"fix" output canvas and data export
still not sure why pixels are inverse at some point also tidied up a few things report palette switch bug
This commit is contained in:
parent
44ee5b874e
commit
648143b7a0
|
@ -62,7 +62,7 @@ $(document).ready(function() {
|
|||
}
|
||||
|
||||
function hexToColour(hex) {
|
||||
var rgb = hex.match(/[\da-fA-F]{2}/g);
|
||||
var rgb = hex.match(/[\da-f]{2}/gi);
|
||||
|
||||
return {
|
||||
red: parseInt(rgb[0], 16),
|
||||
|
@ -121,6 +121,7 @@ $(document).ready(function() {
|
|||
});
|
||||
|
||||
// get tiles
|
||||
|
||||
bitsyData.tiles = {};
|
||||
|
||||
// tile 0 (background colour only) is implicit in bitsy rather than being stored in the game data
|
||||
|
@ -130,22 +131,21 @@ $(document).ready(function() {
|
|||
bitmap: _.chunk(_.split(_.repeat(0, 64), ''), 8)
|
||||
};
|
||||
|
||||
// todo: handle animated tiles properly instead of discarding the second animation frame
|
||||
var tiles = input.match(/TIL (.*)\n([01]{8}\n){8}/g);
|
||||
|
||||
if (tiles.length > 0) {
|
||||
for (var i = 0; i < tiles.length; i++) {
|
||||
var name = tiles[i].match(/TIL .*/)[0].replace('TIL ', '');
|
||||
_.each(tiles, function(tile, i) {
|
||||
var name = tile.match(/TIL .*/)[0].replace('TIL ', '');
|
||||
|
||||
tiles[i] = tiles[i].replace(/TIL .*\n/, '');
|
||||
tile = tile.replace(/TIL .*\n/, '');
|
||||
|
||||
var bitmap = tiles[i].match(/[01]/g);
|
||||
var bitmap = tile.match(/[01]/g);
|
||||
|
||||
bitsyData.tiles[name] = {
|
||||
name: name,
|
||||
bitmap: _.chunk(bitmap, 8)
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// set palette to first imported palette and redraw
|
||||
palette = _.first(_.sortBy(bitsyData.palettes, 'id'));
|
||||
|
@ -197,7 +197,7 @@ $(document).ready(function() {
|
|||
var rawData = imageData.data;
|
||||
var monochrome = [];
|
||||
|
||||
brightnessAdjustment = parseFloat($('#brightness').val());
|
||||
var brightnessAdjustment = parseFloat($('#brightness').val());
|
||||
|
||||
// for each pixel
|
||||
for (var i = 0; i < rawData.length; i += 4) {
|
||||
|
@ -210,10 +210,10 @@ $(document).ready(function() {
|
|||
|
||||
var targetColour = getClosestColour(pixel, palette);
|
||||
|
||||
if (targetColour.name === "background") {
|
||||
monochrome.push(0);
|
||||
if (targetColour.name === "background") { // ?! why is this reversed?
|
||||
monochrome.push(1);
|
||||
} else { // tile
|
||||
monochrome.push(1)
|
||||
monochrome.push(0)
|
||||
}
|
||||
|
||||
rawData[i ] = targetColour.red;
|
||||
|
@ -280,10 +280,10 @@ $(document).ready(function() {
|
|||
|
||||
position *= 4; // 4 values (rgba) per pixel
|
||||
|
||||
if (parseInt(pixel) === 1) { // ?! wtf
|
||||
pixelColour = palette.background;
|
||||
if (parseInt(pixel) === 0) {
|
||||
var pixelColour = palette.background;
|
||||
} else {
|
||||
pixelColour = palette.tile;
|
||||
var pixelColour = palette.tile;
|
||||
}
|
||||
|
||||
rawData[position ] = pixelColour.red;
|
||||
|
|
Loading…
Reference in New Issue