Difference between revisions of "Render Part C Assignment"
| Line 6: | Line 6: | ||
=Code to Implement= | =Code to Implement= | ||
| + | ==Bounds== | ||
| + | |||
==Transform== | ==Transform== | ||
| − | {{RubyToEvolve|transform|render/assignment|Transform|Object| | + | {{RubyToEvolve|transform|render/assignment|Transform|Object|Ø|move(direction,amount)<br/>calculate_bounds()|Ø}} |
===move=== | ===move=== | ||
the move method will accept two parameters: direction and amount. | the move method will accept two parameters: direction and amount. | ||
| Line 33: | Line 35: | ||
==Rectangle== | ==Rectangle== | ||
| − | {{RubyToEvolve|rectangle|render/assignment|Rectangle|ColorTransform||calculate_local_bounds|}} | + | {{RubyToEvolve|rectangle|render/assignment|Rectangle|ColorTransform|Ø|calculate_local_bounds|Ø}} |
| + | ===calculate_local_bounds=== | ||
| + | Returns an instance of Bounds specified by min and max Point2ds. | ||
| + | |||
| + | ==Ellipse== | ||
| + | {{RubyToEvolve|ellipse|render/assignment|Ellipse|ColorTransform|Ø|calculate_local_bounds|Ø}} | ||
| + | |||
| + | ===calculate_local_bounds=== | ||
| + | Returns an instance of Bounds specified by min and max Point2ds. | ||
| + | |||
| + | ==EquilateralTriangle== | ||
| + | {{RubyToEvolve|equilateral_triangle|render/assignment|Rectangle|EquilateralTriangle|Ø|calculate_local_bounds|Ø}} | ||
| + | |||
===calculate_local_bounds=== | ===calculate_local_bounds=== | ||
| + | Returns an instance of Bounds specified by min and max Point2ds. | ||
| − | ==BezierCurve, Chord | + | ==BezierCurve, Chord, Image, Text== |
Imagine what it would be like to define <code>calculate_local_bounds</code> for each of these classes. | Imagine what it would be like to define <code>calculate_local_bounds</code> for each of these classes. | ||
Revision as of 16:35, 2 December 2020
In this studio we will evolve our code from Render_Part_B_Assignment to add new methods and a new class.
Continue editing files in the render/assignment directory.
Contents
Code to Implement
Bounds
Transform
| file: | src/main/ruby/render/assignment/transform.rb | |
| class: | Transform | |
| superclass: | Object | |
| methods to evolve: | Ø | |
| methods to add: | move(direction,amount) calculate_bounds() |
|
| methods to remove: | Ø |
move
the move method will accept two parameters: direction and amount.
direction can be one of four symbols
:left :right :up :down
- left corresponds to translating along the negative x axis
- right corresponds to translating along the positive x axis
- down corresponds to translating along the negative y axis
- up corresponds to translating along the positive y axis
any other value for direction should raise an ArgumentError.
calculate_bounds
invoke calculate_local_bounds and transform the returned bounds by x and y.
NOTE: calculate_local_bounds is abstract. it must be defined by the subclasses.
Rectangle
| file: | src/main/ruby/render/assignment/rectangle.rb | |
| class: | Rectangle | |
| superclass: | ColorTransform | |
| methods to evolve: | Ø | |
| methods to add: | calculate_local_bounds | |
| methods to remove: | Ø |
calculate_local_bounds
Returns an instance of Bounds specified by min and max Point2ds.
Ellipse
| file: | src/main/ruby/render/assignment/ellipse.rb | |
| class: | Ellipse | |
| superclass: | ColorTransform | |
| methods to evolve: | Ø | |
| methods to add: | calculate_local_bounds | |
| methods to remove: | Ø |
calculate_local_bounds
Returns an instance of Bounds specified by min and max Point2ds.
EquilateralTriangle
| file: | src/main/ruby/render/assignment/equilateral_triangle.rb | |
| class: | Rectangle | |
| superclass: | EquilateralTriangle | |
| methods to evolve: | Ø | |
| methods to add: | calculate_local_bounds | |
| methods to remove: | Ø |
calculate_local_bounds
Returns an instance of Bounds specified by min and max Point2ds.
BezierCurve, Chord, Image, Text
Imagine what it would be like to define calculate_local_bounds for each of these classes.
CompositeTransform
calculate_local_bounds
Scene
calculate_bounds
ConvexPolygon
render_transformed
calculate_local_bounds
Testing Your Solution
Visual Comparison
| file to run: | src/test/ruby/render/part_c/part_c_test_snapshots_web_page_generator.rb |
Unit Test
| file: | src/test/ruby/render/part_c/part_c_unit_test.rb |
note: ensure that you have removed all printing to receive credit for any assignment.
| file: | src/test/ruby/render/part_c/part_c_move_unit_test.rb |
note: ensure that you have removed all printing to receive credit for any assignment.
| file: | src/test/ruby/render/part_c/part_c_bounds_unit_test.rb |
note: ensure that you have removed all printing to receive credit for any assignment.