From 48e758814433a32e4ec3051222ed5dfe172c014f Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Sun, 27 Jul 2008 00:10:01 -0500 Subject: [PATCH 1/2] opengl: Put top-left, top-right, bottom-left, bottom-right, in opengl.private --- extra/opengl/opengl.factor | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extra/opengl/opengl.factor b/extra/opengl/opengl.factor index 9e91119247..be70b1e176 100755 --- a/extra/opengl/opengl.factor +++ b/extra/opengl/opengl.factor @@ -195,6 +195,8 @@ TUPLE: sprite loc dim dim2 dlist texture ; : gl-translate ( point -- ) first2 0.0 glTranslated ; + + : four-sides ( dim -- ) dup top-left dup top-right dup bottom-right bottom-left ; From 96d7fd11dcad08cd62f307ea97d989d8e598fd45 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Sun, 27 Jul 2008 00:10:34 -0500 Subject: [PATCH 2/2] math.geometry.rect: Add corner words --- extra/math/geometry/rect/rect.factor | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/extra/math/geometry/rect/rect.factor b/extra/math/geometry/rect/rect.factor index 4503d08a0a..7f0bb94092 100644 --- a/extra/math/geometry/rect/rect.factor +++ b/extra/math/geometry/rect/rect.factor @@ -1,5 +1,7 @@ -USING: kernel arrays sequences math.vectors math.geometry accessors ; +USING: kernel arrays sequences + math math.points math.vectors math.geometry + accessors ; IN: math.geometry.rect @@ -50,3 +52,10 @@ M: rect set-height! ( rect height -- rect ) over dim>> set-second ; M: rect set-x! ( rect x -- rect ) over loc>> set-first ; M: rect set-y! ( rect y -- rect ) over loc>> set-second ; + +! Accessing corners + +: top-left ( rect -- point ) loc>> ; +: top-right ( rect -- point ) [ loc>> ] [ width 1 - ] bi v+x ; +: bottom-left ( rect -- point ) [ loc>> ] [ height 1 - ] bi v+y ; +: bottom-right ( rect -- point ) [ loc>> ] [ dim>> ] bi v+ { 1 1 } v- ;