From 4de326869fc9632756f4000e1f831e1455cb7c7d Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Mon, 1 Dec 2008 17:40:21 -0600 Subject: [PATCH 1/2] boids: Implement Slava's suggestion to have the system iteration happen outside of 'draw-gadget*' --- extra/boids/boids.factor | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/extra/boids/boids.factor b/extra/boids/boids.factor index b0d5bda508..8319a2d8d9 100644 --- a/extra/boids/boids.factor +++ b/extra/boids/boids.factor @@ -25,7 +25,7 @@ USING: kernel ui.render multi-methods multi-method-syntax - combinators.short-circuit.smart + combinators.short-circuit processing.shapes flatland ; @@ -86,7 +86,7 @@ TUPLE: < { radius initial: 25 } ; [ BEHAVIOUR view-angle>> in-view? ] [ eq? not ] } - && ; + 2&& ; :: neighborhood ( SELF OTHERS BEHAVIOUR -- boids ) OTHERS [| OTHER | SELF OTHER BEHAVIOUR within-neighborhood? ] filter ; @@ -154,7 +154,7 @@ M: ungraft* ( -- ) t >>paused drop ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -M:: draw-gadget* ( BOIDS-GADGET -- ) +:: iterate-system ( BOIDS-GADGET -- ) [let | SKY [ BOIDS-GADGET gadget->sky ] BOIDS [ BOIDS-GADGET boids>> ] @@ -183,11 +183,14 @@ M:: draw-gadget* ( BOIDS-GADGET -- ) map - BOIDS-GADGET (>>boids) + BOIDS-GADGET (>>boids) ] ; - origin get - [ BOIDS-GADGET boids>> [ draw-boid ] each ] - with-translation ] ; +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +M:: draw-gadget* ( BOIDS-GADGET -- ) + origin get + [ BOIDS-GADGET boids>> [ draw-boid ] each ] + with-translation ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -197,7 +200,7 @@ M:: draw-gadget* ( BOIDS-GADGET -- ) [ GADGET paused>> [ f ] - [ GADGET relayout-1 25 milliseconds sleep t ] + [ GADGET iterate-system GADGET relayout-1 1 milliseconds sleep t ] if ] loop From 77def0bc962bd65ffc3c5f68f61c2a45d081e351 Mon Sep 17 00:00:00 2001 From: "U-SLAVA-DFB8FF805\\Slava" Date: Mon, 1 Dec 2008 17:53:17 -0600 Subject: [PATCH 2/2] was using each-line from io by accident, dont' even need io in USING: list here --- basis/ui/gadgets/editors/editors.factor | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) mode change 100644 => 100755 basis/ui/gadgets/editors/editors.factor diff --git a/basis/ui/gadgets/editors/editors.factor b/basis/ui/gadgets/editors/editors.factor old mode 100644 new mode 100755 index ad81d18f92..e262ac7fea --- a/basis/ui/gadgets/editors/editors.factor +++ b/basis/ui/gadgets/editors/editors.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2006, 2008 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays documents io kernel math models +USING: accessors arrays documents kernel math models namespaces locals fry make opengl opengl.gl sequences strings io.styles math.vectors sorting colors combinators assocs math.order fry calendar alarms ui.clipboards ui.commands @@ -218,7 +218,7 @@ M: editor ungraft* ] with-editor-translation ; : selection-start/end ( editor -- start end ) - dup editor-mark* swap editor-caret* sort-pair ; + [ editor-mark* ] [ editor-caret* ] bi sort-pair ; : (draw-selection) ( x1 x2 -- ) over - @@ -227,9 +227,8 @@ M: editor ungraft* swap [ gl-fill-rect ] with-translation ; : draw-selected-line ( start end n -- ) - [ start/end-on-line ] keep tuck - [ editor get offset>x ] 2dip - editor get offset>x + [ start/end-on-line ] keep + tuck [ editor get offset>x ] 2bi@ (draw-selection) ; : draw-selection ( -- ) @@ -237,9 +236,9 @@ M: editor ungraft* editor get selection-start/end over first [ 2dup [ - [ 2dup ] dip draw-selected-line + draw-selected-line 1 translate-lines - ] each-line 2drop + ] with with each-line ] with-editor-translation ; M: editor draw-gadget*