Skip to content

Commit 5095f2a

Browse files
feat: revision 0.0.16 (#8)
* bump 0.0.16 * fix: pixelated canvas * feat: use put instead print in example * feat: somes improves * feat: toggle antialiasing
1 parent 981b4b8 commit 5095f2a

File tree

5 files changed

+24
-12
lines changed

5 files changed

+24
-12
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"funding": "https://github.com/sponsors/RodrigoDornelles",
77
"bugs": "https://github.com/gamelly/gly-ide/issues",
88
"devDependencies": {
9-
"@gamely/core-native-html5": "^0.0.15",
10-
"@gamely/gly-engine-lite": "^0.0.15",
9+
"@gamely/core-native-html5": "^0.0.16",
10+
"@gamely/gly-engine-lite": "^0.0.16",
1111
"copy-webpack-plugin": "11.0.0",
1212
"css-loader": "6.7.3",
1313
"html-webpack-plugin": "5.5.0",

src/assets/index.css

-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ select option {
266266
}
267267

268268
#gameCanvas {
269-
height: 100%;
270269
width: 100%;
271270
}
272271
}

src/default.lua

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
std.draw.clear(std.color.blue)
22
std.draw.color(std.color.white)
3-
std.text.font_size(std.app.width/8)
4-
std.text.print(8 , 8, 'Hello world!')
3+
std.text.put(1, 1, 'Hello world!', 10)

src/index.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ <h1>tool-img-gen</h1>
3030
<div id="buttons">
3131
<form>
3232
<select id="resolution" name="resolution">
33-
<option value="48x48">32x32</option>
33+
<option value="32x32">32x32</option>
3434
<option value="48x48">48x48</option>
3535
<option value="80x80">80x80</option>
36-
<option value="128x128">128x48</option>
36+
<option value="128x48">128x48</option>
3737
<option value="128x128">128x128</option>
3838
<option value="256x256">256x256</option>
3939
<option value="512x512" selected>512x512</option>
@@ -71,6 +71,7 @@ <h1>tool-img-gen</h1>
7171
</g>
7272
</svg></label>
7373
<input type="number" id="height" name="height" value="512" required>
74+
<input type="checkbox" id="antialiasing" name="antialiasing" checked>
7475
<button id="download">download</button>
7576
</form>
7677
</div>

src/index.js

+18-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ document.addEventListener('DOMContentLoaded', async () => {
1212
const elInpHeight = document.querySelector('#height')
1313
const elSelFormat = document.querySelector('#resolution')
1414
const elBtnDownload = document.querySelector('#download')
15+
const elChkAntiAliasing = document.querySelector('#antialiasing')
1516
const elSelResolution = document.querySelector('#resolution')
1617
const elMonacoEditor = document.querySelector('#editor')
1718
const elCanvas = document.querySelector('#gameCanvas')
@@ -64,10 +65,18 @@ document.addEventListener('DOMContentLoaded', async () => {
6465
const apply = () => {
6566
const code = monacoEditor.getValue()
6667
gly.load(`return {init=function()end,loop=function()end,draw=function(std)\n${code}\nend}`)
67-
gly.resize(elInpWidth.value, elInpHeight.value)
6868
window.requestAnimationFrame(gly.update)
6969
}
7070

71+
const resizeAndApply = () => {
72+
gly.resize(elInpWidth.value, elInpHeight.value)
73+
apply()
74+
}
75+
76+
const toggleAntiAliasing = () => {
77+
elCanvas.style.imageRendering = elChkAntiAliasing.checked ? '': 'pixelated'
78+
}
79+
7180
monacoEditor.onDidChangeModelContent(() => {
7281
clearTimeout(monacoTimeout);
7382
monacoTimeout = setTimeout(() => {
@@ -79,7 +88,9 @@ document.addEventListener('DOMContentLoaded', async () => {
7988
const [width, height] = elSelResolution.value.split('x').map(Number);
8089
elInpWidth.value = width;
8190
elInpHeight.value = height;
82-
apply();
91+
elChkAntiAliasing.checked = width > 128;
92+
toggleAntiAliasing();
93+
resizeAndApply();
8394
})
8495

8596
elBtnDownload.addEventListener('click', (ev) => {
@@ -94,8 +105,10 @@ document.addEventListener('DOMContentLoaded', async () => {
94105
URL.revokeObjectURL(url)
95106
})
96107

97-
elInpWidth.addEventListener('change', apply);
98-
elInpHeight.addEventListener('change', apply);
108+
elChkAntiAliasing.addEventListener('change', toggleAntiAliasing);
109+
elInpWidth.addEventListener('change', resizeAndApply);
110+
elInpHeight.addEventListener('change', resizeAndApply);
99111

100-
apply();
112+
toggleAntiAliasing()
113+
resizeAndApply();
101114
})

0 commit comments

Comments
 (0)