Sha256: 13d5f4fcfc41200199a6541134195feb8ffd2bb7fbad3319b472e6345c7dbdc5

Contents?: true

Size: 1.86 KB

Versions: 4

Compression:

Stored size: 1.86 KB

Contents

# arrows.rb: style objects for lines and arrows
# copyright (c) 2012 by Vincent Fourmond
  
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
  
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details (in the COPYING file).

require 'ctioga2/utils'
require 'ctioga2/log'

# This module contains all the classes used by ctioga
module CTioga2

  Version::register_svn_info('$Revision$', '$Date$')

  module Graphics

    # All the styles
    module Styles

      # This class represents styles attached to a box
      #
      # @todo Add rounded corners and the like...
      class BoxStyle < StrokeStyle

        sub_style 'fill', FillStyle

        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

        # Draws a box around the given box, leaving dx and dy
        # around. If _dy_ is omitted, it defaults to _dx_
        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

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ctioga2-0.6.1 lib/ctioga2/graphics/styles/box.rb
ctioga2-0.6 lib/ctioga2/graphics/styles/box.rb
ctioga2-0.5 lib/ctioga2/graphics/styles/box.rb
ctioga2-0.4 lib/ctioga2/graphics/styles/box.rb