Author Topic: Peacock Butterfly  (Read 1899 times)

0 Members and 2 Guests are viewing this topic.

Peter

  • Guest
Peacock Butterfly
« on: December 20, 2013, 06:00:10 AM »
Deleted
« Last Edit: April 25, 2015, 03:26:44 AM by Peter »

JRS

  • Guest
Re: Peacock Butterfly
« Reply #1 on: December 20, 2013, 09:58:23 AM »
Hi Peter,

I tried to convert your example to ScriptBasic but have a couple questions.

Code: [Select]
For i=v to <1
This syntax isn't supported in SB. Can you post a traditional BASIC equivalent?

The Line_Draw() function in SB requires a value generated by the RGB() function for color. When I printed c with the first iteration it was 1 (one).


JRS

  • Guest
Re: Peacock Butterfly
« Reply #2 on: December 20, 2013, 10:30:05 AM »
Thanks!

I still can't get my Line_Draw() function to work with the values being used.

Sorry.  :'(

Charles Pegge

  • Guest
Re: Peacock Butterfly
« Reply #3 on: December 20, 2013, 10:49:22 AM »
A fair substitute:
For i=v to .999999


c is an RGB composite: 1..0x00FFFFFF

Time: 21 secs

JRS

  • Guest
Re: Peacock Butterfly
« Reply #4 on: December 20, 2013, 11:03:10 AM »
Bit in the ass again by uninitialized variables.  ::)



Code: [Select]
' ScriptBasic Peacock

DECLARE SUB Window ALIAS "SB_Window" LIB "sdl"
DECLARE SUB WaitKey ALIAS "SB_WaitKey" LIB "sdl"
DECLARE SUB Ticks ALIAS "SB_Ticks" LIB "sdl"
DECLARE SUB UpdateRect ALIAS "SB_UpdateRect" LIB "sdl"
DECLARE SUB Draw_Line ALIAS "SB_Draw_Line" LIB "sdl"

Window 700, 500, "Peacock Plume"
q = 1
q1 = 0.9997
v = 0.01
vv = 0.0004
xs = 750
ys = 730
xm = 650
ym = 180
br = -0.7393
bi = 0.117
ar = 0.0
ai = 0.0
_cos = cos(0.01)
_sin = sin(0.01)
t1 = Ticks()
FOR d = 1 TO 15000
  tr = ar * ar - ai * ai + br
  ti = 2 * ar * ai + bi
  x  = tr * xs + xm
  y  = ti * ys + ym
  v  = v + vv
  q  = q * q1
  c  = d ^ 2.1
  Draw_Line x, y, x + (_cos * 50 * q), y + (_sin * 50 * q), c
  ar = tr
  ai = ti
NEXT
UpdateRect
t2 = Ticks()
t3 = (t2 - t1) / 1000
PRINT "Time:  ", FORMAT("%.4f", t3), " seconds.\n"
PRINT d-1, " Lines Drawn\n"
WaitKey

jrs@laptop:~/sb/sb22/sdl$ scriba peacock.sb
Time:  0.0880 seconds.
15000 Lines Drawn
jrs@laptop:~/sb/sb22/sdl$
« Last Edit: December 20, 2013, 04:41:59 PM by John »