Difference between revisions of "W1503 Lines and Ellipses"
From Coder Merlin
Line 7: | Line 7: | ||
= Experiment = | = Experiment = | ||
Enter into the Sources directory of the | Enter into the Sources/IgisShellD directory of the W1501 experience. | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
cd ~/ | cd ~/Experiences/W1501/Sources/IgisShellD | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 72: | Line 72: | ||
canvas.paint(ellipse) | canvas.paint(ellipse) | ||
}</syntaxhighlight> | }</syntaxhighlight> | ||
= Exercises = | = Exercises = |
Revision as of 21:01, 10 November 2019
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder
Prerequisites[edit]
Research[edit]
- Examine the back of a dollar bill. Note the pyramid on the left-hand side.
Experiment[edit]
Enter into the Sources/IgisShellD directory of the W1501 experience.
cd ~/Experiences/W1501/Sources/IgisShellD
Open main.swift in emacs.
emacs main.swift
Paint a Single Blue Line[edit]
Find the function within the Painter object named "setup". Edit the contents as follows:
func setup(canvas:Canvas) {
let lineWidth = LineWidth(width:3)
canvas.paint(lineWidth)
let blue = StrokeStyle(color:Color(red:100, green:100, blue:255))
canvas.paint(blue)
let lines = Lines(from:Point(x:10, y:50), to:Point(x:100, y:50))
canvas.paint(lines)
}
Paint a Triangle[edit]
Find the function within the Painter object named "setup". Edit the contents as follows:
func setup(canvas:Canvas) {
let lineWidth = LineWidth(width:3)
canvas.paint(lineWidth)
let blue = StrokeStyle(color:Color(red:100, green:100, blue:255))
canvas.paint(blue)
let lines = Lines(from:Point(x:10, y:50), to:Point(x:100, y:50))
lines.lineTo(Point(x:55, y:150))
lines.lineTo(Point(x:10, y:50))
canvas.paint(lines)
}
Now, run the program and view in a browser before continuing.
Circumscribe the Triangle with an Ellipse[edit]
Find the function within the Painter object named "setup". Edit the contents as follows:
func setup(canvas:Canvas) {
let lineWidth = LineWidth(width:3)
canvas.paint(lineWidth)
let blue = StrokeStyle(color:Color(red:100, green:100, blue:255))
canvas.paint(blue)
let lines = Lines(from:Point(x:110, y:150), to:Point(x:200, y:150))
lines.lineTo(Point(x:155, y:250))
lines.lineTo(Point(x:110, y:150))
canvas.paint(lines)
let violet = StrokeStyle(color:Color(.blueviolet))
canvas.paint(violet)
let ellipse = Ellipse(center:Point(x:155, y:200), radiusX:120, radiusY:55)
canvas.paint(ellipse)
}
Exercises[edit]
Continuing your previous project:
- Split your pyramid so that a few rows near the apex are separated from the body of the pyramid
- Alter the pyramid so that these separated rows (on top) are drawn using a triangle (rather than by a rows of bricks)
- Inside the triangle, draw an eye
- Draw the entire pyramid in shades of green. (Use at least three different shades of green.) See this note for more information about colors.