Class: Origami::Graphics::State
- Inherits:
-
Object
- Object
- Origami::Graphics::State
- Defined in:
- lib/origami/graphics/state.rb,
lib/origami/graphics/colors.rb
Instance Attribute Summary collapse
-
#alpha_constant ⇒ Object
Returns the value of attribute alpha_constant.
-
#alpha_source ⇒ Object
Returns the value of attribute alpha_source.
-
#blend_mode ⇒ Object
Returns the value of attribute blend_mode.
-
#clipping_path ⇒ Object
Returns the value of attribute clipping_path.
-
#ctm ⇒ Object
Device-independent parameters.
-
#current_path ⇒ Object
readonly
Returns the value of attribute current_path.
-
#dash_pattern ⇒ Object
Returns the value of attribute dash_pattern.
-
#line_cap ⇒ Object
Returns the value of attribute line_cap.
-
#line_join ⇒ Object
Returns the value of attribute line_join.
-
#line_width ⇒ Object
Returns the value of attribute line_width.
-
#miter_limit ⇒ Object
Returns the value of attribute miter_limit.
-
#nonstroking_color ⇒ Object
Returns the value of attribute nonstroking_color.
-
#nonstroking_colorspace ⇒ Object
Returns the value of attribute nonstroking_colorspace.
-
#rendering_intent ⇒ Object
Returns the value of attribute rendering_intent.
-
#soft_mask ⇒ Object
Returns the value of attribute soft_mask.
-
#stroke_adjustment ⇒ Object
Returns the value of attribute stroke_adjustment.
-
#stroking_color ⇒ Object
Returns the value of attribute stroking_color.
-
#stroking_colorspace ⇒ Object
Returns the value of attribute stroking_colorspace.
-
#text_state ⇒ Object
Returns the value of attribute text_state.
Instance Method Summary collapse
-
#initialize ⇒ State
constructor
A new instance of State.
- #reset ⇒ Object
- #restore ⇒ Object
- #save ⇒ Object
- #set_nonstroking_color(color, space = @nonstroking_colorspace) ⇒ Object
- #set_nonstroking_colorspace(space) ⇒ Object
- #set_stroking_color(color, space = @stroking_color_space) ⇒ Object
- #set_stroking_colorspace(space) ⇒ Object
Constructor Details
Instance Attribute Details
#alpha_constant ⇒ Object
Returns the value of attribute alpha_constant.
40 41 42 |
# File 'lib/origami/graphics/state.rb', line 40 def alpha_constant @alpha_constant end |
#alpha_source ⇒ Object
Returns the value of attribute alpha_source.
40 41 42 |
# File 'lib/origami/graphics/state.rb', line 40 def alpha_source @alpha_source end |
#blend_mode ⇒ Object
Returns the value of attribute blend_mode.
40 41 42 |
# File 'lib/origami/graphics/state.rb', line 40 def blend_mode @blend_mode end |
#clipping_path ⇒ Object
Returns the value of attribute clipping_path.
34 35 36 |
# File 'lib/origami/graphics/state.rb', line 34 def clipping_path @clipping_path end |
#ctm ⇒ Object
Device-independent parameters.
33 34 35 |
# File 'lib/origami/graphics/state.rb', line 33 def ctm @ctm end |
#current_path ⇒ Object (readonly)
Returns the value of attribute current_path.
42 43 44 |
# File 'lib/origami/graphics/state.rb', line 42 def current_path @current_path end |
#dash_pattern ⇒ Object
Returns the value of attribute dash_pattern.
37 38 39 |
# File 'lib/origami/graphics/state.rb', line 37 def dash_pattern @dash_pattern end |
#line_cap ⇒ Object
Returns the value of attribute line_cap.
37 38 39 |
# File 'lib/origami/graphics/state.rb', line 37 def line_cap @line_cap end |
#line_join ⇒ Object
Returns the value of attribute line_join.
37 38 39 |
# File 'lib/origami/graphics/state.rb', line 37 def line_join @line_join end |
#line_width ⇒ Object
Returns the value of attribute line_width.
37 38 39 |
# File 'lib/origami/graphics/state.rb', line 37 def line_width @line_width end |
#miter_limit ⇒ Object
Returns the value of attribute miter_limit.
37 38 39 |
# File 'lib/origami/graphics/state.rb', line 37 def miter_limit @miter_limit end |
#nonstroking_color ⇒ Object
Returns the value of attribute nonstroking_color.
35 36 37 |
# File 'lib/origami/graphics/state.rb', line 35 def nonstroking_color @nonstroking_color end |
#nonstroking_colorspace ⇒ Object
Returns the value of attribute nonstroking_colorspace.
35 36 37 |
# File 'lib/origami/graphics/state.rb', line 35 def nonstroking_colorspace @nonstroking_colorspace end |
#rendering_intent ⇒ Object
Returns the value of attribute rendering_intent.
38 39 40 |
# File 'lib/origami/graphics/state.rb', line 38 def rendering_intent @rendering_intent end |
#soft_mask ⇒ Object
Returns the value of attribute soft_mask.
40 41 42 |
# File 'lib/origami/graphics/state.rb', line 40 def soft_mask @soft_mask end |
#stroke_adjustment ⇒ Object
Returns the value of attribute stroke_adjustment.
39 40 41 |
# File 'lib/origami/graphics/state.rb', line 39 def stroke_adjustment @stroke_adjustment end |
#stroking_color ⇒ Object
Returns the value of attribute stroking_color.
35 36 37 |
# File 'lib/origami/graphics/state.rb', line 35 def stroking_color @stroking_color end |
#stroking_colorspace ⇒ Object
Returns the value of attribute stroking_colorspace.
35 36 37 |
# File 'lib/origami/graphics/state.rb', line 35 def stroking_colorspace @stroking_colorspace end |
#text_state ⇒ Object
Returns the value of attribute text_state.
36 37 38 |
# File 'lib/origami/graphics/state.rb', line 36 def text_state @text_state end |
Instance Method Details
#reset ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/origami/graphics/state.rb', line 52 def reset @ctm = Matrix.identity(3) @clipping_path = nil @stroking_colorspace = @nonstroking_colorspace = Color::Space::DEVICE_GRAY @stroking_color = @nonstroking_color = [ 0.0 ] #black @text_state.reset @line_width = 1.0 @line_cap = LineCapStyle::BUTT_CAP @line_join = LineJoinStyle::MITER_JOIN @miter_limit = 10.0 @dash_pattern = DashPattern.new([], 0) @rendering_intent = Color::Intent::RELATIVE @stroke_adjustment = false @blend_mode = Color::BlendMode::NORMAL @soft_mask = :None @alpha_constant = 1.0 @alpha_source = false end |
#restore ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/origami/graphics/state.rb', line 85 def restore raise GraphicsStateError, "Cannot restore context : empty stack" if @stack.empty? @ctm, @clipping_path, @stroking_colorspace, @nonstroking_colorspace, @stroking_color, @nonstroking_color, @text_state, @line_width, @line_cap, @line_join, @miter_limit, @dash_pattern, @rendering_intent, @stroke_adjustment, @blend_mode, @soft_mask, @alpha_constant, @alpha_source = @stack.pop end |
#save ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/origami/graphics/state.rb', line 71 def save context = [ @ctm, @clipping_path, @stroking_colorspace, @nonstroking_colorspace, @stroking_color, @nonstroking_color, @text_state, @line_width, @line_cap, @line_join, @miter_limit, @dash_pattern, @rendering_intent, @stroke_adjustment, @blend_mode, @soft_mask, @alpha_constant, @alpha_source ] @stack.push(context) end |
#set_nonstroking_color(color, space = @nonstroking_colorspace) ⇒ Object
139 140 141 142 143 144 |
# File 'lib/origami/graphics/colors.rb', line 139 def set_nonstroking_color(color, space = @nonstroking_colorspace) check_color(space, color) @nonstroking_colorspace = space @nonstroking_color = color end |
#set_nonstroking_colorspace(space) ⇒ Object
152 153 154 155 156 |
# File 'lib/origami/graphics/colors.rb', line 152 def set_nonstroking_colorspace(space) check_color_space(space, @nonstroking_color) @nonstroking_color_space = space end |
#set_stroking_color(color, space = @stroking_color_space) ⇒ Object
132 133 134 135 136 137 |
# File 'lib/origami/graphics/colors.rb', line 132 def set_stroking_color(color, space = @stroking_color_space) check_color(space, color) @stroking_colorspace = space @stroking_color = color end |
#set_stroking_colorspace(space) ⇒ Object
146 147 148 149 150 |
# File 'lib/origami/graphics/colors.rb', line 146 def set_stroking_colorspace(space) check_color_space(space, @stroking_color) @stroking_color_space = space end |