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]]
|
||||
name = "fantastic-rs"
|
||||
version = "0.5.0-alpha3"
|
||||
version = "0.5.1-alpha1"
|
||||
dependencies = [
|
||||
"log",
|
||||
"nrpc",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "fantastic-rs"
|
||||
version = "0.5.0-alpha3"
|
||||
version = "0.5.1-alpha1"
|
||||
edition = "2021"
|
||||
authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
|
||||
description = "Backend (superuser) functionality for Fantastic"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"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",
|
||||
"scripts": {
|
||||
"build": "shx rm -rf dist && rollup -c",
|
||||
|
|
|
@ -76,13 +76,14 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({serverAPI}) => {
|
|||
}
|
||||
|
||||
function onClickCanvas(e: any) {
|
||||
//console.log("canvas click", e);
|
||||
//console.log("[FANTASTIC] canvas click", e);
|
||||
const realEvent: any = e.nativeEvent;
|
||||
//console.log("Canvas click @ (" + realEvent.layerX.toString() + ", " + realEvent.layerY.toString() + ")");
|
||||
const target: any = e.currentTarget;
|
||||
//console.log("Target dimensions " + target.width.toString() + "x" + target.height.toString());
|
||||
const clickX = realEvent.layerX;
|
||||
const clickY = realEvent.layerY;
|
||||
//console.log("[FANTASTIC] Target dimensions " + target.width.toString() + "x" + target.height.toString());
|
||||
var clickX = realEvent.offsetX;
|
||||
var clickY = realEvent.offsetY;
|
||||
//console.debug("[FANTASTIC] curve click:", clickX, clickY);
|
||||
for (let i = 0; i < curveGlobal.length; i++) {
|
||||
const curvePoint = curveGlobal[i];
|
||||
const pointX = curvePoint.x * target.width;
|
||||
|
@ -99,7 +100,8 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({serverAPI}) => {
|
|||
}
|
||||
}
|
||||
//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 {
|
||||
|
|
Loading…
Reference in a new issue