mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Rework pixel storage, manipulation, rendering
This commit is contained in:
committed by
Julian Descottes
parent
06abdca62e
commit
f5c98cf0b3
@@ -18,9 +18,9 @@ describe("Canvas Renderer test", function() {
|
||||
|
||||
var frameFromCanvas = pskl.utils.FrameUtils.createFromImage(canvas);
|
||||
|
||||
expect(frameFromCanvas.getPixel(0,0)).toBe(BLACK);
|
||||
expect(frameFromCanvas.getPixel(0,1)).toBe(WHITE);
|
||||
expect(frameFromCanvas.getPixel(1,0)).toBe(WHITE);
|
||||
expect(frameFromCanvas.getPixel(1,1)).toBe(BLACK);
|
||||
test.testutils.colorEqualsColor(frameFromCanvas.getPixel(0,0), BLACK);
|
||||
test.testutils.colorEqualsColor(frameFromCanvas.getPixel(0,1), WHITE);
|
||||
test.testutils.colorEqualsColor(frameFromCanvas.getPixel(1,0), WHITE);
|
||||
test.testutils.colorEqualsColor(frameFromCanvas.getPixel(1,1), BLACK);
|
||||
});
|
||||
});
|
||||
@@ -198,7 +198,7 @@ describe("SelectionManager suite", function() {
|
||||
|
||||
var checkContainsPixel = function (pixels, row, col, color) {
|
||||
var containsPixel = pixels.some(function (pixel) {
|
||||
return pixel.row == row && pixel.col == col && pixel.color == color;
|
||||
return pixel.row == row && pixel.col == col && test.testutils.compareColor(pixel.color, color);
|
||||
});
|
||||
expect(containsPixel).toBe(true);
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
ns.frameEqualsGrid = function (frame, grid) {
|
||||
frame.forEachPixel(function (color, col, row) {
|
||||
expect(color).toBe(grid[row][col]);
|
||||
ns.colorEqualsColor(color, grid[row][col]);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -47,10 +47,18 @@
|
||||
for (var y = 0 ; y < grid[x].length ; y++) {
|
||||
var expected = tinycolor(grid[x][y]).toRgbString();
|
||||
var color = tinycolor(ns.getRgbaAt(image, x, y)).toRgbString();
|
||||
expect(color).toBe(expected);
|
||||
ns.colorEqualsColor(color, expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ns.compareColor = function(colorA, colorB) {
|
||||
return pskl.utils.colorToInt(colorA) === pskl.utils.colorToInt(colorB);
|
||||
};
|
||||
|
||||
ns.colorEqualsColor = function (color, expected) {
|
||||
expect(pskl.utils.colorToInt(color)).toBe(pskl.utils.colorToInt(expected));
|
||||
};
|
||||
|
||||
ns.getRgbaAt = function (image, x, y) {
|
||||
var w = image.width;
|
||||
|
||||
Reference in New Issue
Block a user