1
# drawable.rb: style objects pertaining to drawable objects.
2
# copyright (c) 2009 by Vincent Fourmond
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details (in the COPYING file).
14
require 'ctioga2/utils'
17
# This module contains all the classes used by ctioga
20
Version::register_svn_info('$Revision: 158 $', '$Date: 2010-07-23 15:03:47 +0200 (Fri, 23 Jul 2010) $')
27
# This class represents all the stylistic information to stroke
29
class StrokeStyle < BasicStyle
39
# Sets the stroke style to a FigureMaker object, _t_.
40
def set_stroke_style(t)
41
t.stroke_color = @color if @color
42
t.line_type = @style if @style
43
t.line_width = @width if @width
47
# This class represents all the stylistic information to draw a
50
# \todo many things are still missing here...
52
# * in particular, angles could be handled here, and they could
53
# be handled directly in the marker specification...
54
class MarkerStyle < BasicStyle
65
# Shows the marker at a given location/set of locations.
67
# \p override is a hash that can override part of the
68
# dictionnary specification.
69
def draw_markers_at(t, x, y, override = nil)
71
## \todo allow custom line types for markers ?
72
t.line_type = LineStyles::Solid
86
dict['scale'] = @scale
96
# A style that handles drawing a fill.
98
# \todo add ways to specify complex fills, such as patterned
99
# fills and so on. Those would use clipping the path and base
100
# themselves on the coordinates of the current frame.
102
# \todo more attributes ?
103
class FillStyle < BasicStyle
109
attr_accessor :transparency
111
# Sets up the parameters for the fill. Must be called before
114
# \warning You *must* call FillStyle#do_fill for
115
# filling. Directly calling FigureMaker#fill is not a good
116
# idea, as you lose all 'hand-crafted' fills !
118
t.fill_color = @color if @color
119
t.fill_transparency = @transparency if @transparency
122
# Does the actual filling step. Must be used within a context,
123
# as it quite messes up with many things. Must be called after
124
# a call to #setup_fill.
131
# Same as FillStyle, but with additional parameters that handle
132
# how the fill should be applied to curves.
133
class CurveFillStyle < FillStyle
135
# At which Y value we should draw the horizontal line for the
136
# fill ? A float, or:
138
# * false, nil to disable filling altogether