2018-05-28 08:29:05 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
<title>Minimal demo of SvgCanvas</title>
|
2020-08-04 07:18:31 +00:00
|
|
|
<script src="../src/editor/jquery.min.js"></script>
|
2018-05-28 08:29:05 +00:00
|
|
|
<style> #svgroot { overflow: hidden; } </style>
|
2020-08-04 07:18:31 +00:00
|
|
|
<link rel="shortcut icon" type="image/x-icon" href="../src/editor/images/logo.png" />
|
2018-05-28 08:29:05 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<h1>Minimal demo of SvgCanvas</h1>
|
|
|
|
|
|
|
|
<div id="editorContainer"></div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
[<button onclick="canvas.setMode('select')">Select</button>
|
|
|
|
<button onclick="canvas.setMode('circle')">Circle</button>
|
|
|
|
<button onclick="canvas.setMode('rect')">Rect</button>]
|
|
|
|
<button onclick="fill('#ff0000')">Fill Red</button>
|
|
|
|
<button onclick="canvas.deleteSelectedElements()">Delete Selected</button>
|
|
|
|
<button onclick="canvas.clear(); canvas.updateCanvas(width, height);">Clear All</button>
|
|
|
|
<button onclick="alert(canvas.getSvgString())">Get SVG</button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script type="module">
|
2019-07-02 04:21:21 +00:00
|
|
|
/* globals canvas */
|
2020-07-30 12:21:16 +00:00
|
|
|
import SvgCanvas from '../src/svgcanvas/svgcanvas.js';
|
2018-05-28 08:29:05 +00:00
|
|
|
|
|
|
|
const container = document.querySelector('#editorContainer');
|
|
|
|
const {width, height} = {width: 500, height: 300};
|
|
|
|
window.width = width;
|
|
|
|
window.height = height;
|
|
|
|
|
|
|
|
const config = {
|
|
|
|
initFill: {color: 'FFFFFF', opacity: 1},
|
|
|
|
initStroke: {color: '000000', opacity: 1, width: 1},
|
|
|
|
text: {stroke_width: 0, font_size: 24, font_family: 'serif'},
|
|
|
|
initOpacity: 1,
|
|
|
|
imgPath: 'editor/images/',
|
|
|
|
dimensions: [width, height],
|
2019-07-02 04:21:21 +00:00
|
|
|
baseUnit: 'px'
|
2018-05-28 08:29:05 +00:00
|
|
|
};
|
|
|
|
|
2018-11-22 00:53:09 +00:00
|
|
|
window.canvas = new SvgCanvas(container, config);
|
2018-05-28 08:29:05 +00:00
|
|
|
canvas.updateCanvas(width, height);
|
|
|
|
|
|
|
|
window.fill = function (colour) {
|
|
|
|
canvas.getSelectedElems().forEach((el) => {
|
|
|
|
el.setAttribute('fill', colour);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|