Skip to content

Commit 1a62383

Browse files
committed
update engine
1 parent 829a874 commit 1a62383

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

public/litecanvas.js

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
var assert = (condition, message = "Assertion failed") => {
2828
if (!condition) throw new Error(message);
2929
};
30-
var version = "0.95.0";
30+
var version = "0.96.0";
3131
function litecanvas(settings = {}) {
3232
const root = window, math = Math, TWO_PI = math.PI * 2, raf = requestAnimationFrame, _browserEventListeners = [], on = (elem, evt, callback) => {
3333
elem.addEventListener(evt, callback, false);
@@ -122,7 +122,7 @@
122122
round: (n, precision = 0) => {
123123
DEV: assert(isNumber(n), "[litecanvas] round() 1st param must be a number");
124124
DEV: assert(
125-
null == precision || isNumber(precision) && precision >= 0,
125+
isNumber(precision) && precision >= 0,
126126
"[litecanvas] round() 2nd param must be a positive number or zero"
127127
);
128128
if (!precision) {
@@ -508,15 +508,15 @@
508508
instance.stroke(color);
509509
},
510510
/**
511-
* Sets the thickness of lines
511+
* Sets the thickness of the lines
512512
*
513513
* @param {number} value
514514
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineWidth
515515
*/
516516
linewidth(value) {
517517
DEV: assert(
518-
isNumber(value) && ~~value > 0,
519-
"[litecanvas] linewidth() 1st param must be a positive number"
518+
isNumber(value) && value >= 0,
519+
"[litecanvas] linewidth() 1st param must be a positive number or zero"
520520
);
521521
_ctx.lineWidth = ~~value;
522522
_outline_fix = 0 === ~~value % 2 ? 0 : 0.5;
@@ -695,43 +695,47 @@
695695
*
696696
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/save
697697
*/
698-
push: () => _ctx.save(),
698+
push() {
699+
_ctx.save();
700+
},
699701
/**
700702
* restores the drawing style settings and transformations
701703
*
702704
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/restore
703705
*/
704-
pop: () => _ctx.restore(),
706+
pop() {
707+
_ctx.restore();
708+
},
705709
/**
706710
* Adds a translation to the transformation matrix.
707711
*
708712
* @param {number} x
709713
* @param {number} y
710714
*/
711-
translate: (x, y) => {
715+
translate(x, y) {
712716
DEV: assert(isNumber(x), "[litecanvas] translate() 1st param must be a number");
713717
DEV: assert(isNumber(y), "[litecanvas] translate() 2nd param must be a number");
714-
return _ctx.translate(~~x, ~~y);
718+
_ctx.translate(~~x, ~~y);
715719
},
716720
/**
717721
* Adds a scaling transformation to the canvas units horizontally and/or vertically.
718722
*
719723
* @param {number} x
720724
* @param {number} [y]
721725
*/
722-
scale: (x, y) => {
726+
scale(x, y) {
723727
DEV: assert(isNumber(x), "[litecanvas] scale() 1st param must be a number");
724728
DEV: assert(null == y || isNumber(y), "[litecanvas] scale() 2nd param must be a number");
725-
return _ctx.scale(x, y || x);
729+
_ctx.scale(x, y || x);
726730
},
727731
/**
728732
* Adds a rotation to the transformation matrix.
729733
*
730734
* @param {number} radians
731735
*/
732-
rotate: (radians) => {
736+
rotate(radians) {
733737
DEV: assert(isNumber(radians), "[litecanvas] rotate() 1st param must be a number");
734-
return _ctx.rotate(radians);
738+
_ctx.rotate(radians);
735739
},
736740
/**
737741
* Sets the alpha (opacity) value to apply when drawing new shapes and images
@@ -956,12 +960,15 @@
956960
/**
957961
* Returns information about that engine instance.
958962
*
959-
* @param {number} n
963+
* @param {number|string} index
960964
* @returns {any}
961965
*/
962-
stat(n) {
963-
DEV: assert(isNumber(n) && n >= 0, "[litecanvas] stat() 1st param must be a number");
964-
const list = [
966+
stat(index) {
967+
DEV: assert(
968+
isNumber(index) || "string" === typeof index,
969+
"[litecanvas] stat() 1st param must be a number or string"
970+
);
971+
const internals = [
965972
// 0
966973
settings,
967974
// 1
@@ -987,7 +994,7 @@
987994
// 11
988995
_fontFamily
989996
];
990-
const data = { index: n, value: list[n] };
997+
const data = { index, value: internals[index] };
991998
instance.emit("stat", data);
992999
return data.value;
9931000
},

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.7.26.0";
2+
const version = "2025.7.27.0";
33

44
const precacheResources = [
55
"/",

0 commit comments

Comments
 (0)