mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
temp commit
This commit is contained in:
parent
6ea7f74d00
commit
3664d87751
@ -19,7 +19,34 @@ var FrameSheetModel = (function() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getUsedColors : function () {
|
getUsedColors : function () {
|
||||||
return ["#000", "#fff"]
|
var colors = [];
|
||||||
|
var pixels = this.getAllPixels();
|
||||||
|
for (var i = 0 ; i < pixels.length ; i++) {
|
||||||
|
var pixel = pixels[i];
|
||||||
|
if (pixel && colors.indexOf(pixel)) {
|
||||||
|
colors.push(pixel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return colors;
|
||||||
|
},
|
||||||
|
|
||||||
|
getAllPixels : function () {
|
||||||
|
var pixels = [];
|
||||||
|
for (var i = 0 ; i < frames.length ; i++) {
|
||||||
|
pixels = pixels.concat(this.getFramePixels(frames[i]));
|
||||||
|
}
|
||||||
|
return pixels;
|
||||||
|
},
|
||||||
|
|
||||||
|
getFramePixels : function (frame) {
|
||||||
|
var pixels = [];
|
||||||
|
for (var i = 0 ; i < frame.length ; i++) {
|
||||||
|
var line = frame[i];
|
||||||
|
for (var j = 0 ; j < line.length ; j++) {
|
||||||
|
pixels.push(line[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pixels;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Could be used to pass around model using long GET param (good enough for simple models) and
|
// Could be used to pass around model using long GET param (good enough for simple models) and
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
onPickerChange : function(evt) {
|
onPickerChange : function(evt) {
|
||||||
penColor = colorPicker.value;
|
penColor = "#" + this.colorPicker.value;
|
||||||
},
|
},
|
||||||
|
|
||||||
initPalette : function (color) {
|
initPalette : function (color) {
|
||||||
@ -88,6 +88,7 @@
|
|||||||
var color = colors[i];
|
var color = colors[i];
|
||||||
var colorEl = document.createElement("li");
|
var colorEl = document.createElement("li");
|
||||||
colorEl.setAttribute("data-color", color);
|
colorEl.setAttribute("data-color", color);
|
||||||
|
colorEl.innerHTML = color;
|
||||||
paletteEl.appendChild(colorEl);
|
paletteEl.appendChild(colorEl);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user