Skip to content
Snippets Groups Projects
Commit df61bda4 authored by Moritz Langenstein's avatar Moritz Langenstein
Browse files

(ml5717) Added svg canvas and public/index.html

parent 719c3657
No related branches found
No related tags found
No related merge requests found
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
</head>
<body>
<textarea style="width: 100%; height: 500px" id="textfield"></textarea>
<script src="js/app.js"></script>
<svg id="whiteboard" width="100%" height="100%"></svg>
<script>
var whiteboard = document.getElementById("whiteboard")
var painting = false
var path
whiteboard.onmousedown = function(e) {
painting = true
var mouse = {
x: e.offsetX,
y: e.offsetY
}
path = document.createElementNS("http://www.w3.org/2000/svg", "path")
path.setAttribute("d", "M" + mouse.x + " " + mouse.y)
path.setAttribute("stroke", "blue")
path.setAttribute("stroke-width", 3)
path.setAttribute("fill", "none")
path.setAttribute("pointer-events", "none")
whiteboard.appendChild(path)
}
whiteboard.onmouseup = function(e) {
painting = false
}
whiteboard.onmousemove = function(e) {
var mouse = {
x: e.offsetX,
y: e.offsetY
}
if (painting) {
path.setAttribute(
"d",
path.getAttribute("d") + " L" + mouse.x + " " + mouse.y
)
}
}
</script>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment