From f75a52474b4505a031b091a40907ada4e76d2648 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Mon, 1 Dec 2008 13:15:47 -0600 Subject: [PATCH 1/4] flatland: minor changes --- extra/flatland/flatland.factor | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/extra/flatland/flatland.factor b/extra/flatland/flatland.factor index a33da32908..c98c5a6c57 100644 --- a/extra/flatland/flatland.factor +++ b/extra/flatland/flatland.factor @@ -176,3 +176,45 @@ METHOD: height ( -- height ) \\ top>> bottom>> bi - ; ! METHOD: to-extent ( -- ) ! { [ left>> ] [ right>> ] [ bottom>> ] [ top>> ] } cleave boa ; +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +METHOD: to-the-left-of? ( sequence -- ? ) \\ x left bi* < ; +METHOD: to-the-right-of? ( sequence -- ? ) \\ x right bi* > ; + +METHOD: below? ( sequence -- ? ) \\ y bottom bi* < ; +METHOD: above? ( sequence -- ? ) \\ y top bi* > ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +! Some support for the' 'rect' class from math.geometry.rect' + +! METHOD: width ( rect -- width ) dim>> first ; +! METHOD: height ( rect -- height ) dim>> second ; + +! METHOD: left ( rect -- left ) loc>> x +! METHOD: right ( rect -- right ) [ loc>> x ] [ width ] bi + ; + +! METHOD: to-the-left-of? ( sequence rect -- ? ) [ x ] [ loc>> x ] bi* < ; +! METHOD: to-the-right-of? ( sequence rect -- ? ) [ x ] [ loc>> x ] bi* > ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +USING: locals combinators ; + +:: wrap ( POINT RECT -- POINT ) + + { + { [ POINT RECT to-the-left-of? ] [ RECT right ] } + { [ POINT RECT to-the-right-of? ] [ RECT left ] } + { [ t ] [ POINT x ] } + } + cond + + { + { [ POINT RECT below? ] [ RECT top ] } + { [ POINT RECT above? ] [ RECT bottom ] } + { [ t ] [ POINT y ] } + } + cond + + 2array ; From d9b4402ae212da65776d172d8990ce52fb7d003f Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Mon, 1 Dec 2008 13:16:30 -0600 Subject: [PATCH 2/4] boids.ui: removed --- extra/boids/ui/ui.factor | 176 --------------------------------------- 1 file changed, 176 deletions(-) delete mode 100755 extra/boids/ui/ui.factor diff --git a/extra/boids/ui/ui.factor b/extra/boids/ui/ui.factor deleted file mode 100755 index ddb25ccd8d..0000000000 --- a/extra/boids/ui/ui.factor +++ /dev/null @@ -1,176 +0,0 @@ - -USING: combinators.short-circuit kernel namespaces - math - math.trig - math.functions - math.vectors - math.parser - hashtables sequences threads - colors - opengl - opengl.gl - ui - ui.gadgets - ui.gadgets.handler - ui.gadgets.slate - ui.gadgets.theme - ui.gadgets.frames - ui.gadgets.labels - ui.gadgets.buttons - ui.gadgets.packs - ui.gadgets.grids - ui.gestures - assocs.lib vars rewrite-closures boids accessors - math.geometry.rect - newfx - processing.shapes ; - -IN: boids.ui - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! draw-boid -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: draw-boid ( boid -- ) - glPushMatrix - dup pos>> gl-translate-2d - vel>> first2 rect> arg rad>deg 0 0 1 glRotated - { { 0 5 } { 0 -5 } { 20 0 } } triangle - fill-mode - glPopMatrix ; - -: draw-boids ( -- ) boids> [ draw-boid ] each ; - -: boid-color ( -- color ) T{ rgba f 1.0 0 0 0.3 } ; - -: display ( -- ) - boid-color >fill-color - draw-boids ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -VAR: slate - -VAR: loop - -: run ( -- ) - slate> rect-dim >world-size - iterate-boids - slate> relayout-1 - yield - loop> [ run ] when ; - -: button* ( string quot -- button ) closed-quot ; - -: toggle-loop ( -- ) loop> [ loop off ] [ loop on [ run ] in-thread ] if ; - -VARS: population-label cohesion-label alignment-label separation-label ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: update-population-label ( -- ) - "Population: " boids> length number>string append - 20 32 pad-right population-label> set-label-string ; - -: add-10-boids ( -- ) - boids> 10 random-boids append >boids update-population-label ; - -: sub-10-boids ( -- ) - boids> 10 tail >boids update-population-label ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: truncate-value ( n -- n ) 10 * round 10 / ; - -: update-cohesion-label ( -- ) - "Cohesion: " cohesion-weight> truncate-value number>string append - 20 32 pad-right cohesion-label> set-label-string ; - -: update-alignment-label ( -- ) - "Alignment: " alignment-weight> truncate-value number>string append - 20 32 pad-right alignment-label> set-label-string ; - -: update-separation-label ( -- ) - "Separation: " separation-weight> truncate-value number>string append - 20 32 pad-right separation-label> set-label-string ; - -: inc-cohesion-weight ( -- ) cohesion-weight inc* update-cohesion-label ; -: dec-cohesion-weight ( -- ) cohesion-weight dec* update-cohesion-label ; - -: inc-alignment-weight ( -- ) alignment-weight inc* update-alignment-label ; -: dec-alignment-weight ( -- ) alignment-weight dec* update-alignment-label ; - -: inc-separation-weight ( -- ) separation-weight inc* update-separation-label ; -: dec-separation-weight ( -- ) separation-weight dec* update-separation-label ; - -: boids-window* ( -- ) - init-variables init-world-size init-boids loop on - - ""