mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:50:33 +08:00
26 lines
913 B
JavaScript
Executable File
26 lines
913 B
JavaScript
Executable File
import IDraggableControlTemplate from "./IDraggableControlTemplate.js"
|
|
import Utility from "../Utility.js"
|
|
|
|
/** @typedef {import("../element/ColorHandlerElement").default} ColorHandlerElement */
|
|
|
|
/** @extends {IDraggableControlTemplate<ColorHandlerElement>} */
|
|
export default class ColorHandlerTemplate extends IDraggableControlTemplate {
|
|
|
|
/**
|
|
* @param {Number} x
|
|
* @param {Number} y
|
|
* @returns {[Number, Number]}
|
|
*/
|
|
adjustLocation(x, y) {
|
|
const radius = Math.round(this.movementSpaceSize[0] / 2)
|
|
x = x - radius
|
|
y = -(y - radius)
|
|
let [r, theta] = Utility.getPolarCoordinates(x, y)
|
|
r = Math.min(r, radius), [x, y] = Utility.getCartesianCoordinates(r, theta)
|
|
this.locationChangeCallback?.(x / radius, y / radius)
|
|
x = Math.round(x + radius)
|
|
y = Math.round(-y + radius)
|
|
return [x, y]
|
|
}
|
|
}
|