Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

Commit 12de12e

Browse files
chore: add button to go to history details
1 parent aa5b84d commit 12de12e

2 files changed

Lines changed: 356 additions & 336 deletions

File tree

frontend/src/components/entropy/painting-visualizer.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function PaintingVisualizer({ uiData, className }: PaintingVisualizerProp
3131
context.scale(dpr, dpr)
3232
context.lineJoin = 'round'
3333
context.lineCap = 'round'
34-
context.lineWidth = 2
34+
context.lineWidth = 4
3535
context.strokeStyle = 'rgba(37, 99, 235, 0.8)'
3636
}
3737

@@ -58,10 +58,9 @@ export function PaintingVisualizer({ uiData, className }: PaintingVisualizerProp
5858

5959
if (mouseEvents.length === 0) return
6060

61-
// Get canvas dimensions for scaling
62-
const rect = canvas.getBoundingClientRect()
63-
const scaleX = rect.width / 800 // Assuming original canvas was 800px wide
64-
const scaleY = rect.height / 600 // Assuming original canvas was 600px high
61+
// Use 1:1 scaling to match drawing pad coordinate system
62+
const scaleX = 1
63+
const scaleY = 1
6564

6665
// Group events by stroke (consecutive events)
6766
const strokes: SchemaUiEvent[][] = []
@@ -92,16 +91,18 @@ export function PaintingVisualizer({ uiData, className }: PaintingVisualizerProp
9291

9392
context.beginPath()
9493
context.strokeStyle = `rgba(37, 99, 235, ${0.6 + (strokeIndex % 3) * 0.1})`
95-
context.lineWidth = 1 + (strokeIndex % 3)
94+
context.lineWidth = 4
9695

9796
const firstPoint = stroke[0]
98-
if (firstPoint.mouse_x !== null && firstPoint.mouse_y !== null) {
97+
if (firstPoint.mouse_x !== null && firstPoint.mouse_y !== null &&
98+
firstPoint.mouse_x !== undefined && firstPoint.mouse_y !== undefined) {
9999
context.moveTo(firstPoint.mouse_x * scaleX, firstPoint.mouse_y * scaleY)
100100
}
101101

102102
for (let i = 1; i < stroke.length; i++) {
103103
const point = stroke[i]
104-
if (point.mouse_x !== null && point.mouse_y !== null) {
104+
if (point.mouse_x !== null && point.mouse_y !== null &&
105+
point.mouse_x !== undefined && point.mouse_y !== undefined) {
105106
context.lineTo(point.mouse_x * scaleX, point.mouse_y * scaleY)
106107
}
107108
}
@@ -112,7 +113,8 @@ export function PaintingVisualizer({ uiData, className }: PaintingVisualizerProp
112113
// Draw individual click events as dots
113114
const clickEvents = uiData.filter(event => event.event_type === 'click')
114115
clickEvents.forEach(event => {
115-
if (event.mouse_x !== null && event.mouse_y !== null) {
116+
if (event.mouse_x !== null && event.mouse_y !== null &&
117+
event.mouse_x !== undefined && event.mouse_y !== undefined) {
116118
context.beginPath()
117119
context.fillStyle = 'rgba(239, 68, 68, 0.8)'
118120
context.arc(event.mouse_x * scaleX, event.mouse_y * scaleY, 3, 0, 2 * Math.PI)

0 commit comments

Comments
 (0)