COMP 1000 WORKSHOP 2

.docx

School

Macquarie University *

*We aren’t endorsed by this school

Course

1000

Subject

Mathematics

Date

Apr 3, 2024

Type

docx

Pages

3

Uploaded by ElderFerretMaster894

Report
WORKSHOP 2 Question 1: 1 = Integer 1.0 = Float 'a' = Character 2 = Integer 0 = Integer 0.0 = Float -0.0 = Float True = Boolean 'b' = Character '%' = Character "Hello World" = String "true" = String '4' = String "a" = String Question 2: The following code draws an ellipse centered at point x, y with a width of w and a height of h. ellipse( x, y, w, h); Complete the following statement that draws two ellipses, one centered at point 50, 80 with a width of 40 and a height of 60 and one smaller one centered at the same point with a height of 30 and a width of 20. ANSWER - ellipse(50, 80, 40, 60); ellipse(50, 80, 20, 30); QUESTION 3: Given an ellipse(120, 160, 50, 50) thats center is exactly 80 pixels from the right of the window, and 100 pixels from the bottom of the window, complete the following statement: ANSWER - size(200, 260); ellipse( 120, 160, 50, 50); QUESTION 4:
The following code draws a straight line that connect the two points x1, y1 and x2, y2: line( x1, y1, x2, y2); The following code will draw the same straight line line( x2, y2, x1, y1); For convenience, we'll refer to these as first and second points, where the first point is written before the second point. You task is to complete the following statement that draws a line where 1. The first point is at 80, 70 2. The second point is 30 pixels to the left of the first point, and 20 pixels below the first point. ANSWER - line(80, 70, 50, 90); QUESTION 5: The following code draws a rectangle where the x and y coordinates represent the upper-left corner of the shape, with a width of w and a height of h. rect( x, y, w, h); Determine what changes when the following statement is added. ANSWER: rectMode(CENTER); Before it would start from the up left corner but rectMode(CENTER); will cause the drawing to start from the middle of the rectangle rect( x, y, w, h); QUESTION 6: ANSWER: size(200,200); strokeWeight(4);
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help