Skip to content

Commit b5cc786

Browse files
committed
update engine and deps
1 parent 470c0e0 commit b5cc786

File tree

6 files changed

+243
-166
lines changed

6 files changed

+243
-166
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@litecanvas/plugin-migrate": "latest",
2929
"@litecanvas/utils": "latest",
3030
"codemirror": "^6.0.2",
31-
"eslint-linter-browserify": "9.29.0",
31+
"eslint-linter-browserify": "9.30.0",
3232
"litecanvas": "latest",
3333
"pako": "^2.1.0"
3434
}

public/about.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,12 @@ <h2><a id="drawing">Functions for Drawing</a></h2>
420420
// draw a outline circle
421421
circ(x, y, r, color = 0): void
422422

423+
// draw a color-filled ellipse
424+
ovalfill(x, y, rx, ry, color = 0): void
425+
426+
// draw a outline ellipse
427+
oval(x, y, rx, ry, color = 0): void
428+
423429
// draw a line from one point (x1, y1) to another (x2, y2)
424430
line(x1, y1, x2, y2, color = 0): void
425431

public/app.js

Lines changed: 159 additions & 159 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/litecanvas.js

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198
DEV: assert(isNumber(value), "norm: 1st param must be a number");
199199
DEV: assert(isNumber(start), "norm: 2nd param must be a number");
200200
DEV: assert(isNumber(stop), "norm: 3rd param must be a number");
201+
DEV: assert(start !== stop, "norm: the 2nd param must be different than the 3rd param");
201202
return instance.map(value, start, stop, 0, 1);
202203
},
203204
/**
@@ -398,6 +399,62 @@
398399
_ctx.arc(~~x, ~~y, ~~radius, 0, TWO_PI);
399400
instance.fill(color);
400401
},
402+
/**
403+
* Draw a ellipse outline
404+
*
405+
* @param {number} x
406+
* @param {number} y
407+
* @param {number} radiusX
408+
* @param {number} radiusY
409+
* @param {number} [color=0] the color index
410+
*/
411+
oval(x, y, radiusX, radiusY, color) {
412+
DEV: assert(isNumber(x), "oval: 1st param must be a number");
413+
DEV: assert(isNumber(y), "oval: 2nd param must be a number");
414+
DEV: assert(
415+
isNumber(radiusX) && radiusX >= 0,
416+
"oval: 3rd param must be a positive number or zero"
417+
);
418+
DEV: assert(
419+
isNumber(radiusY) && radiusY >= 0,
420+
"oval: 4th param must be a positive number or zero"
421+
);
422+
DEV: assert(
423+
null == color || isNumber(color) && color >= 0,
424+
"oval: 5th param must be a positive number or zero"
425+
);
426+
_ctx.beginPath();
427+
_ctx.ellipse(~~x, ~~y, ~~radiusX, ~~radiusY, 0, 0, TWO_PI);
428+
instance.stroke(color);
429+
},
430+
/**
431+
* Draw a color-filled ellipse
432+
*
433+
* @param {number} x
434+
* @param {number} y
435+
* @param {number} radiusX
436+
* @param {number} radiusY
437+
* @param {number} [color=0] the color index
438+
*/
439+
ovalfill(x, y, radiusX, radiusY, color) {
440+
DEV: assert(isNumber(x), "ovalfill: 1st param must be a number");
441+
DEV: assert(isNumber(y), "ovalfill: 2nd param must be a number");
442+
DEV: assert(
443+
isNumber(radiusX) && radiusX >= 0,
444+
"ovalfill: 3rd param must be a positive number or zero"
445+
);
446+
DEV: assert(
447+
isNumber(radiusY) && radiusY >= 0,
448+
"ovalfill: 4th param must be a positive number or zero"
449+
);
450+
DEV: assert(
451+
null == color || isNumber(color) && color >= 0,
452+
"ovalfill: 5th param must be a positive number or zero"
453+
);
454+
_ctx.beginPath();
455+
_ctx.ellipse(~~x, ~~y, ~~radiusX, ~~radiusY, 0, 0, TWO_PI);
456+
instance.fill(color);
457+
},
401458
/**
402459
* Draw a line
403460
*
@@ -1219,17 +1276,19 @@
12191276
`Litecanvas' option "width" is required when the option "height" is defined`
12201277
);
12211278
const width = settings.width || root.innerWidth, height = settings.height || settings.width || root.innerHeight;
1222-
instance.def("W", _canvas.width = width);
1223-
instance.def("H", _canvas.height = height);
1279+
instance.def("W", width);
1280+
instance.def("H", height);
1281+
_canvas.width = width;
1282+
_canvas.height = height;
12241283
if (settings.autoscale) {
12251284
if (!_canvas.style.display) {
12261285
_canvas.style.display = "block";
12271286
_canvas.style.margin = "auto";
12281287
}
1229-
_scale = math.min(root.innerWidth / instance.W, root.innerHeight / instance.H);
1288+
_scale = math.min(root.innerWidth / width, root.innerHeight / height);
12301289
_scale = (settings.pixelart ? ~~_scale : _scale) || 1;
1231-
_canvas.style.width = instance.W * _scale + "px";
1232-
_canvas.style.height = instance.H * _scale + "px";
1290+
_canvas.style.width = width * _scale + "px";
1291+
_canvas.style.height = height * _scale + "px";
12331292
}
12341293
if (!settings.antialias || settings.pixelart) {
12351294
_ctx.imageSmoothingEnabled = false;

public/sw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const cacheName = "luizbills.litecanvas-editor-v1";
2-
const version = "2025.06.28.0";
2+
const version = "2025.06.30.0";
33

44
const precacheResources = [
55
"/",

src/completions.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ export default function customCompletions(context) {
6363
apply: "circfill(",
6464
detail: "(x, y, radius, color=0)",
6565
},
66+
{
67+
label: "oval",
68+
type: "function",
69+
apply: "oval(",
70+
detail: "(x, y, rx, ry, color=0)",
71+
},
72+
{
73+
label: "ovalfill",
74+
type: "function",
75+
apply: "ovalfill(",
76+
detail: "(x, y, rx, ry, color=0)",
77+
},
6678
{
6779
label: "line",
6880
type: "function",

0 commit comments

Comments
 (0)