Fractal tree: Difference between revisions

m
J: efficiency update (eliminating the need for a paint event handler)
m (J: efficiency update (eliminating the need for a paint event handler))
Line 1,425:
 
<lang j>require'gl2'
coinsert'jgl2'
 
L0=: 50 NB. initial length
A0=: 1r8p1 NB. initial angle: pi divided by 8
Line 1,431 ⟶ 1,432:
dA=: 0.75 NB. shrink factor for angle
N=: 14 NB. number of branches
 
L=: L0*dL^1+i.N NB. lengths of line segments
 
NB. relative angles of successive line segments
A=: A0*(dA^i.N) +/\@:*("1) _1 ^ #:i.2 ^ N
 
NB. end points for each line segment
P=: 0 0+/\@,"2 +.*.inv (L0,0),"2 L,"0"1 A
 
P_C_paint=: gllines_jgl2_@:<.@(10 + ,/"2 P-"1<./,/P)
wd {{)n
pc P closeok;
setp wh 480 640;
cc C isigraphisidraw flush;
pshow;
}}</lang>
 
P_C_paint=:gllines gllines_jgl2_@:<.@(10 + ,/"2 P-"1<./,/P)</lang>
 
See the [[Talk:Fractal tree#J Explanation|talk page]] for some implementation notes.
6,962

edits