Fundamentos - Variables

Introducción al manejo de variables en JavaScript

by jhonjairoroa87

HTML

<html>
<body>
    <canvas id="myCanvas" width="400" height="300"></canvas>
</body>

CSS

#myCanvas {background-color: #ccc;}

JavaScript

//
// Fundamentos - Variables
//

var x = 200; 
var y = 150;
var radius = 20; /// ASDASDASD
var color = 'red'; 

main = function(){ 
    drawCircle(x, y, radius, color); 
};

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
//
// Private functions
// You don't need to understand this at this point, feel free to ignore it :)
//    
drawCircle = function(x, y, radius, color) {
    var canvas = document.getElementById("myCanvas");
    var ctx = canvas.getContext("2d");
    ctx.fillStyle = color;
    ctx.beginPath();
    ctx.arc(x, y, radius, 0, Math.PI * 2, false);
    ctx.fill();
}
    
main();