-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rainbow Feather.fsx
39 lines (31 loc) · 1.34 KB
/
Rainbow Feather.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#load "FractalFunctions.fsx"
open Fractal
let branchAngle = 0.25
let lengthMultiplier = 1.3/2.0
let widthModifier = -0.5
let startWidth = 3.0
let startLength = 250.0
let numBranches = 5
let asColour x y factor =
let centredX = abs ((imageCentre - startWidth/2.0) - x)
abs (int (((centredX+y)*factor)%510.0) - 255)
let getColour x y =
(asColour x y 2.0,asColour x y 1.5,asColour x y 2.5)
let rec endpoints x y angle length iteration = seq {
let segLength = length/float numBranches
yield endpoint x y (pi*angle) (segLength*float iteration)
if iteration < numBranches then
yield! endpoints x y angle length (iteration + 1)
}
let rec branch x y length width colour angle =
if width > 0.0 then
let angleDegrees = (pi*angle)
line x y angleDegrees length width colour
endpoints x y angle length 0
|> Seq.iteri ( fun i (nextX, nextY) ->
let stageLengthMultiplier = (1.0/float numBranches*float i)
branch nextX nextY (length*lengthMultiplier*stageLengthMultiplier) (width+widthModifier) (getColour x y) (angle+branchAngle)
branch nextX nextY (length*lengthMultiplier*stageLengthMultiplier) (width+widthModifier) (getColour x y) (angle-branchAngle)
)
branch (imageCentre - startWidth/2.0) 70.0 startLength startWidth startColour 0.5
form.ShowDialog()