Mintoris

Author Topic: Plasma (ported)  (Read 1535 times)

Operator

  • Full Member
  • ***
  • Posts: 14
Plasma (ported)
« on: Aug 12, 2014, 12:51 PM »
Hi I'm new to Mintoris Basic, for getting used to it a snipped port was done..

? Fps seems not to match, while it shows ~5 fps on my MotoG, the refresh rate seems to be 1

? Any hints to make this faster

? Any command to refresh the screen after all points have been calculated

Code: [Select]
' sdl plasma example on: https://gist.github.com/stevenlr/824019
' ported to CMLua by Cybermonkey 08/2014
' ported to OxygenBasic by Peter Wirbelauer  o7.o8.2o14
' ported to X11Basic by vsync o8.o8.2o14
' ported to Smart Basic on iPhone by Henko 8/8/2014
' mod1 by Mr. Kybernetic
' mod2 by Operator
' ported to Mintoris Basic on MotoG by Operator

bw = 180
bh = 100

size = 4

Graphics On
SetScale 2*bh,2*bw

DIM r(256)
DIM g(256)
DIM b(256)
k3=sqrt(35600)/50

FOR x = 0 TO 255
  r(x) = int((255-(SIN(Pi*3*x/255)+1)*127))
  g(x) = int(254*(SIN(PI*2*x/127)+1)/4)
  b(x) = int(255-r(x))
NEXT x

iter:
  t1 = Time()

  FOR y =0 TO bh step 5
    FOR x = 0 TO bw step 5
      
     ind = int(SIN(x/50+f+y/200+SIN((1-y/100+(1-x/160)*1)))*63.5+127)
     'ind = int(127+127*sin(x*f/(y+1.1)))
     ColorRGBA r(ind), g(ind), b(ind)
     Rect x,y,x+size,y+size, 1

    NEXT x
  NEXT y

  f = f + 0.1
  
  Color 0,0,0
  Rect 20,120,100,140,1

  fps = 1000/(TIME()-t1)
  DrawText "fps= "+Left$(str$(fps),3),20,140,0,1
  
goto iter
« Last Edit: Aug 30, 2014, 04:38 PM by Operator »

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: Plasma (ported)
« Reply #1 on: Aug 14, 2014, 01:01 PM »
This is a really cool program. I've attached Plasma.bas above so you can easily download it.

The wait 1 will control when the screen is updated. Without the Wait 1, the screen will automatically update 1/sec.

  DrawText "fps= "+Left$(str$(fps),3),20,140,0,1

  Wait 1
  
goto iter


-Chuck
« Last Edit: Aug 14, 2014, 01:27 PM by Chuck »

Operator

  • Full Member
  • ***
  • Posts: 14
Re: Plasma (ported)
« Reply #2 on: Aug 17, 2014, 04:02 PM »
Hello Chuck,
Thanks for your feedback and nice hint
with wait 1. With my MotoG I get ~1.5 fps. A bit slow I guess....