% Tree
proc AddGradient (c1, c2, n : int)
var clr : int
var r1, g1, b1, r2, g2, b2, 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 AddGradient
AddGradient (114, 114, 220)
AddGradient (2, 10, 35)
type Point :
record
x, y : real
end record
var holdPoint : Point
holdPoint.x := 0
holdPoint.y := 0
fcn RandReal : real
result (Rand.Real * 2 - 1) * 10
end RandReal
fcn AngleFrom (X, Y : real, dist, ang : real) : Point
holdPoint.x := (cosd (ang) * dist) + X
holdPoint.y := (sind (ang) * dist) + Y
result holdPoint
end AngleFrom
var md : int := 150
var inc : real := 45
var reduc : real := 2
var numB : int := 3
proc MakeTree (X, Y : real, ang : real, dist : real)
var test := AngleFrom (X, Y, dist, ang)
if 511 - round (255 * dist / md) + 1 <= 511 - 36 then
Draw.ThickLine (round (X), round (Y), round (test.x), round (test.y), round (dist / md * 25), 511 - round (255 * dist / md) + 1)
else
Draw.ThickLine (round (X), round (Y), round (test.x), round (test.y), round (dist / md * 10), 511 - round (255 * dist / md) + 1)
end if
if dist <= 10 then
return
end if
for i : 0 .. numB
MakeTree (test.x, test.y, RandReal + ang + (inc * ((i / numB) * 2 - 1)), dist / reduc + (dist / reduc * Rand.Real * Rand.Real))
end for
end MakeTree
MakeTree (maxx div 2, 0, 90 + Rand.Int (-15, 15), md) |