Skip to content

Instantly share code, notes, and snippets.

@mayurbhangale
Created November 15, 2018 11:18
Show Gist options
  • Select an option

  • Save mayurbhangale/95c3deba7fe7f083aeec2de002dde28d to your computer and use it in GitHub Desktop.

Select an option

Save mayurbhangale/95c3deba7fe7f083aeec2de002dde28d to your computer and use it in GitHub Desktop.
Drawing canvas by sketch.js
<center>
<h1>Drawing canvas by sketch.js</h1>
<p>Paint anything as you want in this grey area</p>
<button id="btnClear">CLEAR</button>
<br>
<br>
<div id="sketch-container"></div>
</center>
var sketch = Sketch.create({
container: document.getElementById('sketch-container'),
fullscreen: false,
width: 960,
height: 500,
autoclear: false,
touchmove: function() {
if (this.dragging) {
var touch = this.touches[0];
this.lineWidth = 3;
this.beginPath();
this.moveTo(touch.ox, touch.oy);
this.lineTo(touch.x, touch.y);
this.stroke();
}
}
})
document.getElementById('btnClear').addEventListener("click", function(){
sketch.clear()
});
<script src="https://soulwire.github.io/sketch.js/js/sketch.js"></script>
#sketch-container {
background: #EAEAEA;
width: 960px;
height: 500px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment