Virtual tabletop management library
npm install virtual-tabletop-library
npm i virtual-tabletop-library
`
$3
`
document.addEventListener("DOMContentLoaded", function () {
const mapCanvas = new MapCanvas("game-board", {
mapUrl: "your_map_image_url_here",
});
});
`
$3
`jsx
import React, { useEffect, useRef } from 'react';
import { MapCanvas as MapCanvasLibrary } from './MapCanvas'; // Adjust the import path as necessary
const MapCanvas = ({ canvasId, mapUrl, maxWidth, maxHeight }) => {
const canvasRef = useRef(null);
useEffect(() => {
if (canvasRef.current) {
const mapCanvas = new MapCanvasLibrary(canvasId, { mapUrl, maxWidth, maxHeight });
// Additional setup or methods can be called on mapCanvas if needed
return () => {
// Perform any cleanup if necessary
};
}
}, [canvasId, mapUrl, maxWidth, maxHeight]);
return ;
};
`
`
const App = () => {
return (
canvasId="mapCanvas"
mapUrl="your-map-url.jpg"
maxWidth={800}
maxHeight={600}
/>
);
};
``