-
-
-
-
@@ -215,7 +219,7 @@ let dotSize = Math.floor(Math.max(cellSize * 1.25, 32));
let ctx;
let dpr = 1;
let selectedColor;
-let currentOpacity = clamp01(fillOpacityEl?.value ?? 0.15, 0.15);
+let currentOpacity = clamp01(fillOpacityEl?.value ?? 1, 1);
let currentShape = null;
const history = [structuredClone(shapes)];
@@ -268,7 +272,7 @@ function commit(nextShapes) {
redrawAll();
}
-function clamp01(n, fallback = 0.15) {
+function clamp01(n, fallback = 1) {
const x = Number(n);
return Number.isFinite(x) ? Math.min(1, Math.max(0, x)) : fallback;
}
@@ -281,7 +285,7 @@ function sanitizeShapes(list) {
return list.flatMap((s) => {
if (!s || typeof s !== 'object' || !allowed.has(s.type)) return [];
const color = typeof s.color === 'string' ? s.color : '#000000';
- const opacity = clamp01(s.opacity, 0.15);
+ const opacity = clamp01(s.opacity, 1);
if (s.type === 'line') {
if (!['x1','y1','x2','y2'].every(k => isFiniteNum(s[k]))) return [];
@@ -446,7 +450,7 @@ function normalizeRect(shape) {
h: Math.abs(y2 - y1),
color: shape.color,
fill: shape.fill,
- opacity: clamp01(shape.opacity, 0.15)
+ opacity: clamp01(shape.opacity, 1)
};
}
@@ -522,7 +526,7 @@ function drawShape(shape) {
}
if (shape.fill) {
- ctx.globalAlpha = clamp01(shape.opacity, 0.15);
+ ctx.globalAlpha = clamp01(shape.opacity, 1);
ctx.fillStyle = shape.color;
if (shape.type === 'rect') {
ctx.fillRect(x, y, w, h);
@@ -702,11 +706,11 @@ document.addEventListener('keydown', (e) => {
});
fillOpacityEl?.addEventListener('input', () => {
- currentOpacity = clamp01(fillOpacityEl.value, 0.15);
+ currentOpacity = clamp01(fillOpacityEl.value, 0);
});
fillOpacityEl?.addEventListener('change', () => {
- currentOpacity = clamp01(fillOpacityEl.value, 0.15);
+ currentOpacity = clamp01(fillOpacityEl.value, 0);
});
gridEl.addEventListener('pointercancel', () => {
@@ -724,16 +728,19 @@ gridEl.addEventListener('pointermove', (e) => {
const { ix, iy, x: snapX, y: snapY, localX, localY } = snapToGrid(e.clientX, e.clientY);
-
- const renderX = snapX - dotSize / 2;
- const renderY = snapY - dotSize / 2;
-
coordsEl.classList.remove('d-none');
if (getActiveType() !== 'noGrid') {
dotEl.classList.remove('d-none');
- dotEl.style.top = `${renderY}px`;
- dotEl.style.left = `${renderX}px`;
+
+ const gridRect = gridEl.getBoundingClientRect();
+ const wrapRect = gridWrapEl.getBoundingClientRect();
+
+ const offsetX = gridRect.left - wrapRect.left;
+ const offsetY = gridRect.top - wrapRect.top;
+
+ dotEl.style.left = `${offsetX + snapX}px`;
+ dotEl.style.top = `${offsetY + snapY}px`;
}
if (getActiveType() == 'noGrid') {