Docsity

EECS 468 Fall 2023 ICP 13, Assignments of Computer Science

Toggle sidebar
bg1
Mikaela Navarro
2998217
1)// create a variable to be able to reference the context object to be able to use
its properties
let cx =document.querySelector("canvas").getContext("2d");
// start drawing
cx.beginPath();
// start at (20,70) to draw quadratic curve
cx.moveTo(20,70);
// draw to control point at (60, 10), and ends at (70, 80)
cx.quadraticCurveTo(60,10,70,80);
// create stroke
cx.stroke();
2)// create a variable to be able to reference the context object to be able to use
its properties
let cx =document.querySelector("canvas").getContext("2d");
// start drawing
cx.beginPath();
// start at (20,90) to draw bezier curve
cx.moveTo(20,90);
// draw to control1 at (20, 10), control2 at (100, 10), and ends at (60, 90)
cx.bezierCurveTo(20,10,100,10,60,90);
// from (60, 90) draw a line to (100, 10)
cx.lineTo(100,10);
// from (100, 10) draw a line to (20,10)
cx.lineTo(20,10);
// close the opening from (20, 10) to (20, 90)
cx.closePath();
// fill in the shape
cx.fill();
3)// create a variable to be able to reference the context object to be able to use
its properties
let cx =document.querySelector("canvas").getContext("2d");
// start drawing
cx.beginPath();
// left eye
// draw the circle w/ the center=(130, 40) radius=10 angle=0 to 7
cx.arc(130,40,10,0,7);
// fill in the shape
pf2

Partial preview of the text

Download EECS 468 Fall 2023 ICP 13 and more Assignments Computer Science in PDF only on Docsity!

Mikaela Navarro

1)// create a variable to be able to reference the context object to be able to use

its properties let cx = document.querySelector("canvas").getContext("2d"); // start drawing cx.beginPath(); // start at (20,70) to draw quadratic curve cx.moveTo(20,70); // draw to control point at (60, 10), and ends at (70, 80) cx.quadraticCurveTo(60, 10, 70, 80); // create stroke cx.stroke();

2)// create a variable to be able to reference the context object to be able to use

its properties let cx = document.querySelector("canvas").getContext("2d"); // start drawing cx.beginPath(); // start at (20,90) to draw bezier curve cx.moveTo(20, 90); // draw to control1 at (20, 10), control2 at (100, 10), and ends at (60, 90) cx.bezierCurveTo(20, 10, 100, 10, 60, 90); // from (60, 90) draw a line to (100, 10) cx.lineTo(100, 10); // from (100, 10) draw a line to (20,10) cx.lineTo(20, 10); // close the opening from (20, 10) to (20, 90) cx.closePath(); // fill in the shape cx.fill();

3)// create a variable to be able to reference the context object to be able to use

its properties let cx = document.querySelector("canvas").getContext("2d"); // start drawing cx.beginPath(); // left eye // draw the circle w/ the center=(130, 40) radius=10 angle=0 to 7 cx.arc(130, 40, 10, 0, 7); // fill in the shape

cx.fill(); // right eye // draw the circle w/ the center=(170, 40) radius=10 angle=0 to 7 cx.arc(170, 40, 10, 0, 7); // fill in the shape cx.fill(); // smile // start a drawing, so that we don't connect the eyes to the mouth cx.beginPath(); // draw the curve w/ the center=(150,50) radius=40 angle=0 to ½π cx.arc(150, 50, 40, 0, 1 * Math.PI); // create stroke cx.stroke();