From 86a881f1f2b8facdb37258610f87298abffa0963 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Mon, 28 Jul 2008 00:50:22 -0500 Subject: [PATCH] boids.ui: Use processing.shapes --- extra/boids/ui/ui.factor | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/extra/boids/ui/ui.factor b/extra/boids/ui/ui.factor index 064eda841b..f380441960 100755 --- a/extra/boids/ui/ui.factor +++ b/extra/boids/ui/ui.factor @@ -1,6 +1,7 @@ USING: combinators.short-circuit kernel namespaces math + math.trig math.functions math.vectors math.parser @@ -21,7 +22,8 @@ USING: combinators.short-circuit kernel namespaces ui.gestures assocs.lib vars rewrite-closures boids accessors math.geometry.rect - newfx ; + newfx + processing.shapes ; IN: boids.ui @@ -29,17 +31,22 @@ IN: boids.ui ! draw-boid ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -: point-a ( boid -- a ) pos>> ; - -: point-b ( boid -- b ) [ pos>> ] [ vel>> normalize* 20 v*n ] bi v+ ; - -: boid-points ( boid -- point-a point-b ) [ point-a ] [ point-b ] bi ; - -: draw-boid ( boid -- ) boid-points gl-line ; +: 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 + glPopMatrix ; : draw-boids ( -- ) boids> [ draw-boid ] each ; -: display ( -- ) black gl-color draw-boids ; +: boid-color ( -- color ) { 1.0 0 0 0.3 } ; + +: display ( -- ) + white gl-clear + boid-color >fill-color + 2 glLineWidth + draw-boids ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!