HW #1







<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
////////////////////////////////////// start below this line ˇˇˇˇˇˇˇˇˇˇ

var x=50;
var y=100;
var width = 700
var height= 250;

context.beginPath();
context.rect(x, y, width, height);
context.lineWidth = 10;
//context.fillStyle = 'rgb(0,255,0)';
context.strokeStyle = 'rgb(87,249,255)';
// add linear gradient
        var grd = context.createLinearGradient(x, y, x+width, y+height);
        // starting color
        grd.addColorStop(0, "rgb(158,216,255)");
        //intermediate color
        grd.addColorStop(0.5, "rgb(255,205,140)");
        // ending color
        grd.addColorStop(1, "rgb(158,216,255)");
        context.fillStyle = grd;
        context.fill();
context.fill();


context.stroke();

//context.rect(x, y, width, height); // top left corner x and y coordinates, width and height

// for a square width = height , the width and the height have the same value

////////////////////////////////////// end above this line ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ

};
</script>
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>

<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
////////////////////////////////////// start below this line ˇˇˇˇˇˇˇˇˇˇ
//Simple V line in pink

var x= 50;
var y = 100;
var x1 = 300;
var y1 = 450;
var x2 = 400;
var y2 = 300;
var x3 = 500;
var y3 = 450;
var x4 = 750;
var y4 = 100;

//comment
context.beginPath();
context.moveTo(x, y);
context.lineTo(x1, y1); // move to starting coordinates
context.lineTo(x2, y2); // draw line to following point
context. lineTo (x3,y3)
context. lineTo (x4,y4)
context.lineCap = 'round';
context.lineWidth = 10;// declare the width in pixels of the line
context.strokeStyle = 'rgb(255,0,255)'; // or "#FF0000" // declare the line color in rgb or hexadecimal values

context.stroke();


//Line Caps
//context.lineCap = "butt"; // "round" or "square"

//Line Joins
//context.lineJoin = "miter"; // "round" or "bevel"


////////////////////////////////////// end above this line ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ

};
</script>

</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>

                                          
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
////////////////////////////////////// start below this line ˇˇˇˇˇˇˇˇˇˇ
var rectx2  = 200;
var recty2 = 200;
var rectwidth2 = 200;
var rectheight2 = 200;
  
//blue and green rectangle2
  context.beginPath();
context.rect(rectx2,recty2,rectwidth2,rectheight2);
context.lineWidth = 3;
context.strokeStyle = 'rgb(128,0,0)';
context.fillStyle = 'rgb(0,128,128)';
  context.fill();
context.stroke();
////////////////////////////////////// end above this line ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ

};

</script
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>

<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");

////////////////////////////////////// start below this line ˇˇˇˇˇˇˇˇˇˇ
var x1 =50;
var y1 =50;
var x2 =750;
var y2 =500;


var x3= 300;
var y3= 60;
var x4= 100;
var y4= 500;

var x5= 600;
var y5= 150;
var x6= 550;
var y6= 500;

var x7= 400;
var y7= 75;
var x8= 150;
var y8= 400;

//light blue line
  context.beginPath();
  context.moveTo(x1,y1);
  context.lineTo(x2,y2);
  context.lineWidth = 30;
  context.strokeStyle = 'rgb(0,250,250)';
  context.lineCap = 'round';
  context.stroke();
  


//dark blue line
context.beginPath();
  context.moveTo(x3,y3);
  context.lineTo(x4,y4);
  context.lineWidth = 15;
  context.strokeStyle = 'rgb(0,0,250)';
  context.lineCap = 'square';
  context.stroke();


//orange line
context.beginPath();
  context.moveTo(x5,y5);
  context.lineTo(x6,y6);
  context.lineWidth = 25;
  context.strokeStyle = 'rgb(255,165,0)';
  context.lineCap = 'butt';
  context.stroke();
//green line
context.beginPath();
  context.moveTo(x7,y7);
  context.lineTo(x8,y8);
  context.lineWidth = 8;
  context.strokeStyle = 'rgb(85,255,0)';
  context.lineCap = 'butt';
  context.stroke();


////////////////////////////////////// end above this line ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ

};

</script>
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>

Comments

Popular posts from this blog

Logo

portrait poster

Caligram