]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/golden-section/golden-section.factor
tools.test: Make the flag public. Finish porting tester changes to fuzzer.
[factor.git] / unmaintained / golden-section / golden-section.factor
1
2 USING: kernel namespaces math math.constants math.functions math.order
3        arrays sequences
4        opengl opengl.gl opengl.glu ui ui.render ui.gadgets ui.gadgets.theme
5        ui.gadgets.cartesian colors accessors combinators.cleave
6        processing.shapes ;
7
8 IN: golden-section
9
10 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11
12 ! omega(i) = 2*pi*i*(phi-1)
13
14 ! x(i) = 0.5*i*cos(omega(i))
15 ! y(i) = 0.5*i*sin(omega(i))
16
17 ! radius(i) = 10*sin((pi*i)/720)
18
19 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
20
21 : omega ( i -- omega ) phi 1- * 2 * pi * ;
22
23 : x ( i -- x ) [ omega cos ] [ 0.5 * ] bi * ;
24 : y ( i -- y ) [ omega sin ] [ 0.5 * ] bi * ;
25
26 : center ( i -- point ) { x y } 1arr ;
27
28 : radius ( i -- radius ) pi * 720 / sin 10 * ;
29
30 : color ( i -- i ) dup 360.0 / dup 0.25 1 rgba boa >fill-color ;
31
32 : line-width ( i -- i ) dup radius 0.5 * 1 max glLineWidth ;
33
34 : draw ( i -- ) [ center ] [ radius 1.5 * 2 * ] bi circle ;
35
36 : dot ( i -- ) color line-width draw ;
37
38 : golden-section ( -- ) 720 [ dot ] each ;
39
40 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
41
42 : <golden-section> ( -- gadget )
43   <cartesian>
44     {  600 600 }       >>pdim
45     { -400 400 }       x-range
46     { -400 400 }       y-range
47     [ golden-section ] >>action ;
48
49 : golden-section-window ( -- )
50   [ <golden-section> "Golden Section" open-window ] with-ui ;
51
52 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
53
54 MAIN: golden-section-window