Skip to content

Commit

Permalink
Merge branch 'main' into task/xsebek/lodestone-watch
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Sep 15, 2024
2 parents ba8dae3 + 746be8f commit 413ef06
Show file tree
Hide file tree
Showing 4 changed files with 44,124 additions and 11 deletions.
8 changes: 4 additions & 4 deletions web/play.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
<html>
<head>
<title>Web frontend</title>
<script src="https://pixijs.download/release/pixi.js"></script>
<script src="script/pixi.js"></script>

<script src="script/display.js"></script>
<script src="script/fetch.js"></script>

<script>
<script type="module">

function startLoop() {
async function startLoop() {
const button = document.getElementById('restart-button');
button.style.display = 'none';

let displayWidth = 600;
let displayHeight = 300;
let out = setupGraphics(button, displayWidth, displayHeight);
let out = await setupGraphics(button, displayWidth, displayHeight);
let appView = out[0];
let graphics = out[1];
doFetch(button, appView, graphics, displayWidth, displayHeight);
Expand Down
9 changes: 5 additions & 4 deletions web/script/display.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
function setupGraphics(button, displayWidth, displayHeight) {
async function setupGraphics(button, displayWidth, displayHeight) {

const app = new PIXI.Application();
// Create the application helper and add its render target to the page
let app = new PIXI.Application({
await app.init({
width: displayWidth,
height: displayHeight,
backgroundColor: 0xFFFFFF
});

document.body.insertBefore(app.view, button);
document.body.insertBefore(app.canvas, button);

const graphics = new PIXI.Graphics();
app.stage.addChild(graphics);
return [app.view, graphics];
return [app.canvas, graphics];
}
5 changes: 2 additions & 3 deletions web/script/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ function drawGraphics(graphics, colorMap, grid) {
let colorIdx = row[colIdx];
let color = colorMap[colorIdx];

graphics.beginFill(color);
let xPos = colIdx * cellSize;
let yPos = rowIdx * cellSize;
graphics.drawRect(xPos, yPos, xPos + cellSize, yPos + cellSize);
graphics.endFill();
graphics.rect(xPos, yPos, xPos + cellSize, yPos + cellSize);
graphics.fill(color);
}
}
}
Expand Down
Loading

0 comments on commit 413ef06

Please sign in to comment.