Class: CTioga2::Graphics::Styles::BoxStyle
- Inherits:
-
StrokeStyle
- Object
- BasicStyle
- StrokeStyle
- CTioga2::Graphics::Styles::BoxStyle
- Defined in:
- lib/ctioga2/graphics/styles/box.rb
Overview
TODO:
Add rounded corners and the likeā¦
This class represents styles attached to a box
Constant Summary
Constants inherited from BasicStyle
CTioga2::Graphics::Styles::BasicStyle::OldAttrAccessor
Instance Method Summary collapse
- #draw_box(t, x1, y1, x2, y2) ⇒ Object
-
#draw_box_around(t, x1, y1, x2, y2, dx, dy = nil) ⇒ Object
Draws a box around the given box, leaving dx and dy around.
Methods inherited from StrokeStyle
Methods inherited from BasicStyle
attr_accessor, attributes, from_hash, #instance_variable_defined?, options_hash, #set_from_hash, sub_style, sub_styles, #to_hash, typed_attribute, #update_from_other
Instance Method Details
#draw_box(t, x1, y1, x2, y2) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ctioga2/graphics/styles/box.rb', line 34 def draw_box(t, x1, y1, x2, y2) t.context do t.discard_path ## @todo Rounded rects! if fill && fill.color fill.setup_fill(t) t.append_rect_to_path(x1, y1, x2 - x1, y2 - y1) fill.do_fill(t) end if color set_stroke_style(t) t.append_rect_to_path(x1, y1, x2 - x1, y2 - y1) t.stroke end end end |
#draw_box_around(t, x1, y1, x2, y2, dx, dy = nil) ⇒ Object
Draws a box around the given box, leaving dx and dy around. If dy is omitted, it defaults to dx
55 56 57 58 59 60 61 |
# File 'lib/ctioga2/graphics/styles/box.rb', line 55 def draw_box_around(t, x1, y1, x2, y2, dx, dy = nil) dy ||= dx dx = dx.to_figure(t, :x) dy = dy.to_figure(t, :y) draw_box(t, x1 - dx, y1 + dy, x2 + dx, y2 - dy) end |