Class: DYI::Drawing::Brush
Overview
Brush
object holds a Painting object and a Font object. Using these object, Brush
object creates instances of concrete subclass of Shape::Base; a created instance has a painting attribute and a font attribute that Brush
object holds.
Brush
class has been optimized to fill a shape with a color and so on. Synonym methods of attributes fill_xxx has been defined in this class: color
(synonym of fill), rule
(synonym of fill_rule).
This class has shortcut contractors: color_name_brush, which a fill color is specified in.
Direct Known Subclasses
Constant Summary collapse
- ALIAS_ATTRIBUTES =
Painting::IMPLEMENT_ATTRIBUTES.inject({}) do |hash, key| hash[$'.empty? ? :color : $'.to_sym] = key if key.to_s =~ /^(fill_|fill$)/ && key != :fill_opacity hash end
Constants inherited from PenBase
Instance Attribute Summary collapse
-
#color ⇒ Color, ...
Synonym of attribute fill.
-
#rule ⇒ Color, ...
Synonym of attribute fill.
Attributes inherited from PenBase
#display, #drop_shadow, #fill, #fill_opacity, #fill_rule, #opacity, #stroke, #stroke_dasharray, #stroke_dashoffset, #stroke_linecap, #stroke_linejoin, #stroke_miterlimit, #stroke_opacity, #stroke_width, #visibility
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Brush
constructor
A new instance of Brush.
Methods inherited from PenBase
#draw_circle, #draw_closed_path, #draw_ellipse, #draw_image, #draw_line, #draw_line_on_direction, #draw_path, #draw_polygon, #draw_polyline, #draw_rectangle, #draw_rectangle_on_corner, #draw_sector, #draw_text, #draw_toroid, #import_image
Constructor Details
#initialize(options = {}) ⇒ Brush
Returns a new instance of Brush.
690 691 692 693 694 695 696 697 698 |
# File 'lib/dyi/drawing/pen.rb', line 690 def initialize(={}) = .clone ALIAS_ATTRIBUTES.each do |key, value| [value] = .delete(key) if .key?(key) && !.key?(value) end [:stroke_width] = 0 unless .key?(:stroke_width) [:fill] = 'black' unless .key?(:fill) super end |
Instance Attribute Details
#color ⇒ Color, ...
707 708 709 710 |
# File 'lib/dyi/drawing/pen.rb', line 707 ALIAS_ATTRIBUTES.each do |key, value| alias_method key, value alias_method "#{key}=", "#{value}=" end |
#rule ⇒ Color, ...
707 708 709 710 |
# File 'lib/dyi/drawing/pen.rb', line 707 ALIAS_ATTRIBUTES.each do |key, value| alias_method key, value alias_method "#{key}=", "#{value}=" end |
Class Method Details
.method_missing(method_name, *args, &block) ⇒ Object
713 714 715 716 717 718 719 720 721 722 723 |
# File 'lib/dyi/drawing/pen.rb', line 713 def method_missing(method_name, *args, &block) if method_name.to_s =~ /([a-z]+)_brush/ if = args.first self.new(.merge(:fill => $1)) else self.new(:fill => $1) end else super end end |