hm
This commit is contained in:
parent
7455d630fc
commit
4d3fc2cd47
84 changed files with 3429 additions and 3480 deletions
55
js/render.js
55
js/render.js
|
|
@ -12,6 +12,15 @@ function toolCursorIconDefinition(world) {
|
|||
return { tool, def, type: def.itemType || (def.placeable ? tool : "") };
|
||||
}
|
||||
|
||||
|
||||
function canvasEllipsizeText(ctx, text, maxW) {
|
||||
let s = String(text || "");
|
||||
if (!ctx || ctx.measureText(s).width <= maxW) return s;
|
||||
while (s.length > 1 && ctx.measureText(`${s}\u2026`).width > maxW) s = s.slice(0, -1);
|
||||
return `${s}\u2026`;
|
||||
}
|
||||
TARINAI_RENDER_GLOBAL.canvasEllipsizeText = TARINAI_RENDER_GLOBAL.canvasEllipsizeText || canvasEllipsizeText;
|
||||
|
||||
function staticVersionedAssetPath(path) {
|
||||
const raw = String(path || "");
|
||||
if (!raw) return "";
|
||||
|
|
@ -46,6 +55,45 @@ function drawToolCursorIconFallback(ctx, icon, size) {
|
|||
return true;
|
||||
}
|
||||
|
||||
function drawSimpleFireShape(ctx, x = 0, y = 0, size = 12, options = {}) {
|
||||
if (!ctx) return false;
|
||||
const s = Math.max(2, Number(size || 0) || 2);
|
||||
const phase = Number.isFinite(options.phase) ? options.phase : 0;
|
||||
const alpha = clamp(Number(options.alpha ?? 1) || 0, 0, 1);
|
||||
if (alpha <= 0.01) return false;
|
||||
const wobble = Math.sin(phase) * 0.08;
|
||||
ctx.save();
|
||||
ctx.translate(x, y);
|
||||
ctx.globalAlpha *= alpha;
|
||||
if (options.shadow !== false) {
|
||||
ctx.shadowColor = options.shadowColor || "rgba(255,72,24,0.34)";
|
||||
ctx.shadowBlur = Math.max(0, s * 0.34);
|
||||
}
|
||||
ctx.fillStyle = options.outer || "rgba(236,46,24,0.88)";
|
||||
ctx.strokeStyle = options.edge || "rgba(255,198,72,0.70)";
|
||||
ctx.lineWidth = Math.max(0.8, s * 0.08);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, -s * (1.05 + wobble));
|
||||
ctx.bezierCurveTo(s * (0.58 + wobble), -s * 0.55, s * 0.50, s * 0.28, s * 0.10, s * 0.62);
|
||||
ctx.bezierCurveTo(s * 0.05, s * 0.40, -s * 0.08, s * 0.22, -s * 0.27, s * 0.10);
|
||||
ctx.bezierCurveTo(-s * 0.30, s * 0.40, -s * 0.18, s * 0.56, 0, s * 0.66);
|
||||
ctx.bezierCurveTo(-s * 0.56, s * 0.36, -s * 0.54, -s * 0.44, 0, -s * (1.05 + wobble));
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
ctx.shadowBlur = 0;
|
||||
ctx.fillStyle = options.inner || "rgba(255,224,72,0.88)";
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(s * 0.04, -s * 0.58);
|
||||
ctx.bezierCurveTo(s * 0.32, -s * 0.18, s * 0.24, s * 0.32, s * 0.02, s * 0.48);
|
||||
ctx.bezierCurveTo(-s * 0.26, s * 0.22, -s * 0.18, -s * 0.24, s * 0.04, -s * 0.58);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
ctx.restore();
|
||||
return true;
|
||||
}
|
||||
TARINAI_RENDER_GLOBAL.drawSimpleFireShape = drawSimpleFireShape;
|
||||
|
||||
function buildToolCursorIconCanvas(tool, def, type, size) {
|
||||
const key = `${tool}:${type || "-"}:${size}`;
|
||||
const cached = toolCursorIconCache.get(key);
|
||||
|
|
@ -1589,12 +1637,7 @@ function drawPointerItemTooltip(ctx, world) {
|
|||
ctx.save();
|
||||
ctx.font = "12px Yomogi, sans-serif";
|
||||
const maxTextW = 238;
|
||||
const ellipsize = (text, maxW) => {
|
||||
let s = String(text || "");
|
||||
if (ctx.measureText(s).width <= maxW) return s;
|
||||
while (s.length > 1 && ctx.measureText(`${s}\u2026`).width > maxW) s = s.slice(0, -1);
|
||||
return `${s}\u2026`;
|
||||
};
|
||||
const ellipsize = (text, maxW) => canvasEllipsizeText(ctx, text, maxW);
|
||||
const wrapLine = (text, maxW) => {
|
||||
const s = String(text || "");
|
||||
if (ctx.measureText(s).width <= maxW) return [s];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue