Quick fix for zoom to cursor and brush erase blur
Quick fix to some issues pointed out by @raivshard at #177 Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
This commit is contained in:
parent
e92d8fa9b6
commit
fc8e6fb557
3 changed files with 17 additions and 14 deletions
|
@ -358,7 +358,7 @@
|
|||
<script src="js/lib/ui.js?v=fe9b702" type="text/javascript"></script>
|
||||
|
||||
<script
|
||||
src="js/initalize/layers.populate.js?v=8bc8815"
|
||||
src="js/initalize/layers.populate.js?v=066dc8e"
|
||||
type="text/javascript"></script>
|
||||
|
||||
<!-- Configuration -->
|
||||
|
@ -386,7 +386,7 @@
|
|||
src="js/ui/tool/maskbrush.js?v=d88810f"
|
||||
type="text/javascript"></script>
|
||||
<script
|
||||
src="js/ui/tool/colorbrush.js?v=3f8c01a"
|
||||
src="js/ui/tool/colorbrush.js?v=6f1d2f4"
|
||||
type="text/javascript"></script>
|
||||
<script
|
||||
src="js/ui/tool/select.js?v=f290e83"
|
||||
|
|
|
@ -307,28 +307,28 @@ mouse.listen.camera.onwheel.on((evn) => {
|
|||
evn.evn.preventDefault();
|
||||
|
||||
// Get cursor world position
|
||||
const cursorPosition = viewport.viewToCanvas(evn.x, evn.y);
|
||||
const wcursor = viewport.viewToCanvas(evn.x, evn.y);
|
||||
|
||||
// Get viewport center
|
||||
const pcx = viewport.cx;
|
||||
const pcy = viewport.cy;
|
||||
const wcx = viewport.cx;
|
||||
const wcy = viewport.cy;
|
||||
|
||||
// Apply zoom
|
||||
viewport.zoom *= 1 + evn.delta * 0.0002;
|
||||
|
||||
// Get cursor new world position
|
||||
const nwcursor = viewport.viewToCanvas(evn.x, evn.y);
|
||||
|
||||
// Apply normal zoom (center of viewport)
|
||||
viewport.cx = pcx;
|
||||
viewport.cy = pcy;
|
||||
viewport.cx = wcx;
|
||||
viewport.cy = wcy;
|
||||
|
||||
// Move viewport to keep cursor in same location
|
||||
viewport.cx += wcursor.x - nwcursor.x;
|
||||
viewport.cy += wcursor.y - nwcursor.y;
|
||||
|
||||
viewport.transform(imageCollection.element);
|
||||
|
||||
// Calculate new viewport center and move
|
||||
//const newCursorPosition = viewport.viewToCanvas(evn.x, evn.y);
|
||||
//viewport.cx = pcx - (newCursorPosition.x - cursorPosition.x);
|
||||
//viewport.cy = pcy - (newCursorPosition.y - cursorPosition.y);
|
||||
|
||||
//viewport.transform(imageCollection.element);
|
||||
|
||||
toolbar._current_tool.redrawui && toolbar._current_tool.redrawui();
|
||||
});
|
||||
|
||||
|
|
|
@ -22,8 +22,10 @@ const _color_brush_draw_callback = (evn, state) => {
|
|||
};
|
||||
|
||||
const _color_brush_erase_callback = (evn, state, ctx) => {
|
||||
ctx.save();
|
||||
ctx.strokeStyle = "black";
|
||||
|
||||
ctx.filter = "blur(" + state.brushBlur + "px)";
|
||||
ctx.lineWidth = state.brushSize;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(
|
||||
|
@ -33,6 +35,7 @@ const _color_brush_erase_callback = (evn, state, ctx) => {
|
|||
ctx.lineTo(evn.x, evn.y);
|
||||
ctx.lineJoin = ctx.lineCap = "round";
|
||||
ctx.stroke();
|
||||
ctx.restore();
|
||||
};
|
||||
|
||||
const colorBrushTool = () =>
|
||||
|
|
Loading…
Reference in a new issue