mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Fixed FilmPreview bugs. Simplified piskel.js, removed refernce to drawingController from tools
This commit is contained in:
@ -18,27 +18,27 @@
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
ns.SimplePen.prototype.applyToolAt = function(col, row, color, drawer) {
|
||||
if (drawer.frame.containsPixel(col, row)) {
|
||||
ns.SimplePen.prototype.applyToolAt = function(col, row, color, frame, overlay) {
|
||||
if (frame.containsPixel(col, row)) {
|
||||
this.previousCol = col;
|
||||
this.previousRow = row;
|
||||
drawer.frame.setPixel(col, row, color);
|
||||
frame.setPixel(col, row, color);
|
||||
}
|
||||
};
|
||||
|
||||
ns.SimplePen.prototype.moveToolAt = function(col, row, color, drawer) {
|
||||
|
||||
ns.SimplePen.prototype.moveToolAt = function(col, row, color, frame, overlay) {
|
||||
if((Math.abs(col - this.previousCol) > 1) || (Math.abs(row - this.previousRow) > 1)) {
|
||||
// The pen movement is too fast for the mousemove frequency, there is a gap between the
|
||||
// current point and the previously drawn one.
|
||||
// We fill the gap by calculating missing dots (simple linear interpolation) and draw them.
|
||||
var interpolatedPixels = this.getLinePixels_(col, this.previousCol, row, this.previousRow);
|
||||
for(var i=0, l=interpolatedPixels.length; i<l; i++) {
|
||||
this.applyToolAt(interpolatedPixels[i].col, interpolatedPixels[i].row, color, drawer);
|
||||
var coords = interpolatedPixels[i];
|
||||
this.applyToolAt(coords.col, coords.row, color, frame, overlay);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.applyToolAt(col, row, color, drawer);
|
||||
this.applyToolAt(col, row, color, frame, overlay);
|
||||
}
|
||||
|
||||
this.previousCol = col;
|
||||
|
Reference in New Issue
Block a user