Difference between revisions of "Render Part C Assignment"

From CSE425S Wiki
Jump to navigation Jump to search
Line 7: Line 7:
 
=Code to Implement=
 
=Code to Implement=
 
==Transform==
 
==Transform==
 +
{{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 29: Line 30:
  
 
==Rectangle==
 
==Rectangle==
 +
{{RubyToEvolve|rectangle|render/assignment|Rectangle|ColorTransform||calculate_local_bounds|}}
 
===calculate_local_bounds===
 
===calculate_local_bounds===
  

Revision as of 15:00, 2 December 2020

In this studio we will evolve our code from Render_Part_B_Assignment to add new methods and a new class.

Render part c class hierarchy.svg

Continue editing files in the render/assignment directory.

Code to Implement

Transform

file: src/main/ruby/render/assignment/transform.rb Ruby logo.svg
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

Rectangle

file: src/main/ruby/render/assignment/rectangle.rb Ruby logo.svg
class: Rectangle
superclass: ColorTransform
methods to evolve: '
methods to add: calculate_local_bounds
methods to remove: '

calculate_local_bounds

BezierCurve, Chord, Ellipse, EquilateralTriangle, 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 Ruby logo.svg

Unit Test

file: src/test/ruby/render/part_c/part_c_unit_test.rb Ruby logo.svg UnitTest

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 Ruby logo.svg UnitTest

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 Ruby logo.svg UnitTest

note: ensure that you have removed all printing to receive credit for any assignment.