@appshuttle.io/turing
Version:
Code Generation Library used in Shuttle
82 lines (62 loc) • 1.66 kB
JavaScript
const Dimension = require('./Dimension')
class Frame {
constructor(parameters) {
this.x = new Dimension(parameters.x)
this.y = new Dimension(parameters.y)
this.width = new Dimension(parameters.width)
this.height = new Dimension(parameters.height)
}
// X Dimension Getters and Setters
getX() {
return this.x
}
setX(x) {
this.x = x
}
getCalculatedXValue(device) {
if (this.x.getScale() === 'EXACT') {
return this.x.getValue()
}
return device.frame.width * this.x.getValue()
}
// Y Dimension Getters and Setters
getY() {
return this.y
}
setY(y) {
this.y = y
}
getCalculatedYValue(device) {
if (this.y.getScale() === 'EXACT') {
return this.y.getValue()
}
return device.frame.height * this.y.getValue()
}
// Width Dimension Getters and Setters
getWidth() {
return this.width
}
setWidth(width) {
this.width = width
}
getCalculatedWidthValue(device) {
if (this.width.getScale() === 'EXACT') {
return this.width.getValue()
}
return device.frame.width * this.width.getValue()
}
// Height Dimension Getters and Setters
getHeight() {
return this.height
}
setHeight(height) {
this.height = height
}
getCalculatedHeightValue(device) {
if (this.height.getScale() === 'EXACT') {
return this.height.getValue()
}
return device.frame.height * this.height.getValue()
}
}
module.exports = Frame