Class: Ra::Material
- Inherits:
-
Object
- Object
- Ra::Material
- Defined in:
- lib/ra/material.rb
Overview
Instance Attribute Summary collapse
- #ambient ⇒ Float
- #base ⇒ Ra::Color, Ra::Pattern::Base
- #diffuse ⇒ Float
- #reflective ⇒ Float
- #shininess ⇒ Integer
- #specular ⇒ Float
Instance Method Summary collapse
- #color(point:) ⇒ Ra::Color
-
#initialize(base:, ambient: 0.0, diffuse: 0.8, reflective: 0.0, specular: 0.2, shininess: 80) ⇒ Material
constructor
A new instance of Material.
Constructor Details
#initialize(base:, ambient: 0.0, diffuse: 0.8, reflective: 0.0, specular: 0.2, shininess: 80) ⇒ Material
Returns a new instance of Material.
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ra/material.rb', line 44 def initialize(base:, ambient: 0.0, diffuse: 0.8, reflective: 0.0, specular: 0.2, shininess: 80) raise ArgumentError, "ambient=#{ambient} must be between 0 and 1" unless ambient.between?(0, 1) raise ArgumentError, "ambient=#{diffuse} must be between 0 and 1" unless diffuse.between?(0, 1) raise ArgumentError, "ambient=#{reflective} must be between 0 and 1" unless reflective.between?(0, 1) raise ArgumentError, "specular=#{specular} must be between 0 and 1" unless specular.between?(0, 1) @base = base @ambient = ambient @diffuse = diffuse @reflective = reflective @specular = specular @shininess = shininess end |
Instance Attribute Details
#ambient ⇒ Float
20 21 22 |
# File 'lib/ra/material.rb', line 20 def ambient @ambient end |
#base ⇒ Ra::Color, Ra::Pattern::Base
16 17 18 |
# File 'lib/ra/material.rb', line 16 def base @base end |
#diffuse ⇒ Float
24 25 26 |
# File 'lib/ra/material.rb', line 24 def diffuse @diffuse end |
#reflective ⇒ Float
28 29 30 |
# File 'lib/ra/material.rb', line 28 def reflective @reflective end |
#shininess ⇒ Integer
36 37 38 |
# File 'lib/ra/material.rb', line 36 def shininess @shininess end |
#specular ⇒ Float
32 33 34 |
# File 'lib/ra/material.rb', line 32 def specular @specular end |