Skip to content

Commit a5a9668

Browse files
committed
update engine
1 parent 7825bd5 commit a5a9668

File tree

6 files changed

+380
-378
lines changed

6 files changed

+380
-378
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
"author": "Luiz Bills",
1818
"license": "MIT",
1919
"devDependencies": {
20-
"esbuild": "^0.25.2"
20+
"esbuild": "^0.25.5"
2121
},
2222
"dependencies": {
23-
"@babel/standalone": "^7.27.0",
24-
"@codemirror/lang-javascript": "^6.2.3",
23+
"@babel/standalone": "^7.27.5",
24+
"@codemirror/lang-javascript": "^6.2.4",
2525
"@codemirror/theme-one-dark": "^6.1.2",
2626
"@litecanvas/plugin-asset-loader": "latest",
2727
"@litecanvas/utils": "latest",

public/app.js

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

public/litecanvas.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
for (e = a * e + 9, X *= a, P *= a, S *= a, r *= a, H *= 500 * t / a ** 3, K *= t / a, V *= t / a, J *= a, h = a * h | 0, i *= 0.3 * (globalThis.zzfxV || 1), s = e + X + P + S + r | 0; f < s; d[f++] = o * i) ++l % (100 * E | 0) || (o = I ? 1 < I ? 2 < I ? 3 < I ? C(x * x) : n.max(n.min(n.tan(x), 1), -1) : 1 - (2 * x / t % 2 + 2) % 2 : 1 - 4 * n.abs(n.round(x / t) - x / t) : C(x), o = (h ? 1 - L + L * C(t * f / h) : 1) * (o < 0 ? -1 : 1) * n.abs(o) ** c * (f < e ? f / e : f < e + X ? 1 - (f - e) / X * (1 - B) : f < e + X + P ? B : f < s - r ? (s - f - r) / S * B : 0), o = r ? o / 2 + (r > f ? 0 : (f < s - r ? 1 : (s - f) / r) * d[f - r | 0] / 2 / i) : o, D && (o = Z = v * U + A * (U = W) + R * (W = o) - y * Y - m * (Y = Z))), u = (z += T += H) * n.cos(K * _++), x += u + u * j * C(f ** 5), g && ++g > J && (z += V, O += V, g = 0), !h || ++$ % h || (z = O, T = F, g = g || 1);
88
i = zzfxX.createBuffer(1, s, a), i.getChannelData(0).set(d), z = zzfxX.createBufferSource(), z.buffer = i, z.connect(zzfxX.destination), z.start();
99
};
10-
var colors = [
10+
var defaultPalette = [
1111
"#111",
1212
"#6a7799",
1313
"#aec2c2",
@@ -45,7 +45,7 @@
4545
animate: true
4646
};
4747
settings = Object.assign(defaults, settings);
48-
let _initialized = false, _plugins = [], _canvas, _scale = 1, _ctx, _outline_fix = 0.5, _timeScale = 1, _lastFrameTime, _deltaTime = 1 / 60, _accumulated = 0, _rafid, _fontFamily = "sans-serif", _fontSize = 20, _rng_seed = Date.now(), _events = {
48+
let _initialized = false, _plugins = [], _canvas, _scale = 1, _ctx, _outline_fix = 0.5, _timeScale = 1, _lastFrameTime, _deltaTime = 1 / 60, _accumulated = 0, _rafid, _fontFamily = "sans-serif", _fontSize = 20, _rng_seed = Date.now(), _colors = defaultPalette, _events = {
4949
init: false,
5050
update: false,
5151
draw: false,
@@ -55,8 +55,7 @@
5555
tapping: false,
5656
tapped: false
5757
}, _helpers = {
58-
settings: Object.assign({}, settings),
59-
colors
58+
settings: Object.assign({}, settings)
6059
};
6160
const instance = {
6261
/** @type {number} */
@@ -77,6 +76,8 @@
7776
MOUSEY: -1,
7877
/** @type {number[]} */
7978
DEFAULT_SFX: [0.5, 0, 1750, , , 0.3, 1, , , , 600, 0.1],
79+
/** @type {string[]} */
80+
COLORS: _colors,
8081
/** MATH API */
8182
/**
8283
* Twice the value of the mathematical constant PI (π).
@@ -870,6 +871,19 @@
870871
triggerEvent("after:" + eventName, arg1, arg2, arg3, arg4);
871872
}
872873
},
874+
/**
875+
* Set or reset the color palette
876+
*
877+
* @param {string[]} [colors]
878+
*/
879+
pal(colors = defaultPalette) {
880+
DEV: assert(
881+
Array.isArray(colors) && colors.length > 0,
882+
"pal: 1st param must be a array of strings"
883+
);
884+
_colors = colors;
885+
instance.setvar("COLORS", _colors);
886+
},
873887
/**
874888
* Get a color by index
875889
*
@@ -881,7 +895,7 @@
881895
null == index || isNumber(index) && index >= 0,
882896
"getcolor: 1st param must be a number"
883897
);
884-
return colors[~~index % colors.length];
898+
return _colors[~~index % _colors.length];
885899
},
886900
/**
887901
* Create or update a instance variable
@@ -1119,6 +1133,7 @@
11191133
});
11201134
on(root, "focus", () => {
11211135
if (!_rafid) {
1136+
_accumulated = 0;
11221137
_rafid = raf(drawFrame);
11231138
}
11241139
});

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 = "2.80.3";
2+
const version = "2.81.0";
33

44
const precacheResources = [
55
"/",

src/completions.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ export default function customCompletions(context) {
3636
label: "DEFAULT_SFX",
3737
type: "variable",
3838
},
39+
{
40+
label: "COLORS",
41+
type: "variable",
42+
info: "the current color palette",
43+
},
3944
{ label: "PI", type: "constant" },
4045
{ label: "TWO_PI", type: "constant" },
4146
{ label: "HALF_PI", type: "constant" },
@@ -191,6 +196,12 @@ export default function customCompletions(context) {
191196
detail: "",
192197
info: "restore the rendering context",
193198
},
199+
{
200+
label: "pal",
201+
type: "function",
202+
apply: "pal(colors?)",
203+
info: "set or reset the color palette",
204+
},
194205
{
195206
label: "ctx",
196207
type: "function",
@@ -263,12 +274,6 @@ export default function customCompletions(context) {
263274
apply: "norm(",
264275
detail: "(val, min, max)",
265276
},
266-
{
267-
label: "diff",
268-
type: "function",
269-
apply: "diff(",
270-
detail: "(a, b)",
271-
},
272277
{
273278
label: "clamp",
274279
type: "function",

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ const state = EditorState.create({
230230
EditorView.updateListener.of((update) => {
231231
if (update.docChanged) config.codeChanged = true;
232232
}),
233-
scrollPastEnd(),
233+
// scrollPastEnd(),
234234
...desktopExtensions,
235235
],
236236
});

0 commit comments

Comments
 (0)