Class: PBRT::Texture
- Inherits:
-
Object
- Object
- PBRT::Texture
- Defined in:
- lib/pbrt/texture.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
Class Method Summary collapse
Instance Method Summary collapse
- #color ⇒ Object
- #float ⇒ Object
-
#initialize(builder, *args) ⇒ Texture
constructor
A new instance of Texture.
-
#spectrum ⇒ Object
If these three methods are called, it means the user is trying to write a Texture directive, so delegate to that builder.
Constructor Details
#initialize(builder, *args) ⇒ Texture
Returns a new instance of Texture.
9 10 11 12 |
# File 'lib/pbrt/texture.rb', line 9 def initialize(builder, *args) @builder = builder @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
7 8 9 |
# File 'lib/pbrt/texture.rb', line 7 def args @args end |
Class Method Details
.raise_ambiguous_error(value) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/pbrt/texture.rb', line 47 def self.raise_ambiguous_error(value) = "Please specify whether #{value.inspect} is a spectrum or texture.\n" += "If it's a texture, wrap it with: texture(#{value.inspect})\n" += "If it's a spectrum, wrap it with its representation: sampled(#{value.inspect})\n" += "Valid representations are: rgb, xyz, sampled and blackbody" raise AmbiguousArgumentError, end |
.string?(*value) ⇒ Boolean
56 57 58 |
# File 'lib/pbrt/texture.rb', line 56 def self.string?(*value) value.flatten.first.is_a?(String) end |
.unpack(type, value) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pbrt/texture.rb', line 28 def self.unpack(type, value) return [type, value] unless type.to_s.include?("texture") return [:texture, value.args] if value.is_a?(self) if type == :float_texture return string?(value) ? [:texture, value] : [:float, value] end if type == :spectrum_texture && !string?(value) return [:spectrum, value] end if type == :texture && !string?(value) return [:float, value] end raise_ambiguous_error(value) end |