Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Julia sets - fractals
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MysticAngel




PostPosted: 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 Sad Also, if anyone comes up with some interesting results, post the numbers used Wink +15Bits - Tony
Sponsor
Sponsor
Sponsor
sponsor
Catalyst




PostPosted: 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 Very Happy +15Bits -Tony
Dan




PostPosted: 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




PostPosted: 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




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

p=0
q=1
maxcount=50


gives a cool lightning bolt effect.
MysticAngel




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

That's pretty cool
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: