jrlazz
March 18, 2023, 6:36am
1
Painting with fat lines
Hi Three.js followers,
I would like Someone suggests a right way to convert mouse position !!!
This workaround (with iframe) is not a good project.
I would like to get correct mouse position calculation and have resize option !!!
the new link:
https://jrlazz.eu5.org/anim/paintfatA1.html
the old link:
https://jrlazz.eu5.org/anim/paintfatA.html
Again, Thanks for the great Three.js Team!
Jose Roberto Lazzareschi
4 Likes
In Suica I get the position like this:
findPosition( domEvent )
{
var canvas = domEvent.target;
// get pixel position withing the Suica canvas
var rect = canvas.getBoundingClientRect(),
pixelX = Math.floor( domEvent.clientX - rect.left ),
pixelY = Math.floor( domEvent.clientY - rect.top );
// get relative pixel position (ie. [-1,+1])
this.raycastPointer.x = 2*pixelX/canvas.clientWidth - 1;
this.raycastPointer.y = -2*pixelY/canvas.clientHeight + 1;
return [pixelX-canvas.clientWidth/2, -pixelY+canvas.clientHeight/2, 0];
}
Off-topics:
The color selection can be made with <input type="color">
as shown here
Negative width produces interesting result (no lines, just dots):
1 Like
jrlazz
March 18, 2023, 3:24pm
3
Hi Pavel,
Thank You very much for the attention.
I will try it and see it working.
jrlazz
March 19, 2023, 3:24am
4
This is new version, with a better mouse position calculation!
And the color choose way as You suggested!
http://jrlazz.eu5.org/anim/paintfatA1.html
1 Like