math.geometry.rect: Add corner words
parent
48e7588144
commit
96d7fd11dc
|
@ -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- ;
|
||||
|
|
Loading…
Reference in New Issue