mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Merge branch 'master' into gh-pages
This commit is contained in:
commit
b433dea1cf
@ -1,6 +1,8 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var ns = $.namespace("pskl.model");
|
var ns = $.namespace("pskl.model");
|
||||||
ns.FrameSheet = function () {
|
ns.FrameSheet = function (width, height) {
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
this.frames = [];
|
this.frames = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -9,7 +11,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ns.FrameSheet.prototype.addEmptyFrame = function () {
|
ns.FrameSheet.prototype.addEmptyFrame = function () {
|
||||||
this.addFrame(ns.Frame.createEmpty(width, height));
|
this.addFrame(ns.Frame.createEmpty(this.width, this.height));
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.FrameSheet.prototype.addFrame = function (frame) {
|
ns.FrameSheet.prototype.addFrame = function (frame) {
|
||||||
|
21
js/piskel.js
21
js/piskel.js
@ -50,13 +50,11 @@ $.namespace("pskl");
|
|||||||
var piskel = {
|
var piskel = {
|
||||||
|
|
||||||
init : function () {
|
init : function () {
|
||||||
var emptyFrame = pskl.model.Frame.createEmpty(framePixelWidth, framePixelHeight);
|
frameSheet = new pskl.model.FrameSheet(framePixelWidth, framePixelHeight);
|
||||||
|
frameSheet.addEmptyFrame();
|
||||||
frameSheet = new pskl.model.FrameSheet();
|
|
||||||
frameSheet.addFrame(emptyFrame);
|
|
||||||
|
|
||||||
this.drawingController = new pskl.controller.DrawingController(
|
this.drawingController = new pskl.controller.DrawingController(
|
||||||
emptyFrame,
|
frameSheet.getFrameByIndex(0),
|
||||||
$('#drawing-canvas-container')[0],
|
$('#drawing-canvas-container')[0],
|
||||||
drawingCanvasDpi
|
drawingCanvasDpi
|
||||||
);
|
);
|
||||||
@ -193,6 +191,7 @@ $.namespace("pskl");
|
|||||||
},
|
},
|
||||||
|
|
||||||
onMousedown : function (event) {
|
onMousedown : function (event) {
|
||||||
|
console.log("onMousedown");
|
||||||
isClicked = true;
|
isClicked = true;
|
||||||
|
|
||||||
if(event.button == 2) { // right click
|
if(event.button == 2) { // right click
|
||||||
@ -211,6 +210,7 @@ $.namespace("pskl");
|
|||||||
},
|
},
|
||||||
|
|
||||||
onMousemove : function (event) {
|
onMousemove : function (event) {
|
||||||
|
console.log("onMousemove");
|
||||||
var currentTime = new Date().getTime();
|
var currentTime = new Date().getTime();
|
||||||
// Throttling of the mousemove event:
|
// Throttling of the mousemove event:
|
||||||
if ((currentTime - previousMousemoveTime) > 40 ) {
|
if ((currentTime - previousMousemoveTime) > 40 ) {
|
||||||
@ -233,15 +233,12 @@ $.namespace("pskl");
|
|||||||
},
|
},
|
||||||
|
|
||||||
onMouseup : function (event) {
|
onMouseup : function (event) {
|
||||||
|
console.log("onMouseup");
|
||||||
if(isClicked || isRightClicked) {
|
if(isClicked || isRightClicked) {
|
||||||
// A mouse button was clicked on the drawing canvas before this mouseup event,
|
// A mouse button was clicked on the drawing canvas before this mouseup event,
|
||||||
// the user was probably drawing on the canvas.
|
// the user was probably drawing on the canvas.
|
||||||
// Note: The mousemove movement (and the mouseup) may end up outside
|
// Note: The mousemove movement (and the mouseup) may end up outside
|
||||||
// of the drawing canvas.
|
// of the drawing canvas.
|
||||||
// TODO: Remove that when we have the centralized redraw loop
|
|
||||||
this.previewsController.createPreviews();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isRightClicked) {
|
if(isRightClicked) {
|
||||||
$.publish(Events.CANVAS_RIGHT_CLICK_RELEASED);
|
$.publish(Events.CANVAS_RIGHT_CLICK_RELEASED);
|
||||||
}
|
}
|
||||||
@ -254,6 +251,12 @@ $.namespace("pskl");
|
|||||||
penColor,
|
penColor,
|
||||||
this.drawingController
|
this.drawingController
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// TODO: Remove that when we have the centralized redraw loop
|
||||||
|
this.previewsController.createPreviews();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onCanvasContextMenu : function (event) {
|
onCanvasContextMenu : function (event) {
|
||||||
|
Loading…
Reference in New Issue
Block a user