Class: Origami::Graphics::State
- Inherits:
-
Object
- Object
- Origami::Graphics::State
- Defined in:
- lib/origami/graphics/state.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
Constructor Details
Instance Attribute Details
#alpha_constant ⇒ Object
Returns the value of attribute alpha_constant.
47 48 49 |
# File 'lib/origami/graphics/state.rb', line 47 def alpha_constant @alpha_constant end |
#alpha_source ⇒ Object
Returns the value of attribute alpha_source.
47 48 49 |
# File 'lib/origami/graphics/state.rb', line 47 def alpha_source @alpha_source end |
#blend_mode ⇒ Object
Returns the value of attribute blend_mode.
47 48 49 |
# File 'lib/origami/graphics/state.rb', line 47 def blend_mode @blend_mode end |
#clipping_path ⇒ Object
Returns the value of attribute clipping_path.
41 42 43 |
# File 'lib/origami/graphics/state.rb', line 41 def clipping_path @clipping_path end |
#ctm ⇒ Object
Device-independent parameters.
40 41 42 |
# File 'lib/origami/graphics/state.rb', line 40 def ctm @ctm end |
#current_path ⇒ Object (readonly)
Returns the value of attribute current_path.
49 50 51 |
# File 'lib/origami/graphics/state.rb', line 49 def current_path @current_path end |
#dash_pattern ⇒ Object
Returns the value of attribute dash_pattern.
44 45 46 |
# File 'lib/origami/graphics/state.rb', line 44 def dash_pattern @dash_pattern end |
#line_cap ⇒ Object
Returns the value of attribute line_cap.
44 45 46 |
# File 'lib/origami/graphics/state.rb', line 44 def line_cap @line_cap end |
#line_join ⇒ Object
Returns the value of attribute line_join.
44 45 46 |
# File 'lib/origami/graphics/state.rb', line 44 def line_join @line_join end |
#line_width ⇒ Object
Returns the value of attribute line_width.
44 45 46 |
# File 'lib/origami/graphics/state.rb', line 44 def line_width @line_width end |
#miter_limit ⇒ Object
Returns the value of attribute miter_limit.
44 45 46 |
# File 'lib/origami/graphics/state.rb', line 44 def miter_limit @miter_limit end |
#nonstroking_color ⇒ Object
Returns the value of attribute nonstroking_color.
42 43 44 |
# File 'lib/origami/graphics/state.rb', line 42 def nonstroking_color @nonstroking_color end |
#nonstroking_colorspace ⇒ Object
Returns the value of attribute nonstroking_colorspace.
42 43 44 |
# File 'lib/origami/graphics/state.rb', line 42 def nonstroking_colorspace @nonstroking_colorspace end |
#rendering_intent ⇒ Object
Returns the value of attribute rendering_intent.
45 46 47 |
# File 'lib/origami/graphics/state.rb', line 45 def rendering_intent @rendering_intent end |
#soft_mask ⇒ Object
Returns the value of attribute soft_mask.
47 48 49 |
# File 'lib/origami/graphics/state.rb', line 47 def soft_mask @soft_mask end |
#stroke_adjustment ⇒ Object
Returns the value of attribute stroke_adjustment.
46 47 48 |
# File 'lib/origami/graphics/state.rb', line 46 def stroke_adjustment @stroke_adjustment end |
#stroking_color ⇒ Object
Returns the value of attribute stroking_color.
42 43 44 |
# File 'lib/origami/graphics/state.rb', line 42 def stroking_color @stroking_color end |
#stroking_colorspace ⇒ Object
Returns the value of attribute stroking_colorspace.
42 43 44 |
# File 'lib/origami/graphics/state.rb', line 42 def stroking_colorspace @stroking_colorspace end |
#text_state ⇒ Object
Returns the value of attribute text_state.
43 44 45 |
# File 'lib/origami/graphics/state.rb', line 43 def text_state @text_state end |
Instance Method Details
#reset ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/origami/graphics/state.rb', line 60 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
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/origami/graphics/state.rb', line 95 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
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/origami/graphics/state.rb', line 81 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 |