mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-17 05:47:34 +08:00
Comment sizes and color fixed
This commit is contained in:
@@ -68,6 +68,14 @@ export default class Utility {
|
||||
return Math.round(num * power) / power
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Number} a
|
||||
* @param {Number} b
|
||||
*/
|
||||
static approximatelyEqual(a, b) {
|
||||
return !(Math.abs(a - b) > Number.EPSILON)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Number[]} viewportLocation
|
||||
* @param {HTMLElement} movementElement
|
||||
|
||||
@@ -44,8 +44,8 @@ export default class IDraggableElement extends IElement {
|
||||
super(entity, template)
|
||||
this.locationX = 0
|
||||
this.locationY = 0
|
||||
this.sizeX = -1
|
||||
this.sizeY = -1
|
||||
this.sizeX ??= 0 // It may be set in the template already
|
||||
this.sizeY ??= 0 // It may be set in the template already
|
||||
}
|
||||
|
||||
computeSizes() {
|
||||
|
||||
@@ -73,12 +73,9 @@ export default class LinearColorEntity extends IEntity {
|
||||
const r = this.R.value
|
||||
const g = this.G.value
|
||||
const b = this.B.value
|
||||
if (
|
||||
!(Math.abs(r - g) > Number.EPSILON)
|
||||
&& !(Math.abs(r - b) > Number.EPSILON)
|
||||
&& !(Math.abs(g - b) > Number.EPSILON)
|
||||
) {
|
||||
this.V.value = 0
|
||||
if (Utility.approximatelyEqual(r, g) && Utility.approximatelyEqual(r, b) && Utility.approximatelyEqual(g, b)) {
|
||||
this.S.value = 0
|
||||
this.V.value = r
|
||||
return
|
||||
}
|
||||
const max = Math.max(r, g, b)
|
||||
|
||||
@@ -155,8 +155,24 @@ export default class ObjectEntity extends IEntity {
|
||||
this.getType() == Configuration.nodeType.comment ? Configuration.defaultCommentWidth : undefined
|
||||
}
|
||||
|
||||
/** @param {Number} value */
|
||||
setNodeWidth(value) {
|
||||
if (!this.NodeWidth) {
|
||||
this.NodeWidth = new IntegerEntity()
|
||||
}
|
||||
this.NodeWidth.value = value
|
||||
}
|
||||
|
||||
getNodeHeight() {
|
||||
return this.NodeHeight ??
|
||||
this.getType() == Configuration.nodeType.comment ? Configuration.defaultCommentHeight : undefined
|
||||
}
|
||||
|
||||
/** @param {Number} value */
|
||||
setNodeHeight(value) {
|
||||
if (!this.NodeHeight) {
|
||||
this.NodeHeight = new IntegerEntity()
|
||||
}
|
||||
this.NodeHeight.value = value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,15 +16,11 @@ export default class CommentNodeTemplate extends IResizeableTemplate {
|
||||
constructed(element) {
|
||||
if (element.entity.CommentColor) {
|
||||
this.#color.setFromRGBANumber(element.entity.CommentColor.toNumber())
|
||||
this.#color.setFromHSVA(this.#color.H.value, this.#color.S.value, Math.pow(this.#color.V.value, 0.45) * 0.67)
|
||||
}
|
||||
// Dimming the colors to 2/3
|
||||
const factor = 2 / 3
|
||||
this.#color.setFromRGBA(
|
||||
this.#color.R.value,
|
||||
this.#color.G.value,
|
||||
this.#color.B.value,
|
||||
)
|
||||
element.classList.add("ueb-node-style-comment", "ueb-node-resizeable")
|
||||
element.sizeX ??= 25 * Configuration.gridSize
|
||||
element.sizeY ??= 6 * Configuration.gridSize
|
||||
super.constructed(element) // Keep it at the end because it calls this.getColor() where this.#color must be initialized
|
||||
}
|
||||
|
||||
@@ -50,8 +46,10 @@ export default class CommentNodeTemplate extends IResizeableTemplate {
|
||||
|
||||
/** @param {Number} value */
|
||||
setSizeX(value) {
|
||||
value = Math.round(value)
|
||||
if (value >= Configuration.gridSet * Configuration.gridSize) {
|
||||
this.element.sizeX = value
|
||||
this.element.entity.setNodeWidth(this.element.sizeX)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -59,8 +57,10 @@ export default class CommentNodeTemplate extends IResizeableTemplate {
|
||||
|
||||
/** @param {Number} value */
|
||||
setSizeY(value) {
|
||||
value = Math.round(value)
|
||||
if (value >= 3 * Configuration.gridSize) {
|
||||
this.element.sizeY = Math.max(value, 3 * Configuration.gridSize)
|
||||
this.element.entity.setNodeHeight(this.element.sizeY)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user