math.geometry.rect: Add corner words

db4
Eduardo Cavazos 2008-07-27 00:10:34 -05:00
parent 48e7588144
commit 96d7fd11dc
1 changed files with 10 additions and 1 deletions

View File

@ -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- ;