class PBRT::Texture
Attributes
args[R]
Public Class Methods
new(builder, *args)
click to toggle source
# File lib/pbrt/texture.rb, line 9 def initialize(builder, *args) @builder = builder @args = args end
raise_ambiguous_error(value)
click to toggle source
# File lib/pbrt/texture.rb, line 47 def self.raise_ambiguous_error(value) message = "Please specify whether #{value.inspect} is a spectrum or texture.\n" message += "If it's a texture, wrap it with: texture(#{value.inspect})\n" message += "If it's a spectrum, wrap it with its representation: sampled(#{value.inspect})\n" message += "Valid representations are: rgb, xyz, sampled and blackbody" raise AmbiguousArgumentError, message end
string?(*value)
click to toggle source
# File lib/pbrt/texture.rb, line 56 def self.string?(*value) value.flatten.first.is_a?(String) end
unpack(type, value)
click to toggle source
# 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
Public Instance Methods
color()
click to toggle source
# File lib/pbrt/texture.rb, line 20 def color PBRT::Builder::Texture.new(@builder, args.first, "color") end
float()
click to toggle source
# File lib/pbrt/texture.rb, line 24 def float PBRT::Builder::Texture.new(@builder, args.first, "float") end
spectrum()
click to toggle source
If these three methods are called, it means the user is trying to write a Texture
directive, so delegate to that builder.
# File lib/pbrt/texture.rb, line 16 def spectrum PBRT::Builder::Texture.new(@builder, args.first, "spectrum") end