avocado-old/packages/math/rectangle/mixin.coffee
2019-03-17 23:45:48 -05:00

41 lines
845 B
CoffeeScript

import {Mixin, Property} from '@avocado/composition'
import {setterName} from '@avocado/string'
import {Vector} from '../vector'
import {Rectangle_} from './index'
export RectangleMixin = (
rectangle = 'rectangle'
x = 'x'
y = 'y'
width = 'width'
height = 'height'
position = 'position'
size = 'size'
meta = {}
) -> (Superclass) ->
setPosition = setterName position
setSize = setterName size
class Rectangle extends Mixin(Superclass).with(
position, x, y, meta[position]
size, width, height, meta[size]
Property rectangle, Object.assign {
get: -> Rectangle.compose this[position], this[size]
set: (rectangle) ->
this[setPosition] Rectangle.position rectangle
this[setSize] Rectangle.size rectangle
return
eq: (l, r) -> Rectangle_.equals l, r
}, meta
)