You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

146 lines
3.3 KiB

/**
* This file is part of the jps-like-websites lib
* URL: https://git.labos.goip.de/chris/jpc-like-websites
* @copyright by its creator Christian Martin
*/
/**
* This file is part of the jps-like-websites lib
* URL: https://git.labos.goip.de/chris/jpc-like-websites
* COPYRIGHT and LICENCE are owned by its creator Christian Martin
* Copy, altering or distribution without the allowance of the owner are prohibited
*/
/**
*
*/
class Shape extends DirectionUnitDependentAttribute {
constructor(defaultValue = 0, defaultUnit = SizeUnits.PIXEL) {
super(defaultValue, defaultUnit);
}
/**
*
* @param {*} amount
* @returns {Shape}
*/
topLeft(amount) {
this._fFirst = amount;
return this;
}
/**
*
* @param {*} amount
* @returns {Shape}
*/
topRight(amount) {
this._fSecond = amount;
return this;
}
/**
*
* @param {*} amount
* @returns {Shape}
*/
bottomLeft(amount) {
this._fForth = amount;
return this;
}
/**
*
* @param {*} amount
* @returns {Shape}
*/
bottomRight(amount) {
this.fThird = amount;
return this;
}
/**
*
* @param {*} amount
* @returns {Shape}
*/
diagonalPositive(amount) {
return this.bottomLeft(amount).topRight(amount);
}
/**
*
* @param {*} amount
* @returns {Shape}
*/
diagonalNegative(amount) {
return this.topLeft(amount).bottomRight(amount);
}
left(amount) {
return this.topLeft(amount).bottomLeft(amount);
}
right(amount) {
return this.topRight(amount).bottomRight(amount);
}
/**
*
* @param {*} amount
*/
getSidingRefValueMap() {
return {
[SidingRefCorners.TOPLEFT]: this.getBySidingRef(SidingRefCorners.TOPLEFT),
[SidingRefCorners.TOPRIGHT]: this.getBySidingRef(SidingRefCorners.TOPRIGHT),
[SidingRefCorners.BOTTOMLEFT]: this.getBySidingRef(SidingRefCorners.BOTTOMLEFT),
[SidingRefCorners.BOTTOMRIGHT]: this.getBySidingRef(SidingRefCorners.BOTTOMRIGHT),
}
}
}
class ShapeChain extends Shape {
_modifier;
constructor(modifier) {
super();
this._modifier = modifier;
}
/**
*
* @returns {Modifier|ChainableModifier}
*/
toModifier() {
return this._modifier
.clip(this);
}
/**
*
* @returns {Modifier|ChainableModifier}
*/
ensureModifier() {
return this.toModifier()
}
/**
*
* @returns {Component} the Component that was (supposed to be) modified by this obj.
*/
toComponent() {
return this._modifier
.clip(this)
.toComponent();
}
/**
*
* @param {Component|Array<Component>} innerComponent children of the Component under modification.
* @returns {Component}
*/
childContext(innerComponent) {
return this._modifier
.clip(this)
.toComponent()
.childContext(innerComponent);
}
}
const Shapes = Object.freeze({
Rectangle: new Shape(),
RoundedCorner: new Shape(),
Circle: new Shape(49, SizeUnits.PERCENT)
})