Class: Origami::Template::AxialGradient

Inherits:
Graphics::Pattern::Shading::Axial show all
Defined in:
lib/origami/template/patterns.rb

Constant Summary

Constants included from StandardObject

StandardObject::DEFAULT_ATTRIBUTES

Constants inherited from Dictionary

Dictionary::TOKENS

Constants included from Object

Object::TOKENS

Instance Attribute Summary

Attributes inherited from Dictionary

#names_cache, #strings_cache, #xref_cache

Attributes included from Object

#file_offset, #generation, #no, #objstm_offset, #parent

Instance Method Summary collapse

Methods included from Graphics::Pattern::Shading::ShadingObject

included

Methods included from StandardObject

included, #pre_build, #version_required

Methods inherited from Dictionary

#[], #[]=, add_type_signature, #cast_to, #copy, #delete, guess_type, hint_type, #key?, #map!, #merge, parse, #to_h, #to_obfuscated_str, #to_s

Methods included from FieldAccessor

#method_missing, #respond_to_missing?

Methods included from Object

#<=>, #cast_to, #copy, #document, #export, included, #indirect?, #indirect_parent, #logicalize, #logicalize!, #native_type, parse, #post_build, #pre_build, #reference, #set_document, #set_indirect, skip_until_next_obj, #solve, #to_o, #to_s, #type, typeof, #version_required, #xrefs

Constructor Details

#initialize(from, to, color0, color1, coeff = 1) ⇒ AxialGradient

Returns a new instance of AxialGradient.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/origami/template/patterns.rb', line 26

def initialize(from, to, color0, color1, coeff = 1)
    super()

    set_indirect(true)

    x, y  = from
    tx, ty = to

    c0 = Graphics::Color.to_a(color0)
    c1 = Graphics::Color.to_a(color1)

    space =
    case c0.size
    when 1 then Graphics::Color::Space::DEVICE_GRAY
    when 3 then Graphics::Color::Space::DEVICE_RGB
    when 4 then Graphics::Color::Space::DEVICE_CMYK
    end

    f = Function::Exponential.new
    f.Domain = [ 0.0, 1.0 ]
    f.N = coeff
    f.C0, f.C1 = c0, c1

    self.ColorSpace = space
    self.Coords = [ x, y, tx, ty ]
    self.Function = f
    self.Extend = [ true, true ]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Origami::FieldAccessor