Files
ueblueprint/js/template/ColorHandlerTemplate.js
barsdeveloper 7469d55518 Replace parsing and test libraries
* WIP

* WIP

* wip

* WIP

* Several fixes

* Tests wip port to playwright

* WIP

* Fix more tests

* Serialization tests fixed

* Several fixes for tests

* Input options types

* Type adjustments

* Fix object reference parser

* Tests fixes

* More tests fixes
2024-02-14 00:40:42 +01:00

24 lines
818 B
JavaScript
Executable File

import IDraggableControlTemplate from "./IDraggableControlTemplate.js"
import Utility from "../Utility.js"
/** @extends {IDraggableControlTemplate<ColorHandlerElement>} */
export default class ColorHandlerTemplate extends IDraggableControlTemplate {
/**
* @param {Number} x
* @param {Number} y
* @returns {Coordinates}
*/
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]
}
}