_Title "Ashish Fractals Plus! mods by bplus 2017-10-19, press space to return to menu"
cp 2, "Fractal Menu:"
lp 4, 25, " 1 Circle"
lp 5, 25, " 2 Arc"
lp 6, 25, " 3 Tree"
lp 7, 25, " 4 Quad"
lp 8, 25, " 5 Quad & Circle"
lp 9, 25, " 6 Squares forming triangle"
lp 10, 25, " 7 Sierpinski Carpet"
lp 11, 25, " 8 Kite"
lp 12, 25, " 9 Dragon"
lp 13, 25, "10 Triangle of Circles"
lp 14, 25, "11 Vicsek"
lp 15, 25, "12 Circle Illusion?"
lp 16, 25, "13 Sierpinski Triangle"
lp 17, 25, "14 Plus, another variation"
lp 18, 25, "15 Sierpinski Fies a Kite"
lp 20, 25, "16 Exit"
Input "Enter the menu number of your choice "; menu
Case 15: SierFliesKiteFrac
r = 40
needUpdate = 1
needUpdate = 0
ttl "Arc Fractal, Press 'w' and 's' to zoom-in and zoom-out, space to return to Menu"
drawArc 400, 300, r, 1
s = map(r, 1, 10000, 1, 300)
CF x + r, y, r / 2
CF x - r, y, r / 2
cIll (x - r) + r / 3, y, r / 2
cIll (x + r) - r / 3, y, r / 2
cIll x, (y + r) - r / 3, r / 2
cIll x, (y - r) + r / 3, r / 2
'Coded By Ashish with <3
'Can you observe circle in this fractal!? (no, sorry)
'I was able to do so... :D
cIll 400, 300, 200
ttl "Circle with 4 line variation, Illusion? press any..."
'Idea from [youtube]https://youtu.be/jPsZwrV9ld0[/youtube]
r = 50
needUpdate = 1
needupadte = 0
ttl "Circle Fractal, Press 'w' and 's' to zoom-in and zoom-out, space to return to Menu"
CF 400, 300, r
s = map(r, 1, 10000, 1, 300)
'Calculate the distance between two points.
dist!
= Sqr((x2!
- x1!
) ^ 2 + (y2!
- y1!
) ^ 2)
drawDragon
400, 300, 400, 300, 60, Rnd * _Pi(2), Rnd * 255, Rnd * 255, Rnd * 255 ttl "Dragon Curve Fractal, press any except space for more..."
drawDragon xx
, yy
, xx
, yy
, 60, Rnd * _Pi(2), Rnd * 255, Rnd * 255, Rnd * 255 ': f = 0 f = f + 1
ttl "Dragon Curve Fractal, press space to exit"
drawArc x + r, y, r / 2, e
drawArc x - r, y, r / 2, e
Sub drawDragon
(cx
, cy
, x
, y
, r
, a
, mR
, mG
, mB
) d = dist(x, y, cx, cy)
Color _RGB(map
(d
, 0, 200, mR
, 0), map
(d
+ y
, y
, d
+ y
, 0, mG
), map
(d
, 0, 200, 0, mB
)) fcirc x, y, r
drawDragon cx
, cy
, x
+ r
* 1.75 * Cos(a
), y
+ r
* 1.75 * Sin(a
), r
* 0.75, a
- 0.62, mR
, mG
, mB
drawDragon cx
, cy
, x
+ r
* 1.75 * Cos(a
+ _Pi), y
+ r
* 1.75 * Sin(a
+ _Pi), r
* 0.75, (a
+ _Pi) - 0.62, mR
, mG
, mB
')+_PI
Sub drawKite
(x
, y
, s
, a
) drawKite x
+ s
* Cos(_Pi(2) - a
), (y
- s
) + s
* Sin(_Pi(2) - a
), s
/ 2, a
drawKite x
+ s
* Cos(_Pi + a
), (y
- s
) + s
* Sin(_Pi + a
), s
/ 2, a
Sub drawKite2
(xx
, yy
, s
, a
) x = xx: y = yy
x2
= x
+ 3 * s
* Cos(_Pi(1 / 2) - a
/ 2): y2
= y
+ 3 * s
* Sin(_Pi(1 / 2) - a
/ 2) x3
= x
+ 3 * s
* Cos(_Pi(1 / 2) + a
/ 2): y3
= y
+ 3 * s
* Sin(_Pi(1 / 2) + a
/ 2) SierLineTri x, y, x2, y2, x3, y3, 0
drawKite2 x
+ 1 * s
* Cos(_Pi(2) - a
), (y
- s
) + 1 * s
* Sin(_Pi(2) - a
), s
/ 2, a
drawKite2 x
+ 1 * s
* Cos(_Pi + a
), (y
- s
) + 1 * s
* Sin(_Pi + a
), s
/ 2, a
Sub drawTree
(x
, y
, r
, a
, s
) internalp5line x
, y
, x
+ r
* Cos(a
- s
), y
+ r
* Sin(a
- s
), r
/ 10, c~&
internalp5line x
, y
, x
+ r
* Cos(a
+ s
* 3), y
+ r
* Sin(a
+ s
* 3), r
/ 10, c~&
drawTree x
+ r
* Cos(a
- s
), y
+ r
* Sin(a
- s
), r
* 0.67, a
- s
, s
drawTree x
+ r
* Cos(a
+ s
* 3), y
+ r
* Sin(a
+ s
* 3), r
* 0.67, a
+ s
* 3, s
'Steve McNeil's copied from his forum note: Radius is too common a name
RadiusError = -subRadius
X = subRadius
Y = 0
' Draw the middle span here so we don't draw it twice in the main loop,
' which would be a problem with blending turned on.
Line (CX
- X
, CY
)-(CX
+ X
, CY
), , BF
RadiusError = RadiusError + Y * 2 + 1
Line (CX
- Y
, CY
- X
)-(CX
+ Y
, CY
- X
), , BF
Line (CX
- Y
, CY
+ X
)-(CX
+ Y
, CY
+ X
), , BF
X = X - 1
RadiusError = RadiusError - X * 2
Y = Y + 1
Line (CX
- X
, CY
- Y
)-(CX
+ X
, CY
- Y
), , BF
Line (CX
- X
, CY
+ Y
)-(CX
+ X
, CY
+ Y
), , BF
'taken from QB64's p5.js
'http://bit.ly/p5jsbas
Sub internalp5line
(x0!
, y0!
, x1!
, y1!
, s!
, col~&
) dx! = x1! - x0!
dy! = y1! - y0!
d!
= Sqr(dx!
* dx!
+ dy!
* dy!
) fcirc x0! + dxx!, y0! + dyy!, s!
dxx! = dxx! + dx! / d!
dyy! = dyy! + dy! / d!
ttl "Kite Fractal, press any"
drawKite 400, 500, 140, .5
'taken from QB64's p5.js
'http://bit.ly/p5jsbas
Function map!
(value!
, minRange!
, maxRange!
, newMinRange!
, newMaxRange!
) map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
'variation BF, B, B, BF
'variation #2 BF, BF, BF, BF
'variation #3 B, B, B, B
'How many plus can you find?
Line (x
, y
)-(x
- r
, y
- r
), , BF
Line (x
, y
)-(x
+ r
, y
- r
), , B
Line (x
, y
)-(x
- r
, y
+ r
), , B
Line (x
, y
)-(x
+ r
, y
+ r
), , BF
Plus x - r / 2, y - r / 2, r / 2.3
Plus x + r / 2, y - r / 2, r / 2.3
Plus x - r / 2, y + r / 2, r / 2.3
Plus x + r / 2, y + r / 2, r / 2.3
'playing with Ashish circle with 4 line by bplus 2017-10-16
Plus 400, 300, 290
ttl "Plus, another variation "
r = 100
needupdate = 1
needupdate = 0
ttl "Quad Inside Circle Inside Quad, press w to widen, s to shrink, space to exit"
quad_circle 400, 300, 0, 0, r, 0
s = map(r, 1, 10000, 1, 300)
Sub quad_circle
(x
, y
, x2
, y2
, r
, e
) Line (x
, y
)-(x2
, y2
), , B
quad_circle (x + x2) / 2, (y + y2) / 2, 0, 0, newR / 2, 0
tx2
= x
+ r
* Cos(_Pi(2) - .7) ty2
= y
+ r
* Sin(_Pi(2) - .7) quad_circle tx1, ty1, tx2, ty2, r / 2, 1
Sub quad_fractal
(x
, y
, r
, e
) Line (x
- r
, y
- r
)-(x
+ r
, y
- r
) Line (x
+ r
, y
- r
)-(x
+ r
, y
+ r
) Line (x
+ r
, y
+ r
)-(x
- r
, y
+ r
) Line (x
- r
, y
+ r
)-(x
- r
, y
- r
) quad_fractal x - r, y - r, r / 2, e
quad_fractal x + r, y - r, r / 2, e
quad_fractal x + r, y + r, r / 2, e
quad_fractal x - r, y + r, r / 2, e
k = 100: dir = .5
ttl "Quads!!, press space to exit"
quad_fractal 400, 300, 100, k
k = k * dir
Line (x
- r
, y
- r
)-(x
+ r
, y
+ r
), _RGB(map
(x
, lowX
, highX
, 0, 255), map
(y
, lowY
, highY
, 255, 0), map
(x
+ y
, lowX
+ lowY
, highX
+ highY
, 255, 0)), BF
v = r * 2
SC x, y - v, r / 3
SC x, y + v, r / 3
SC x + v, y, r / 3
SC x - v, y, r / 3
SC x - v, y - v, r / 3
SC x + v, y + v, r / 3
SC x - v, y + v, r / 3
SC x + v, y - v, r / 3
Line (x
- r
, y
- r
)-(x
+ r
, y
+ r
), _RGB(0, 0, 0), BF
If x
- r
< lowX
Then lowX
= x
- r
If x
+ r
> highX
Then highX
= x
+ r
If y
- r
< lowY
Then lowY
= y
- r
If y
+ r
> highY
Then highY
= y
+ r
v = r * 2
SC0 x, y - v, r / 3
SC0 x, y + v, r / 3
SC0 x + v, y, r / 3
SC0 x - v, y, r / 3
SC0 x - v, y - v, r / 3
SC0 x + v, y + v, r / 3
SC0 x - v, y + v, r / 3
SC0 x + v, y - v, r / 3
lowX = 500
highX = 500
highY = 500
lowY = 500
SC0 500, 350, 120
ttl "Sierpinski_Carpet, press any"
SC 500, 350, 120
ttl "Sierpinski_Carpet, press any"
' after playing with Ashish Kite Fractal, by bplus 2017-10-16
drawKite2 600, 540, 200, a
ttl "Sierpinski flies a Kite, press space to exit"
Sub SierLineTri
(x1
, y1
, x2
, y2
, x3
, y3
, depth
) If depth
= 0 Then 'draw out triangle if level 0 'find midpoints
If x2
< x1
Then mx1
= (x1
- x2
) / 2 + x2
Else mx1
= (x2
- x1
) / 2 + x1
If y2
< y1
Then my1
= (y1
- y2
) / 2 + y2
Else my1
= (y2
- y1
) / 2 + y1
If x3
< x2
Then mx2
= (x2
- x3
) / 2 + x3
Else mx2
= (x3
- x2
) / 2 + x2
If y3
< y2
Then my2
= (y2
- y3
) / 2 + y3
Else my2
= (y3
- y2
) / 2 + y2
If x3
< x1
Then mx3
= (x1
- x3
) / 2 + x3
Else mx3
= (x3
- x1
) / 2 + x1
If y3
< y1
Then my3
= (y1
- y3
) / 2 + y3
Else my3
= (y3
- y1
) / 2 + y1
Line (mx1
, my1
)-(mx2
, my2
) ' 'draw all inner triangles Line (mx2
, my2
)-(mx3
, my3
) Line (mx1
, my1
)-(mx3
, my3
) If depth
< 4 Then 'not done so call me again SierLineTri x1, y1, mx1, my1, mx3, my3, depth + 1
SierLineTri x2, y2, mx1, my1, mx2, my2, depth + 1
SierLineTri x3, y3, mx3, my3, mx2, my2, depth + 1
SierTri 400, 400, 160
ttl "Sierpinski Triangle, press any..."
fcirc x, y, r
TofCs x
+ r
* 1.75 * Cos(t
), y
+ r
* 1.75 * Sin(t
), r
* 0.75, t
TofCs x
+ r
* 1.75 * Cos(_Pi + t
), y
+ r
* 1.75 * Sin(_Pi - t
), r
* 0.75, t
Sub TofCsFrac
'modified for speed as Petr had shown TofCs 500, 200, 80, .5
ttl "Triangle Formed By Circle, press any..."
v = r * 2
tns x, y - v, r / 2
tns x + v, y - r * 2, r / 2
tns x + v, y, r / 2
ttl "Square_formed_triangle, press any..."
tns 250, 450, 100
radius = 130
ttl "Fractal_Trees, press space to return to Menu"
drawTree
400, 400, radius
, _Pi(3 / 2), s
internalp5line
400, 600, 400, 400, radius
/ 10, _RGB(160, 10, 10) v# = v# + 0.01
lp 2, 5, txt$
vicsek x - r, y, r / 3
vicsek x + r, y, r / 3
vicsek x, y + r, r / 3
vicsek x, y - r, r / 3
vicsek x, y, r / 3
vicsek 400, 300, 180
ttl "Vicsek Fractal, press any..."