Author Topic: Fractals [EGSL]  (Read 9792 times)

Tomaaz

  • Guest
Re: Fractals
« Reply #15 on: November 16, 2012, 10:52:19 AM »
Well, I had already downloaded it and I find it's a good (and amazing) presentation, which places EGSL precisely between 'game' and 'graphics'  ::)

I don't think it's particularly good, but it's amazing how easy is creating something like that with EGSL. It has 117 lines of code and it took me maybe half an hour to write it. Adding new effects is extremely easy. I don't think it would be as easy and fun to make it in Python or even BASIC.

Tomaaz

  • Guest
Re: Fractals [EGSL]
« Reply #16 on: December 05, 2012, 07:12:00 PM »
And here is the same Mandelbrot animation written in FreePascal + egslengine. This is really fast!

Code: [Select]
program Mandelbrot;
uses egslengine;

var
x, y, c : integer;
przelx, przely, powiekszenie, przesx, przesy, x2, y2, x3, y3, a, b, z, a2, b2 : double;

 
begin
openwindow(240, 160, 32 ,'Mandelbrot Set');
przelx := 3 / 240;
przely := 2 / 160;
powiekszenie := 1;
przesx := 14.1779999496342;
przesy := 79.999903999999999;

repeat
begin
przelx := 3 / (240 * powiekszenie);
przely := 2 / (160 * powiekszenie);
for x := 0 to 240 do
begin
x3 := x - 120;
for y := 0 to 160 do
begin
y3 := y - 80;
c := 0;
a := 0;
b := 0;
z := 0;
x2 := (przelx * (x3 + (przesx * powiekszenie))) - 2;
y2 := (przely * (y3 + (przesy * powiekszenie))) - 1;
while (c < 255) and (z < 4) do
begin
a2 := a * a - b * b;
b2 := 2 * a * b;
a := a2 + x2;
b := b2 + y2;
z := a * a + b * b;
c := c + 1;
end;
if (c = 255) then
colour(0, 0, 0)
else
colour(255 - c, (c mod 50)* 5, c);
dot(x, y);
end;

end;
if (powiekszenie < 50 * 50 * 50 * 50 * 50 * 50 * 50 * 50) then
powiekszenie := powiekszenie + powiekszenie * 0.04;
redraw();
wait(20);
end;
until (getkey() = 27);
end.

Source code and an executable created on Linux Mint 9 32-bit are attached.

Aurel

  • Guest
Re: Fractals [EGSL]
« Reply #17 on: December 28, 2012, 08:44:56 AM »
I was asking you about pseudo fractal snow flake drawing like is on
screenshot...

Tomaaz

  • Guest
Re: Fractals [EGSL]
« Reply #18 on: December 28, 2012, 11:04:21 AM »
Code: [Select]
require "turtle"
openwindow (640, 550, 32, "Snowflake")
goxy (100, 150)
turnright(90)
function koch(x, t)
if t > 0 then
t=t-1
x=x/3
koch(x, t)
turnleft(60)
koch(x, t)
turnright(120)
koch(x, t)
turnleft(60)
koch(x, t)
else
forward(3*x)
end
end
for x = 1, 3 do
koch(150, 5)
turnright(120)
end
inkey()

You need my turtle library for this. Is this what you want (if you want anything)?
« Last Edit: December 28, 2012, 11:08:49 AM by Tomaaz »

Aurel

  • Guest
Re: Fractals [EGSL]
« Reply #19 on: December 28, 2012, 12:17:16 PM »
Thanks Tomaaz...
Quote
You need my turtle library for this. Is this what you want (if you want anything)?
of course that i need and what this means ' if you want anything? '... ???
I need this because i build wifi 2.4GHz antennas based on fractals(pseudo fractals).
And like you may see on my picture,it is small fractal antenna.
red and blue lines are copper wires.
Do you understand now?

Where is this turtle lib?
I am interested in this antenna design because are simple to build and have good gain.
On screenshot you can see my last design based on 'curtain quad' antenna.

Tomaaz

  • Guest
Re: Fractals [EGSL]
« Reply #20 on: December 28, 2012, 12:28:22 PM »
need and what this means ' if you want anything? '... ???

I wasn't sure because you were talking about the past ("I was asking..."). The library is attached to this post. Keep it in the same folder where the Snowflake source code.

You can experiment with bolded values to get different effect:
Quote
...
forward(3*x)
...
for x = 1, 3 do
   koch(120, 5)
   turnright(120)
end
« Last Edit: December 28, 2012, 12:31:11 PM by Tomaaz »

Aurel

  • Guest
Re: Fractals [EGSL]
« Reply #21 on: December 28, 2012, 01:18:15 PM »
Yes 'was'.... ;D
Ok thanks.. ;)