|
Post by matthew on Dec 1, 2006 14:18:52 GMT -5
This is a Sierpinski Snowflake. OPTION Explicit
DIM AppRun : AppRun = TRUE
DIM C : C = 0.5 / Sqr(3)
DIM r2 : r2 = Sqr(3) / 2 DIM r3 : r3 = Sqr(3) / 6
DIM Ex : Ex = 400 DIM Sx : Sx = 120 DIM Sy : Sy = 125
DIM x : x = 1 DIM y : y = 0
DIM u DIM v
DIM x0 DIM y0
SUB Main()
IF (Graphics.Initialize <> TRUE) THEN EXIT SUB Graphics.SetTitle "Sierpinski Snowflake" Key.Initialize Graphics.Clear &h000000 DrawFlake While AppRun = TRUE IF Rnd(1) > 0.5 And AppRun = TRUE THEN x0 = 0.5 * x + r3 * y y0 = r3 * x - 0.5 * y ELSE x0 = 0.5 * x - r3 * y + 0.5 y0 = -r3 * x - 0.5 * y + r3 End IF x = x0 y = y0 DrawFlake IF Key.Pressed(1) Or Key.Pressed(0) = TRUE THEN AppRun = FALSE System.ProcessMessages Wend Do While AppRun = TRUE IF Key.Pressed(1) Or Key.Pressed(0) = TRUE THEN AppRun = FALSE System.ProcessMessages Loop Graphics.Terminate Key.Terminate End SUB
CALL Main
SUB DrawFlake()
Graphics.SetPoint x * Ex + Sx, Sy - y * Ex, ARGB(255, 255, 255, 255) u = 0.5 * x - r2 * y v = -r2 * x - 0.5 * y Graphics.SetPoint u * Ex + Sx, Sy - v * Ex, ARGB(255, 255, 255, 255) u = -0.5 * x + r2 * y + 1 v = -r2 * x - 0.5 * y Graphics.SetPoint u * Ex + Sx, Sy - v * Ex, ARGB(255, 255, 255, 255) Graphics.Display System.Pause 1
End SUB
|
|
|
Post by Guilect on Dec 1, 2006 16:10:44 GMT -5
Hey wait a minute. When I ran this program I got the EXACT same image. I thought that no two snowflakes were identical. ;D
|
|
|
Post by matthew on Dec 1, 2006 16:30:29 GMT -5
^^
|
|
|
Post by u9 on Dec 3, 2006 10:56:06 GMT -5
haha Anyways, this gives me an idea. You could try rendering fractals with sub-pixel acuracy. Here's a paper for the interested reader.
|
|
|
Post by matthew on Dec 3, 2006 18:11:13 GMT -5
^^ Interesting Link
|
|