Drawing Shapes On Canvas
I was interested in animating fractals on canvas, but along the way got a bit distracted and took a detour doing what you see in this post. Here I take the function for a Strange Attractor, an attractor with a fractal structure, and then adjust the constants by a random value selected from a range.
Below you can see the equations from which x and y are derived, we begin drawing at an initial point: (x0,y0) then compute (xn+1, yn+1) using these equations. All three lines being drawn have the same initial point, (0,0), as well as the same initial which can also be seen below.
To adjust the constants each line has its own range for a and b from which a random value is selected. After the value is selected it is added to the previous a or b. This happens after each line has completed a full cycle of plotting, which I have set to 400, so the line will plot 400 points per set of constants. After the 400 coordinates are plotted it updates with the new values and then repeats the process.
You can adjust the ranges that the adjustment to a and b are chosen from by using the inputs below and then hitting the update button.
Functions
Xn+1 = Yn - sin(Xn)|b * Xn - c|^.5
Yn+1 = a - Xn
Initial Constants
a = 0.4
b = 1
c = 0
Lines
Line 1
a:
0.4
b:
1
c:
0
a range:
[
,
]
b range:
[
,
]
Line 2
a:
0.4
b:
1
c:
0
a range:
[
,
]
b range:
[
,
]
Line 3
a:
0.4
b:
1
c:
0
a range:
[
,
]
b range:
[
,
]