Class: RubyPost::Clip
- Inherits:
-
BaseDrawCommand
- Object
- Object
- BaseDrawCommand
- RubyPost::Clip
- Defined in:
- lib/draw.rb
Overview
This wraps the metapost clipping command. This needs to be used with a little care. It will clip everything that has been previously added to the picture when you add it. Anything that gets drawn after clipping, wont be clipped. This is in keeping with the way that metapost works, however most other objects in rubypost the order inwhich they are added has no effect (other than overlay). <br> Clip only kind of fits as a draw command. It’s doesn’t need colours and stuff. This is the best place to put it at the moment, but it probably should inheret something else.
Instance Attribute Summary collapse
-
#path ⇒ Object
writeonly
Sets the attribute path.
-
#picture ⇒ Object
writeonly
Sets the attribute picture.
Attributes inherited from BaseDrawCommand
Instance Method Summary collapse
- #compile ⇒ Object
-
#initialize(path = nil, pic = 'currentpicture') ⇒ Clip
constructor
A new instance of Clip.
-
#set_path(p) ⇒ Object
set the clipping path.
-
#set_picture(p = 'currentpicture') ⇒ Object
set the picture to clip.
Methods inherited from BaseDrawCommand
#add_option, #color, #colour, #compile_options, #rotate, #scale, #set_drawable, #translate
Constructor Details
#initialize(path = nil, pic = 'currentpicture') ⇒ Clip
Returns a new instance of Clip.
127 128 129 130 131 |
# File 'lib/draw.rb', line 127 def initialize(path=nil, pic='currentpicture') super() @picture = pic @path = path end |
Instance Attribute Details
#path=(value) ⇒ Object (writeonly)
Sets the attribute path
125 126 127 |
# File 'lib/draw.rb', line 125 def path=(value) @path = value end |
#picture=(value) ⇒ Object (writeonly)
Sets the attribute picture
125 126 127 |
# File 'lib/draw.rb', line 125 def picture=(value) @picture = value end |
Instance Method Details
#compile ⇒ Object
143 144 145 |
# File 'lib/draw.rb', line 143 def compile "clip " + @picture.compile + " to " + @path.compile + ' ' + + ";\n" end |
#set_path(p) ⇒ Object
set the clipping path
134 135 136 |
# File 'lib/draw.rb', line 134 def set_path(p) @path = p end |
#set_picture(p = 'currentpicture') ⇒ Object
set the picture to clip. Defaults to ‘currentpicture’ see a metapost guide
139 140 141 |
# File 'lib/draw.rb', line 139 def set_picture(p='currentpicture') @picture = p end |