class DYI::Drawing::Brush
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.
@example
brush = DYI::Drawing::Brush.red_brush # the followings is the same processing # brush = DYI::Drawing::Brush.new(:color => 'red') # brush = DYI::Drawing::Brush.new(:fill => 'red') canvas = DYI::Canvas.new(100, 50) brush.draw_ellipse(canvas, [50, 25], 40, 15)
@since 0.0.0
Constants
- ALIAS_ATTRIBUTES
@private
Public Class Methods
method_missing(method_name, *args, &block)
click to toggle source
Calls superclass method
# File lib/dyi/drawing/pen.rb, line 712 def method_missing(method_name, *args, &block) if method_name.to_s =~ /([a-z]+)_brush/ if options = args.first self.new(options.merge(:fill => $1)) else self.new(:fill => $1) end else super end end
new(options={})
click to toggle source
(see PenBase#initialize) @option options [Color, write_as] :color the value of attribute {#color
color}
@option options [String] :rule the value of attribute {#rule rule}
Calls superclass method
DYI::Drawing::PenBase::new
# File lib/dyi/drawing/pen.rb, line 689 def initialize(options={}) options = options.clone ALIAS_ATTRIBUTES.each do |key, value| options[value] = options.delete(key) if options.key?(key) && !options.key?(value) end options[:stroke_width] = 0 unless options.key?(:stroke_width) options[:fill] = 'black' unless options.key?(:fill) super end