Skip to content

Commit

Permalink
* ADD: Fonts sub-panel for Video Tab
Browse files Browse the repository at this point in the history
  • Loading branch information
zoul0813 authored and Zeal8bit committed Nov 30, 2024
1 parent fb9f936 commit 4b528bf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
8 changes: 8 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ <h4>Ready?</h4>
<input type="checkbox" id="video-palette" class="toggle" name="palette" checked />
Show Palette
</label>
<label>
<input type="checkbox" id="video-palette" class="toggle" name="fonts" />
Show Fonts
</label>
<label>
<input type="checkbox" id="video-tileset" class="toggle" name="tileset" checked />
Show Tileset
Expand All @@ -373,6 +377,10 @@ <h4>Ready?</h4>
<summary>Palette</summary>
<div class="palette"></div>
</details>
<details class="sub-panel" name="fonts">
<summary>Fonts</summary>
<div class="fonts"></div>
</details>
<details class="sub-panel" name="tileset" open>
<summary>Tileset</summary>
<div class="tileset"></div>
Expand Down
18 changes: 14 additions & 4 deletions view/css/emulator.css
Original file line number Diff line number Diff line change
Expand Up @@ -575,18 +575,28 @@ hr {
}
}

.fonts,
.tileset {
--gap: 1ch;
--column: 64px;
display: grid;
gap: .5em;
grid-template-columns: repeat(auto-fit, 64px);
gap: var(--gap);
grid-template-columns: repeat(auto-fit, var(--column));
> canvas {
width: 64px;
height: 64px;
width: var(--column);
aspect-ratio: 1;
cursor: help;
image-rendering: pixelated;
}
}

.fonts {
--column: 32px;
> canvas {
aspect-ratio: 8 / 12;
}
}

.layers {
> canvas {
max-width: 100%;
Expand Down
15 changes: 14 additions & 1 deletion view/tabs/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
if(!_panels) {
panels = {
"palette": { "open": true, "visible": true },
"fonts": { "open": true, "visible": false },
"tileset": { "open": true, "visible": true },
"tilemap": { "open": false, "visible": false }
}
Expand All @@ -22,7 +23,7 @@
});

$('#video-dump').on('click', () => {
const { tileset, palette, layer0, layer1, sprites } = zealcom.vchip.dump();
const { tileset, palette, layer0, layer1, sprites, font } = zealcom.vchip.dump();

const $palette = $('#video .palette').empty();
const palette888 = palette.getPalette();
Expand All @@ -34,6 +35,18 @@
`);
});

const $font = $('#video .fonts').empty();
for(let i = 0; i < 256; i++) {
const img = font.getCharacterImg(i, [0,0,0], [255,255,255]);
const canvas = document.createElement('canvas');
$(canvas).attr('title', `Char ${i}`).css('background-color', `#${background}`);
canvas.width = 8;
canvas.height = 12;
var ctx = canvas.getContext('2d');
ctx.putImageData(img, 0, 0);
$font.append(canvas);
}

const $tileset = $('#video .tileset').empty();
const mode8bit = tileset.getColorMode8Bit();
const tile_count = mode8bit ? 256 : 512;
Expand Down

0 comments on commit 4b528bf

Please sign in to comment.