Class: Ra::Material
- Inherits:
-
Object
- Object
- Ra::Material
- Defined in:
- lib/ra/material.rb
Overview
A material is used to define the properties of an object that impact the color applied. For example:
material = Ra::Material.new(
base: Ra::Color.uniform(0.5),
ambient: 0.2,
diffuse: 0.5,
specular: 0.7,
shininess: 200,
)
Instance Attribute Summary collapse
-
#ambient ⇒ Object
Returns the value of attribute ambient.
-
#base ⇒ Object
Returns the value of attribute base.
-
#diffuse ⇒ Object
Returns the value of attribute diffuse.
-
#shininess ⇒ Object
Returns the value of attribute shininess.
-
#specular ⇒ Object
Returns the value of attribute specular.
Instance Method Summary collapse
- #color(point:) ⇒ Ra::Color
-
#initialize(base:, ambient: 0.2, diffuse: 0.6, specular: 0.6, shininess: 200) ⇒ Material
constructor
A new instance of Material.
Constructor Details
#initialize(base:, ambient: 0.2, diffuse: 0.6, specular: 0.6, shininess: 200) ⇒ Material
Returns a new instance of Material.
21 22 23 24 25 26 27 |
# File 'lib/ra/material.rb', line 21 def initialize(base:, ambient: 0.2, diffuse: 0.6, specular: 0.6, shininess: 200) @base = base @ambient = ambient @diffuse = diffuse @specular = specular @shininess = shininess end |
Instance Attribute Details
#ambient ⇒ Object
Returns the value of attribute ambient.
14 15 16 |
# File 'lib/ra/material.rb', line 14 def ambient @ambient end |
#base ⇒ Object
Returns the value of attribute base.
14 15 16 |
# File 'lib/ra/material.rb', line 14 def base @base end |
#diffuse ⇒ Object
Returns the value of attribute diffuse.
14 15 16 |
# File 'lib/ra/material.rb', line 14 def diffuse @diffuse end |
#shininess ⇒ Object
Returns the value of attribute shininess.
14 15 16 |
# File 'lib/ra/material.rb', line 14 def shininess @shininess end |
#specular ⇒ Object
Returns the value of attribute specular.
14 15 16 |
# File 'lib/ra/material.rb', line 14 def specular @specular end |
Instance Method Details
#color(point:) ⇒ Ra::Color
31 32 33 34 35 |
# File 'lib/ra/material.rb', line 31 def color(point:) return base if base.is_a?(Color) base.color(point:) end |