feat: add screenshot functionality to export canvas layout as a PNG image

This commit is contained in:
sebseb7
2026-06-08 00:05:48 +02:00
parent 53d9561de1
commit 14c2b9b08c
2 changed files with 69 additions and 7 deletions

View File

@@ -1,7 +1,8 @@
import React, { useRef, useState } from 'react';
import React, { useRef } from 'react';
import { Rect, Group, Transformer } from 'react-konva';
export function Tile({ id, initialX, initialY, scale, meterWidth = 1.6, meterHeight = 1.6, color = "rgba(16, 185, 129, 0.6)", stroke = "#10b981", isSelected, onSelect, type, rotation = 0, onChange }) {
export function Tile({ initialX, initialY, scale, meterWidth = 1.6, meterHeight = 1.6, color = "rgba(16, 185, 129, 0.6)", stroke = "#10b981", isSelected, onSelect, type, rotation = 0, onChange }) {
const shapeRef = useRef();
const trRef = useRef();
const pixelWidth = meterWidth * scale;
@@ -54,7 +55,7 @@ export function Tile({ id, initialX, initialY, scale, meterWidth = 1.6, meterHei
y: e.target.y()
});
}}
onTransformEnd={(e) => {
onTransformEnd={() => {
const node = shapeRef.current;
node.scaleX(1);
node.scaleY(1);