You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have implemented the eraser button, but getting issue while doing undo after erase. If I am erasing only one time on that time undo is working fine if I am erasing more than once then the last erased stroke works fine with undo but other are working as a line stroke.
` var x = "#CB7342",
y = 2;
var bErasing = false;
var canvas, canvasWidth, canvasHeight;
var ctx;
var lastPt=null;
var pathsry = [];
var points = [];
var state;
var colour;
// past states
function ySize(size) {
y = size;
sketchpad.penSize = y;
}
var sketchpad;
function undo(){
bErasing = false;
sketchpad.undo();
}
function init() {
canvas = document.getElementById('sheet');
ctx = canvas.getContext('2d');
var canvasOffset = $('#sheet').offset();
var parent = canvas.parentNode;
canvas.width = parent.clientWidth;
canvas.height = parent.clientHeight;
// alert(bErasing)
sketchpad = new Sketchpad({
element: '#sheet',
width: canvas.width,
height: canvas.height,
color: null,
penSize: 2,
globalAlpha: 0.1
});
}
// function erase(){
// sketchpad.erase();
// }
$(document).on('click', "#erase", function () {
bErasing = true;
});
`
Please help me on this I am trying from last 3 days, but did not get resolution
Thanks
The text was updated successfully, but these errors were encountered:
I have implemented the eraser button, but getting issue while doing undo after erase. If I am erasing only one time on that time undo is working fine if I am erasing more than once then the last erased stroke works fine with undo but other are working as a line stroke.
Please see the below code
`Sketchpad.prototype._stroke = function(start, end, color, size) {
this.context.save();
if(bErasing){
this.context.globalCompositeOperation = "destination-out";
}else{
this.context.globalCompositeOperation = "source-over";
}
// if(size === 7 || size === 13){
// console.log(size)
// this.context.lineJoin = 'square';
// this.context.lineCap = 'square';
// }
// else{
this.context.lineJoin = 'round';
this.context.lineCap = 'round';
// }
this.context.strokeStyle = color;
this.context.lineWidth = size;
// switch(size){
};
`
and function call is here:-
` var x = "#CB7342",
y = 2;
var bErasing = false;
var canvas, canvasWidth, canvasHeight;
var ctx;
var lastPt=null;
var pathsry = [];
var points = [];
var state;
var colour;
// past states
function ySize(size) {
`
Please help me on this I am trying from last 3 days, but did not get resolution
Thanks
The text was updated successfully, but these errors were encountered: