Last active
December 12, 2015 08:59
-
-
Save johnstew/4748299 to your computer and use it in GitHub Desktop.
Canvas Circle Object. Looking for advice as to improve this.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload = function(){ | |
var canvas = document.getElementById('canvas'); | |
var context = canvas.getContext('2d'); | |
canvas.width = 500; | |
canvas.height = 500; | |
function Circle(posX,posY,r,c,lw,s){ | |
this.x = posX; | |
this.y = posY; | |
this.radius = r; | |
this.color = c; | |
this.lineWidth = lw; | |
this.strokeStyle = s; | |
context.beginPath(); | |
context.arc(this.x,this.y,this.radius, 0, 2 * Math.PI, false); | |
context.fillStyle = '#'+this.color; | |
context.fill(); | |
context.lineWidth = this.lineWidth; | |
context.strokeStyle = '#'+this.strokeStyle; | |
context.stroke(); | |
} | |
var circle = new Circle(50,50,20, "0000ff", 2, "ff0000"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment