Fix canvas clicking for #20
This commit is contained in:
parent
8c9a7b7c68
commit
b637f4f5f9
4 changed files with 10 additions and 8 deletions
2
backend-rs/Cargo.lock
generated
2
backend-rs/Cargo.lock
generated
|
@ -247,7 +247,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fantastic-rs"
|
name = "fantastic-rs"
|
||||||
version = "0.5.0-alpha3"
|
version = "0.5.1-alpha1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"nrpc",
|
"nrpc",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "fantastic-rs"
|
name = "fantastic-rs"
|
||||||
version = "0.5.0-alpha3"
|
version = "0.5.1-alpha1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
|
authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
|
||||||
description = "Backend (superuser) functionality for Fantastic"
|
description = "Backend (superuser) functionality for Fantastic"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "Fantastic",
|
"name": "Fantastic",
|
||||||
"version": "0.5.0-alpha3",
|
"version": "0.5.1-alpha1",
|
||||||
"description": "A template to quickly create decky plugins from scratch, based on TypeScript and webpack",
|
"description": "A template to quickly create decky plugins from scratch, based on TypeScript and webpack",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "shx rm -rf dist && rollup -c",
|
"build": "shx rm -rf dist && rollup -c",
|
||||||
|
|
|
@ -76,13 +76,14 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({serverAPI}) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClickCanvas(e: any) {
|
function onClickCanvas(e: any) {
|
||||||
//console.log("canvas click", e);
|
//console.log("[FANTASTIC] canvas click", e);
|
||||||
const realEvent: any = e.nativeEvent;
|
const realEvent: any = e.nativeEvent;
|
||||||
//console.log("Canvas click @ (" + realEvent.layerX.toString() + ", " + realEvent.layerY.toString() + ")");
|
//console.log("Canvas click @ (" + realEvent.layerX.toString() + ", " + realEvent.layerY.toString() + ")");
|
||||||
const target: any = e.currentTarget;
|
const target: any = e.currentTarget;
|
||||||
//console.log("Target dimensions " + target.width.toString() + "x" + target.height.toString());
|
//console.log("[FANTASTIC] Target dimensions " + target.width.toString() + "x" + target.height.toString());
|
||||||
const clickX = realEvent.layerX;
|
var clickX = realEvent.offsetX;
|
||||||
const clickY = realEvent.layerY;
|
var clickY = realEvent.offsetY;
|
||||||
|
//console.debug("[FANTASTIC] curve click:", clickX, clickY);
|
||||||
for (let i = 0; i < curveGlobal.length; i++) {
|
for (let i = 0; i < curveGlobal.length; i++) {
|
||||||
const curvePoint = curveGlobal[i];
|
const curvePoint = curveGlobal[i];
|
||||||
const pointX = curvePoint.x * target.width;
|
const pointX = curvePoint.x * target.width;
|
||||||
|
@ -99,7 +100,8 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({serverAPI}) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//console.log("Adding new point");
|
//console.log("Adding new point");
|
||||||
backend.resolve(backend.addCurvePoint({x: clickX / target.width, y: 1 - (clickY / target.height)}), setCurve);
|
const curvePoint = {x: clickX / target.width, y: 1 - (clickY / target.height)};
|
||||||
|
backend.resolve(backend.addCurvePoint(curvePoint), setCurve);
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawCanvas(ctx: any, frameCount: number): void {
|
function drawCanvas(ctx: any, frameCount: number): void {
|
||||||
|
|
Loading…
Reference in a new issue