Difference between revisions of "Render Part B Assignment"

From CSE425S Wiki
Jump to navigation Jump to search
Line 40: Line 40:
 
superclass: ColorTransform
 
superclass: ColorTransform
  
Add keyword parameters for x: 0, y: 0, and color: nil and invoke your superclass with these parameters.
+
Add keyword parameters for x: 0, y: 0, and color: nil to the constructor and pass them to the superclass.
  
 
NOTE: Be sure to not override render.  Implement the render_transformed method instead.
 
NOTE: Be sure to not override render.  Implement the render_transformed method instead.
Line 48: Line 48:
  
 
superclass: ColorTransform
 
superclass: ColorTransform
 +
 +
Add keyword parameters for x: 0, y: 0, and color: nil to the constructor and pass them to the superclass.
  
 
NOTE: Be sure to not override render.  Implement the render_transformed method instead.
 
NOTE: Be sure to not override render.  Implement the render_transformed method instead.
Line 55: Line 57:
  
 
superclass: ColorTransform
 
superclass: ColorTransform
 +
 +
Add keyword parameters for x: 0, y: 0, and color: nil to the constructor and pass them to the superclass.
  
 
NOTE: Be sure to not override render.  Implement the render_transformed method instead.
 
NOTE: Be sure to not override render.  Implement the render_transformed method instead.
Line 62: Line 66:
  
 
superclass: ColorTransform
 
superclass: ColorTransform
 +
 +
Add keyword parameters for x: 0, y: 0, and color: nil to the constructor and pass them to the superclass.
  
 
NOTE: Be sure to not override render.  Implement the render_transformed method instead.
 
NOTE: Be sure to not override render.  Implement the render_transformed method instead.
Line 69: Line 75:
  
 
superclass: ColorTransform
 
superclass: ColorTransform
 +
 +
Add keyword parameters for x: 0, y: 0, and color: nil to the constructor and pass them to the superclass.
  
 
NOTE: Be sure to not override render.  Implement the render_transformed method instead.
 
NOTE: Be sure to not override render.  Implement the render_transformed method instead.
Line 76: Line 84:
  
 
superclass: ColorTransform
 
superclass: ColorTransform
 +
 +
Add keyword parameters for x: 0, y: 0, and color: nil to the constructor and pass them to the superclass.
  
 
NOTE: Be sure to not override render.  Implement the render_transformed method instead.
 
NOTE: Be sure to not override render.  Implement the render_transformed method instead.
Line 82: Line 92:
  
 
superclass: Transform
 
superclass: Transform
 +
 +
Add a push_component method which accepts a component which will later be rendered.
 +
 +
The private render_transformed method should render each pushed component.
 +
 +
NOTE: you can inherit the constructor without change.
  
 
==class Scene==
 
==class Scene==
  
 
superclass: Object
 
superclass: Object
 +
 +
Scene's constructor should take a keyword parameter background_color: Color.new(0,0,0) and store it in an instance variable.
 +
 +
Add a push_component method which accepts a component which will later be rendered.
 +
 +
The render method should [https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glClearColor.xml set the clear color] before rendering each pushed component.
  
 
=Testing Your Solution=
 
=Testing Your Solution=

Revision as of 07:46, 15 July 2019

In this studio we will evolve our code from Render_Part_A_Assignment to leverage class hierarchies.

File:Part b class hierarchy.png

Continue editing files in the render/assignment directory.

In this studio, we will have parameters for which explicitly passed arguments are not required (for convenience and backwards compatibility). We will prefer keyword arguments over optional arguments.

Code to Implement

Transform

superclass: Object

Transform's constructor should take x and y parameters and store them in instance variables.

It should define a render method which preserves the current model view transformation, translates in the z==0 plane, passes the render_transformed message to itself, and restores the model view transformation.

All subclasses must implement a private render_transformed method.

Image

You will evolve your code from from Part A

superclass: Transform

Add keyword parameters for x: 0 and y: 0 and invoke your superclass with these parameters.

NOTE: Be sure to not override render. Implement the render_transformed method instead.

ColorTransform

superclass: Transform

ColorTransform's constructor should take x, y, and color parameters. x and y should be passed to the superclass and color should be stored in an instance variable.

NOTE: Override render. Be sure to change the color (unless it is nil) before invoking your superclass.

Text

You will evolve your code from from Part A

superclass: ColorTransform

Add keyword parameters for x: 0, y: 0, and color: nil to the constructor and pass them to the superclass.

NOTE: Be sure to not override render. Implement the render_transformed method instead.

Ellipse

You will evolve your code from from Part A

superclass: ColorTransform

Add keyword parameters for x: 0, y: 0, and color: nil to the constructor and pass them to the superclass.

NOTE: Be sure to not override render. Implement the render_transformed method instead.

EquilateralTriangle

You will evolve your code from from Part A

superclass: ColorTransform

Add keyword parameters for x: 0, y: 0, and color: nil to the constructor and pass them to the superclass.

NOTE: Be sure to not override render. Implement the render_transformed method instead.

BezierCurve

You will evolve your code from from Part A

superclass: ColorTransform

Add keyword parameters for x: 0, y: 0, and color: nil to the constructor and pass them to the superclass.

NOTE: Be sure to not override render. Implement the render_transformed method instead.

Chord

You will evolve your code from from Part A

superclass: ColorTransform

Add keyword parameters for x: 0, y: 0, and color: nil to the constructor and pass them to the superclass.

NOTE: Be sure to not override render. Implement the render_transformed method instead.

Rectangle

You will evolve your code from from Part A

superclass: ColorTransform

Add keyword parameters for x: 0, y: 0, and color: nil to the constructor and pass them to the superclass.

NOTE: Be sure to not override render. Implement the render_transformed method instead.

CompositeTransform

superclass: Transform

Add a push_component method which accepts a component which will later be rendered.

The private render_transformed method should render each pushed component.

NOTE: you can inherit the constructor without change.

class Scene

superclass: Object

Scene's constructor should take a keyword parameter background_color: Color.new(0,0,0) and store it in an instance variable.

Add a push_component method which accepts a component which will later be rendered.

The render method should set the clear color before rendering each pushed component.

Testing Your Solution

Unit Testing

ruby/render/part_b_test/part_b_unit_test.rb

Visual Comparison

ruby/render/part_b_test/part_b_test_snapshots_web_page_generator.rb