Skip to content

Instantly share code, notes, and snippets.

@nake89
Created February 24, 2019 16:09
Show Gist options
  • Save nake89/a5baf72ef7c9e0e959327ccc2e5106a5 to your computer and use it in GitHub Desktop.
Save nake89/a5baf72ef7c9e0e959327ccc2e5106a5 to your computer and use it in GitHub Desktop.
class Canvas {
constructor(x, y) {
this.x = x
this.y = y
this.canvas = document.createElement("canvas")
this.ctx = this.canvas.getContext("2d")
document.body.appendChild(this.canvas)
this.ctx.fillStyle = "rgb(51, 51, 51)"
this.ctx.fillRect(0, 0, x, y)
}
setColor(color) {
this.ctx.fillStyle(color)
// console.log(this.ctx)
}
}
let canvas = new Canvas(400, 800)
canvas.setColor("#FF0000")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment