Difference between revisions of "Render Part C Assignment"

From CSE425S Wiki
Jump to navigation Jump to search
Line 43: Line 43:
 
===calculate_local_bounds===
 
===calculate_local_bounds===
 
Returns an instance of Bounds specified by min and max instances of <code>Point2</code>.
 
Returns an instance of Bounds specified by min and max instances of <code>Point2</code>.
 +
 +
NOTE: this method must be private.
  
 
[[File:Rectangle_bounds.png]]
 
[[File:Rectangle_bounds.png]]
 
 
==Ellipse==
 
==Ellipse==
 
{{RubyToEvolve|ellipse|render/assignment|Ellipse|ColorTransform|Ø|calculate_local_bounds|Ø}}
 
{{RubyToEvolve|ellipse|render/assignment|Ellipse|ColorTransform|Ø|calculate_local_bounds|Ø}}
Line 51: Line 52:
 
===calculate_local_bounds===
 
===calculate_local_bounds===
 
Returns an instance of Bounds specified by min and max instances of <code>Point2</code>.
 
Returns an instance of Bounds specified by min and max instances of <code>Point2</code>.
 +
 +
NOTE: this method must be private.
  
 
[[File:Ellipse bounds.png]]
 
[[File:Ellipse bounds.png]]
Line 59: Line 62:
 
===calculate_local_bounds===
 
===calculate_local_bounds===
 
Returns an instance of Bounds specified by min and max instances of <code>Point2</code>.
 
Returns an instance of Bounds specified by min and max instances of <code>Point2</code>.
 +
 +
NOTE: this method must be private.
  
 
[[File:Equilateral triangle bounds.png]]
 
[[File:Equilateral triangle bounds.png]]
Line 66: Line 71:
  
 
===calculate_local_bounds===
 
===calculate_local_bounds===
 +
NOTE: this method must be private.
 +
 
  <nowiki>  def calculate_local_bounds
 
  <nowiki>  def calculate_local_bounds
 
     raise :not_yet_implemented
 
     raise :not_yet_implemented
Line 74: Line 81:
  
 
===calculate_local_bounds===
 
===calculate_local_bounds===
 +
NOTE: this method must be private.
 +
 
  <nowiki>  def calculate_local_bounds
 
  <nowiki>  def calculate_local_bounds
 
     raise :not_yet_implemented
 
     raise :not_yet_implemented
Line 82: Line 91:
  
 
===calculate_local_bounds===
 
===calculate_local_bounds===
 +
NOTE: this method must be private.
 +
 
  <nowiki>  def calculate_local_bounds
 
  <nowiki>  def calculate_local_bounds
 
     raise :not_yet_implemented
 
     raise :not_yet_implemented
Line 90: Line 101:
  
 
===calculate_local_bounds===
 
===calculate_local_bounds===
 +
NOTE: this method must be private.
 +
 
  <nowiki>  def calculate_local_bounds
 
  <nowiki>  def calculate_local_bounds
 
     raise :not_yet_implemented
 
     raise :not_yet_implemented
Line 95: Line 108:
  
 
==CompositeTransform==
 
==CompositeTransform==
 +
{{RubyToEvolve|composite_transform|render/assignment|CompositeTransform|Transform|Ø|calculate_local_bounds|Ø}}
 +
 
===calculate_local_bounds===
 
===calculate_local_bounds===
 +
Returns an instance of Bounds specified by min and max instances of <code>Point2</code>.
 +
 +
NOTE: this method must be private.
 +
 +
[[File:Composite transform bounds.png]]
  
 
==Scene==
 
==Scene==

Revision as of 20:21, 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

Bounds

file: src/main/ruby/render/assignment/bounds.rb Ruby logo.svg
class: Bounds
superclass: Object
methods: '

Note: min and max should be instances of Point2.

Note: You may wish to use Ruby's convenient Struct construct.

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

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 Ruby logo.svg
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 instances of Point2.

NOTE: this method must be private.

Rectangle bounds.png

Ellipse

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

NOTE: this method must be private.

Ellipse bounds.png

EquilateralTriangle

file: src/main/ruby/render/assignment/equilateral_triangle.rb Ruby logo.svg
class: EquilateralTriangle
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 instances of Point2.

NOTE: this method must be private.

Equilateral triangle bounds.png

BezierCurve

file: src/main/ruby/render/assignment/bezier_curve.rb Ruby logo.svg
class: BezierCurve
superclass: ColorTransform
methods to evolve: Ø
methods to add: calculate_local_bounds
methods to remove: Ø

calculate_local_bounds

NOTE: this method must be private.

  def calculate_local_bounds
    raise :not_yet_implemented
  end

Text

file: src/main/ruby/render/assignment/text.rb Ruby logo.svg
class: Text
superclass: ColorTransform
methods to evolve: Ø
methods to add: calculate_local_bounds
methods to remove: Ø

calculate_local_bounds

NOTE: this method must be private.

  def calculate_local_bounds
    raise :not_yet_implemented
  end

Chord

file: src/main/ruby/render/assignment/chord.rb Ruby logo.svg
class: Chord
superclass: ColorTransform
methods to evolve: Ø
methods to add: calculate_local_bounds
methods to remove: Ø

calculate_local_bounds

NOTE: this method must be private.

  def calculate_local_bounds
    raise :not_yet_implemented
  end

Image

file: src/main/ruby/render/assignment/image.rb Ruby logo.svg
class: Image
superclass: Transform
methods to evolve: Ø
methods to add: calculate_local_bounds
methods to remove: Ø

calculate_local_bounds

NOTE: this method must be private.

  def calculate_local_bounds
    raise :not_yet_implemented
  end

CompositeTransform

file: src/main/ruby/render/assignment/composite_transform.rb Ruby logo.svg
class: CompositeTransform
superclass: Transform
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 instances of Point2.

NOTE: this method must be private.

Composite transform bounds.png

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.