Computer Science Canada JULIA SETS (Graphic Trick) |
Author: | vexd [ Sun Oct 05, 2003 4:57 pm ] |
Post subject: | JULIA SETS (Graphic Trick) |
%|-------------------------------------------------------> %|Author: VeXD %|Date: Sept, 30 2003 %|Purpose: To make a program that will draw a julia set fractal image. %|Input: User will input numbers. 2 Reals and 1 Integer. %|Output: This program will output the julia set image %|-------------------------------------------------------> var p : real var q : real var rx : real var rx2 : real var ry : real var ry2 : real var rlMath : real var win : int var intMaxCount : int var intCount : int := 0 var intColor : int := 0 put "Please enter the first value: " .. get p put "Please enter the second value: " .. get q put "Please enter a value for maxcount: " .. loop get intMaxCount exit when intMaxCount >= 20 and intMaxCount <= 200 put "Invalid value for MaxCount, MaxCount must be between 20-200" end loop win := Window.Open ("graphics, nocursor") for x : 0 .. maxx for y : 0 .. maxy rx := 3.5 / maxx * x - 1.75 ry := 3.5 / maxy * y - 1.75 intCount := 0 loop rx2 := rx * rx - ry * ry + p ry2 := 2 * rx * ry + q rx := rx2 ry := ry2 rlMath := rx * rx + ry * ry intCount := intCount + 1 exit when intCount = intMaxCount or rlMath > 4 end loop if intCount < intMaxCount then intColor := intCount + Rand.Int (55, 60) %For Amusement Purposes Only. else intColor := 0 end if Draw.Dot (x, y, intColor) end for end for |