Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Julia sets - fractals
Author Message
MysticAngel

Posted: Thu Mar 27, 2003 6:34 pm   Post subject: Julia sets - fractals

this a really good and a neat program. i did ran into a some trouble and coudnt figure out the problem, but i did it.its fun. u care to run it u would find it pretty fun and the fractals are beautiful. the higher the maxcount the bettter the picture and u can also play around with the count + 55. u canchange to any color by saying count + something. anyways enjoy.

 code: var p, q : real var maxcount, count : int var win1, win2 : int var rx, ry, rx2, ry2 : real var col : string put "Please enter a value for p " get p put " " put "Please enter a value for q" get q put "" loop     put "please enter max count between 20 and 200 "     get maxcount     exit when maxcount >= 20 and maxcount <= 200     put "Enter thye maxcount only between 20 to 200 " end loop win2 := Window.Open ("graphics:800;700,position:150;150,nocursor") for x : 0 .. maxx     for y : 0 .. maxy         rx := 3.5 / maxx * x - 1.75         ry := 3.5 / maxy * y - 1.75         count := 1         loop             rx2 := rx * rx - ry * ry + p             ry2 := 2 * rx * ry + q             rx := rx2             ry := ry2             exit when rx * rx + ry * ry > 4| count = maxcount             count := count + 1         end loop         if count < maxcount then             Draw.Dot (x, y, count + 55)         else             Draw.Dot (x, y, white)         end if     end for end for

MOD Edit: I'm impressed... Mostly with the fact that you stuck to your goals and accompleshed them. Sorry we couldn't help you that much with it Also, if anyone comes up with some interesting results, post the numbers used +15Bits - Tony

Catalyst

Posted: Thu Mar 27, 2003 7:44 pm   Post subject: (No subject)

im glad u figured out ur prob, sorry i didnt post in time(doesnt matter now), heres my prog:

note: to change the res, just change the window size

 code: View.Set ("graphics:150;150,nobuttonbar,position:300;300") proc ColorAdd (c1, c2, n : int)     var clr : int     var r1, g1, b1 : real     var r2, g2, b2 : real     var p, p0 : real     RGB.GetColor (c1, r1, g1, b1)     RGB.GetColor (c2, r2, g2, b2)     const a := 50     for i : 1 .. n         p := (i / n) * 100         p0 := 100 - p         clr := RGB.AddColor ((((r1 * p) + (r2 * p0)) / 2) / a, (((g1 * p) + (g2 * p0)) / 2) / a, (((b1 * p) + (b2 * p0)) / 2) / a)     end for end ColorAdd ColorAdd (yellow, blue, 25) function distance (x1, y1, x2, y2 : real) : real     result ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5 end distance var ox, oy : real := maxx div 2 type complex :     record         r : real         i : real     end record function AddComplex (comp1, comp2 : complex) : complex     var hold : complex     hold.r := comp1.r + comp2.r     hold.i := comp1.i + comp2.i     result hold end AddComplex function MultComplex (comp1, comp2 : complex) : complex     var hold : complex     hold.r := (comp1.r * comp2.r) - (comp1.i * comp2.i)     hold.i := (comp1.r * comp2.i) + (comp1.i * comp2.r)     result hold end MultComplex function Iterate (comp1 : complex, C : complex) : complex     var hold : complex     hold := MultComplex (comp1, comp1)     hold := AddComplex (hold, C)     result hold end Iterate const maxI := 75 var count : int := 0 var dwell : array 0 .. maxx * 3, 0 .. maxy * 3 of real var transX, transY : int := maxx div 2 var c : complex c.r := -0.79 c.i := 0.16 var hold : complex put "Rendering..." for x : -transX .. maxx     for y : -transY .. maxy         hold.r := x / (maxx div 2)         hold.i := y / (maxy div 2)         loop             count += 1             exit when count >= maxI             if distance (hold.r, hold.i, ox, oy) <= maxx div 1.3 then                 hold := Iterate (hold, c)             else                 exit             end if         end loop         dwell (x + maxx, y + maxy) := count         drawdot ((x + transX) div 1, (y + transY) div 1, 255 + round ((dwell (x + maxx, y + maxy) / maxI) * 25))         count := 0     end for end for

MOD Edit: Catalyst with his madd skillz +15Bits -Tony
Dan

Posted: Fri Mar 28, 2003 12:18 pm   Post subject: (No subject)

wow, like way out man....
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
MysticAngel

Posted: Sat Apr 05, 2003 6:10 pm   Post subject: (No subject)

put p as -1, q as 0 and the maxcount as 97
shold give u pretty result
octopi

Posted: Sat Apr 05, 2003 7:59 pm   Post subject: (No subject)

p=0
q=1
maxcount=50

gives a cool lightning bolt effect.
MysticAngel

Posted: Sat Apr 05, 2003 9:23 pm   Post subject: (No subject)

That's pretty cool
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 6 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: