dyi 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +674 -0
- data/README +28 -0
- data/examples/class_diagram.rb +151 -0
- data/examples/data/03311056.xlsx +0 -0
- data/examples/data/currency.xlsx +0 -0
- data/examples/data/money.csv +12 -0
- data/examples/line_and_bar.rb +26 -0
- data/examples/line_chart.rb +30 -0
- data/examples/logo.rb +68 -0
- data/examples/pie_chart.rb +19 -0
- data/examples/simple_shapes.rb +15 -0
- data/lib/dyi.rb +49 -0
- data/lib/dyi/chart.rb +34 -0
- data/lib/dyi/chart/array_reader.rb +136 -0
- data/lib/dyi/chart/base.rb +580 -0
- data/lib/dyi/chart/csv_reader.rb +93 -0
- data/lib/dyi/chart/excel_reader.rb +100 -0
- data/lib/dyi/chart/line_chart.rb +468 -0
- data/lib/dyi/chart/pie_chart.rb +141 -0
- data/lib/dyi/chart/table.rb +201 -0
- data/lib/dyi/color.rb +218 -0
- data/lib/dyi/coordinate.rb +224 -0
- data/lib/dyi/drawing.rb +32 -0
- data/lib/dyi/drawing/canvas.rb +100 -0
- data/lib/dyi/drawing/clipping.rb +61 -0
- data/lib/dyi/drawing/color_effect.rb +118 -0
- data/lib/dyi/drawing/filter.rb +74 -0
- data/lib/dyi/drawing/pen.rb +231 -0
- data/lib/dyi/drawing/pen_3d.rb +270 -0
- data/lib/dyi/font.rb +132 -0
- data/lib/dyi/formatter.rb +36 -0
- data/lib/dyi/formatter/base.rb +245 -0
- data/lib/dyi/formatter/emf_formatter.rb +253 -0
- data/lib/dyi/formatter/eps_formatter.rb +397 -0
- data/lib/dyi/formatter/svg_formatter.rb +260 -0
- data/lib/dyi/formatter/svg_reader.rb +113 -0
- data/lib/dyi/formatter/xaml_formatter.rb +317 -0
- data/lib/dyi/length.rb +399 -0
- data/lib/dyi/matrix.rb +122 -0
- data/lib/dyi/painting.rb +177 -0
- data/lib/dyi/shape.rb +1332 -0
- data/lib/dyi/svg_element.rb +149 -0
- data/lib/dyi/type.rb +104 -0
- data/lib/ironruby.rb +326 -0
- data/lib/util.rb +231 -0
- data/test/path_command_test.rb +217 -0
- data/test/test_length.rb +91 -0
- metadata +114 -0
data/README
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
= DYI: A Library to Create Vector-Images.
|
2
|
+
|
3
|
+
DYI is a 2D graphics library, very rich and expressive.
|
4
|
+
DYI have been optimized for SVG format, but it is also possible
|
5
|
+
to output other format; for example, EPS.
|
6
|
+
|
7
|
+
== License
|
8
|
+
|
9
|
+
Copyright (c) 2009-2011 Sound-F Co., Ltd. All rights reserved.
|
10
|
+
|
11
|
+
DYI is free software: you can redistribute it and/or modify it
|
12
|
+
under the terms of the GNU General Public License as published by
|
13
|
+
the Free Software Foundation, either version 3 of the License, or
|
14
|
+
(at your option) any later version.
|
15
|
+
|
16
|
+
DYI is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
+
GNU General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU General Public License
|
22
|
+
along with DYI. If not, see <http://www.gnu.org/licenses/>.
|
23
|
+
|
24
|
+
== Support
|
25
|
+
|
26
|
+
We plan to make up a mailing list for support of DYI ,but it is
|
27
|
+
under construction.
|
28
|
+
We're going to set up it in a few days.
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require '../lib/dyi'
|
2
|
+
|
3
|
+
class ClassBox
|
4
|
+
def initialize class_name
|
5
|
+
@name = class_name
|
6
|
+
@width = @name.length * 12
|
7
|
+
@height = 30
|
8
|
+
@children = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def draw(canvas, pen, top_left_point, horizontal_span = 5)
|
12
|
+
@top_left_point_x = top_left_point[0]
|
13
|
+
@top_left_point_y = top_left_point[1]
|
14
|
+
pen.draw_rectangle(canvas, top_left_point, @width, @height)
|
15
|
+
pen.draw_text(canvas, [@top_left_point_x+@name.length * 2.5, @top_left_point_y+@height*3.0/4.0], @name)
|
16
|
+
|
17
|
+
total_width = 0
|
18
|
+
@children.each do |child|
|
19
|
+
total_width += child.width + horizontal_span
|
20
|
+
end
|
21
|
+
total_width -= horizontal_span
|
22
|
+
|
23
|
+
position_x = @top_left_point_x + @width/2.0 - total_width/2.0
|
24
|
+
@children.each_with_index do |child, i|
|
25
|
+
child.draw(canvas, pen, [position_x, @top_left_point_y+@height+30])
|
26
|
+
pen.draw_arrow(canvas, child.get_top_center, [get_arrowhead_pos_x(i), @top_left_point_y+@height])
|
27
|
+
position_x += child.width + horizontal_span
|
28
|
+
end
|
29
|
+
self
|
30
|
+
end
|
31
|
+
|
32
|
+
def extends parent
|
33
|
+
parent.pushChildren self
|
34
|
+
self
|
35
|
+
end
|
36
|
+
|
37
|
+
def pushChildren child
|
38
|
+
@children.push child
|
39
|
+
end
|
40
|
+
|
41
|
+
def width
|
42
|
+
@width
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_top_center
|
46
|
+
[@top_left_point_x + @width/2.0, @top_left_point_y]
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_bottom_center
|
50
|
+
[@top_left_point_x + @width/2.0, @top_left_point_y + @height]
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def get_arrowhead_pos_x index
|
56
|
+
@top_left_point_x+(index+1)*@width/(@children.length+1)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class ArrowPen < DYI::Drawing::Pen
|
61
|
+
def draw_arrow(canvas, start_point, end_point, headsize = 5)
|
62
|
+
start_point = DYI::Coordinate.new(start_point)
|
63
|
+
end_point = DYI::Coordinate.new(end_point)
|
64
|
+
total_length = DYI::Length.new(start_point.distance(end_point))
|
65
|
+
end_point_no_rotate = DYI::Coordinate.new(start_point.x + total_length, start_point.y)
|
66
|
+
|
67
|
+
rotate_value = Math.atan2(end_point.y - start_point.y, end_point.x - start_point.x) * 360.0 / (2*Math::PI)
|
68
|
+
|
69
|
+
draw_line(canvas, start_point, end_point_no_rotate).rotate(rotate_value, start_point)
|
70
|
+
draw_polygon(canvas, end_point_no_rotate){|line|
|
71
|
+
line.line_to([-headsize, -headsize], true)
|
72
|
+
line.line_to([0, 2*headsize], true)
|
73
|
+
line.line_to([headsize, -headsize], true)
|
74
|
+
}.rotate(rotate_value, start_point)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
canvas = DYI::Drawing::Canvas.new 1300, 1300
|
79
|
+
|
80
|
+
pen = ArrowPen.new
|
81
|
+
dashed_pen = ArrowPen.new(:stroke_dasharray => [3])
|
82
|
+
|
83
|
+
base_class = ClassBox.new('Base')
|
84
|
+
ClassBox.new('Table').extends(base_class)
|
85
|
+
ClassBox.new('PieChart').extends(base_class)
|
86
|
+
ClassBox.new('LineChart').extends(base_class)
|
87
|
+
|
88
|
+
pen.draw_rectangle(canvas, [30,10], 530, 260)
|
89
|
+
pen.draw_text(canvas, [60, 30], 'DYI::Chart')
|
90
|
+
base_class.draw(canvas, pen, [200,30])
|
91
|
+
legend = ClassBox.new('Legend').draw(canvas, pen, [350,30])
|
92
|
+
axis_util = ClassBox.new('AxisUtil').draw(canvas, pen, [450,30])
|
93
|
+
dashed_pen.draw_arrow(canvas, [200,90], legend.get_bottom_center)
|
94
|
+
dashed_pen.draw_arrow(canvas, [310,90], axis_util.get_bottom_center)
|
95
|
+
|
96
|
+
array_reader = ClassBox.new('ArrayReader')
|
97
|
+
ClassBox.new('CsvReader').extends(array_reader)
|
98
|
+
ClassBox.new('ExcelReader').extends(array_reader)
|
99
|
+
|
100
|
+
array_reader.draw(canvas, pen, [200, 170])
|
101
|
+
|
102
|
+
base_class = ClassBox.new('Base')
|
103
|
+
ClassBox.new('EpsFormatter').extends(base_class)
|
104
|
+
xml_formatter = ClassBox.new('XmlFormatter').extends(base_class)
|
105
|
+
ClassBox.new('EmfFormatter').extends(base_class)
|
106
|
+
ClassBox.new('SvgFormatter').extends(xml_formatter)
|
107
|
+
ClassBox.new('XamlFormatter').extends(xml_formatter)
|
108
|
+
|
109
|
+
pen.draw_rectangle(canvas, [30, 300], 480, 230)
|
110
|
+
pen.draw_text(canvas, [230, 320], 'DYI::Formatter')
|
111
|
+
base_class.draw(canvas, pen, [250,330])
|
112
|
+
|
113
|
+
pen_base_class = ClassBox.new('PenBase')
|
114
|
+
brush = ClassBox.new('Brush').extends(pen_base_class)
|
115
|
+
pen_class = ClassBox.new('Pen').extends(pen_base_class)
|
116
|
+
ClassBox.new('CylinderBrush').extends(brush)
|
117
|
+
ClassBox.new('CubicPen').extends(pen_class)
|
118
|
+
|
119
|
+
pen.draw_rectangle(canvas, [540, 300], 400, 230)
|
120
|
+
pen.draw_text(canvas, [730, 320], 'DYI::Drawing')
|
121
|
+
pen_base_class.draw(canvas, pen, [650,330], 90)
|
122
|
+
ClassBox.new('Canvas').draw(canvas, pen, [800,350])
|
123
|
+
|
124
|
+
comparable_class = ClassBox.new('Comparable').draw(canvas, pen, [50, 550])
|
125
|
+
|
126
|
+
pen.draw_rectangle(canvas, [30, 620], 270, 180)
|
127
|
+
pen.draw_text(canvas, [130, 640], 'DYI')
|
128
|
+
ClassBox.new('Length').draw(canvas, pen, [50, 650])
|
129
|
+
ClassBox.new('Coordinate').draw(canvas, pen, [150, 650])
|
130
|
+
ClassBox.new('Color').draw(canvas, pen, [50, 700])
|
131
|
+
ClassBox.new('Font').draw(canvas, pen, [200, 700])
|
132
|
+
ClassBox.new('Painting').draw(canvas, pen, [80, 750])
|
133
|
+
pen.draw_arrow(canvas, [122, 665], [150, 665])
|
134
|
+
dashed_pen.draw_arrow(canvas, [110, 650], comparable_class.get_bottom_center)
|
135
|
+
|
136
|
+
base_class = ClassBox.new('Base')
|
137
|
+
ClassBox.new('Rectangle').extends(base_class)
|
138
|
+
ClassBox.new('Circle').extends(base_class)
|
139
|
+
ClassBox.new('Ellipse').extends(base_class)
|
140
|
+
ClassBox.new('Line').extends(base_class)
|
141
|
+
polyline = ClassBox.new('Polyline').extends(base_class)
|
142
|
+
ClassBox.new('Path').extends(base_class)
|
143
|
+
ClassBox.new('Text').extends(base_class)
|
144
|
+
ClassBox.new('ShapeGroup').extends(base_class)
|
145
|
+
ClassBox.new('Polygon').extends(polyline)
|
146
|
+
|
147
|
+
pen.draw_rectangle(canvas, [310, 600], 770, 200)
|
148
|
+
pen.draw_text(canvas, [730, 620], 'DYI::Shape')
|
149
|
+
base_class.draw(canvas, pen, [650,630])
|
150
|
+
|
151
|
+
canvas.save 'output/test.svg'
|
Binary file
|
Binary file
|
@@ -0,0 +1,12 @@
|
|
1
|
+
1998,550804,5919793,#008000
|
2
|
+
1999,589375,6153010,#008000
|
3
|
+
2000,658350,6330959,#008000
|
4
|
+
2001,667725,6478207,#008000
|
5
|
+
2002,910393,6707326,#008000
|
6
|
+
2003,1015445,6767064,#ffa500
|
7
|
+
2004,1082958,6891878,#ffa500
|
8
|
+
2005,1115568,7015353,#ffa500
|
9
|
+
2006,1035779,7129107,#ffa500
|
10
|
+
2007,908926,7210963,#ffa500
|
11
|
+
2008,883589,7345795,#ffa500
|
12
|
+
2009,956238,7542049,#ffa500
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: UTF-8 -*-
|
2
|
+
|
3
|
+
require '../lib/dyi'
|
4
|
+
|
5
|
+
chart = DYI::Chart::LineChart.new 800,500,
|
6
|
+
:use_y_second_axises => [true, nil],
|
7
|
+
:chart_margins => {:left => 80, :right => 70, :bottom => 50},
|
8
|
+
:axis_format => '#,##0',
|
9
|
+
:axis_settings => {:min => 4000000},
|
10
|
+
:max_x_label_count => 20,
|
11
|
+
:data_columns => [0, 1],
|
12
|
+
:chart_types => [:line, :bar],
|
13
|
+
:line_width => 3,
|
14
|
+
:show_dropshadow => true,
|
15
|
+
:color_columns => [nil, 2],
|
16
|
+
# :represent_3d => true,
|
17
|
+
# :_3d_settings => {:dx => 30, :dy => -10},
|
18
|
+
:show_legend => false,
|
19
|
+
:legend_point => [50, 480]
|
20
|
+
|
21
|
+
reader = DYI::Chart::CsvReader.read('data/money.csv', :data_types => [:number, :number, :string], :title_column=>0, :column_skip => 1)
|
22
|
+
chart.load_data reader
|
23
|
+
|
24
|
+
chart.save 'output/test.svg'
|
25
|
+
chart.save 'output/test.eps', :eps
|
26
|
+
chart.save 'output/test.emf', :emf if defined? IRONRUBY_VERSION
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: UTF-8 -*-
|
2
|
+
|
3
|
+
require '../lib/dyi'
|
4
|
+
|
5
|
+
gr = DYI::Drawing::ColorEffect::LinearGradient.new([0,0],[0,1])
|
6
|
+
gr.add_color(0, '#8FD3F5')
|
7
|
+
gr.add_color(1, '#D5EEF2')
|
8
|
+
|
9
|
+
chart = DYI::Chart::LineChart.new 720,300,
|
10
|
+
# :represent_3d => true,
|
11
|
+
:axis_format => '#,##0',
|
12
|
+
:data_columns => [0, 3, 1],
|
13
|
+
:use_y_second_axises => [nil, nil, true],
|
14
|
+
:chart_types => [:line, :line, :area],
|
15
|
+
:x_axis_format => '%Y/%m/%d',
|
16
|
+
:axis_font => {:font_family => 'HGPGOTHICM', :size => 12},
|
17
|
+
:show_legend => true,
|
18
|
+
# :axis_settings => {:min=>4000, :max=> 16000},
|
19
|
+
:chart_colors => ['#F68C23', '#89C549', gr],
|
20
|
+
:line_width => 3,
|
21
|
+
:legend_font => {},
|
22
|
+
:legend_texts => ['Constant value (left axis)', 'Constant value of Dividend Reinvestment (left axis)', 'Net Assets (right axis)']
|
23
|
+
|
24
|
+
reader = DYI::Chart::ExcelReader.read('data/03311056.xlsx', :sheet => 'Sheet2', :title_column=>1, :column_skip=>2, :title_row=>1, :row_skip=>2)
|
25
|
+
chart.load_data reader
|
26
|
+
|
27
|
+
chart.save 'output/test.svg'
|
28
|
+
chart.save 'output/test.xaml', :xaml
|
29
|
+
chart.save 'output/test.eps', :eps
|
30
|
+
chart.save 'output/test.emf', :emf if defined? IRONRUBY_VERSION
|
data/examples/logo.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require '../lib/dyi'
|
3
|
+
|
4
|
+
canvas = DYI::Drawing::Canvas.new(287.008, 162.637)
|
5
|
+
|
6
|
+
DYI::Drawing::Brush.new(:color=>'#51ADE2').draw_closed_path(canvas, [287.008,0]) {|path|
|
7
|
+
path.rline_to([0,162.637], [-39.41,0])
|
8
|
+
path.rcurve_to([0,-5.191], [-1.729,-107.272], [-1.729,-107.272], [-2.594,102.295], [-2.813,107.272])
|
9
|
+
path.rline_to([-3.246,0])
|
10
|
+
path.rcurve_to([0,-4.977], [-1.728,-107.272], [-1.728,-107.272], [-2.595,102.513], [-2.595,107.272])
|
11
|
+
path.rline_to([-3.245, 0])
|
12
|
+
path.rcurve_to([-0.215,-4.54], [-1.729,-107.272], [-1.729,-107.272], [-2.813,102.943], [-2.813,107.272])
|
13
|
+
path.rline_to([-3.46, 0])
|
14
|
+
path.line_to([path.current_point.x, 0])
|
15
|
+
path.line_to([287.008, path.current_point.y])
|
16
|
+
}
|
17
|
+
DYI::Drawing::Brush.new(:color=>'#325BA8').draw_closed_path(canvas, [258.475,0]) {|path|
|
18
|
+
path.rline_to([-52.793,97.971], [-0.078,64.666], [-57.073,0], [-0.071, -65.106])
|
19
|
+
path.line_to([98.671,0])
|
20
|
+
path.rline_to([92.148,0])
|
21
|
+
path.rcurve_to([-12.327,25.52], [-35.9,74.829], [-35.9,74.829], [27.034,-50.391], [40.013, -74.829])
|
22
|
+
path.rline_to([4.322,0])
|
23
|
+
path.rcurve_to([-11.461,24.221], [-37.414,78.289], [-37.414,78.289], [30.206,-55.798], [41.955,-78.289])
|
24
|
+
path.rline_to([4.111,0])
|
25
|
+
path.rcurve_to([-10.599,21.844], [-39.146,81.75], [-39.146,81.75], [33.306,-62.069], [43.687,-81.75])
|
26
|
+
}
|
27
|
+
|
28
|
+
DYI::Drawing::Brush.new(:color=>'#51ADE2').draw_closed_path(canvas, [149.875,78.938]){|path|
|
29
|
+
path.rcurve_to([0,13.193], [-2.379,25.52], [-7.353,36.552])
|
30
|
+
path.rcurve_to([-4.757,10.814], [-11.894,20.114], [-20.112,27.249])
|
31
|
+
path.rline_to([-0.216, 0])
|
32
|
+
path.rcurve_to([-9.517,7.786], [-20.113,12.76], [-31.144,15.787])
|
33
|
+
path.rcurve_to([-11.03,3.027], [-22.276,4.111], [-33.954,4.111])
|
34
|
+
path.rcurve_to([-12.76,0], [-22.276,-0.651], [-28.98,-1.514])
|
35
|
+
path.rline_to([-20.113, -2.815])
|
36
|
+
path.rcurve_to([12.327,-1.077], [34.17,-4.322], [54.5,-15.784])
|
37
|
+
path.rcurve_to([14.921,-8.219], [27.034,-21.627], [32.441,-33.524])
|
38
|
+
path.rcurve_to([5.623,-11.894], [6.271,-20.543], [6.487,-20.543])
|
39
|
+
path.rcurve_to([-0.217,0], [-1.08,8.649], [-7.137,20.114])
|
40
|
+
path.rcurve_to([-5.623,11.676], [-18.167,24.654], [-32.873,32.003])
|
41
|
+
path.curve_to([35.468,153.985], [7.354,154.414], [0,154.414])
|
42
|
+
path.rline_to([0, -3.241])
|
43
|
+
path.rcurve_to([7.137,-0.215], [34.82,-1.729], [58.827,-15.355])
|
44
|
+
path.rcurve_to([29.844,-14.921], [35.9,-49.526], [35.035,-48.661])
|
45
|
+
path.rcurve_to([0.866,-0.866], [-6.487,33.303], [-36.117,46.714])
|
46
|
+
path.curve_to([33.954,146.198], [7.137,146.847], [0,146.847])
|
47
|
+
path.rline_to([0, -3.246])
|
48
|
+
path.rcurve_to([6.92,-0.211], [33.307,-1.942], [55.15,-14.488])
|
49
|
+
path.rcurve_to([26.168,-13.193], [31.358,-41.955], [31.358,-43.254])
|
50
|
+
path.rcurve_to([0,1.299], [-6.487,29.631], [-32.44,41.311])
|
51
|
+
path.curve_to([32.44,138.412], [6.92,139.278], [0,139.278])
|
52
|
+
path.line_to([path.current_point.x, 6.704])
|
53
|
+
path.rline_to([27.25, -4.326])
|
54
|
+
path.curve_to([37.631,0.647], [49.31,0], [61.854,0])
|
55
|
+
path.rcurve_to([11.03,0], [21.194,0.864], [31.36,3.677])
|
56
|
+
path.rcurve_to([9.731,2.594], [19.464,6.92], [27.25,12.975])
|
57
|
+
path.rcurve_to([9.083,6.706], [16.868,16.006], [21.843,26.819])
|
58
|
+
path.curve_to([147.496,54.284], [149.875,66.395], [149.875,78.938])
|
59
|
+
path.close_path
|
60
|
+
|
61
|
+
path.move_to([120.678,16.868])
|
62
|
+
path.rcurve_to([0,0], [0,-0.217], [-0.214,-0.217])
|
63
|
+
path.rline_to([0.214, 0])
|
64
|
+
path.line_to([path.current_point.x, 16.868])
|
65
|
+
}
|
66
|
+
|
67
|
+
canvas.save('output/logo.svg')
|
68
|
+
canvas.save('output/logo.eps', :eps)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: UTF-8 -*-
|
2
|
+
|
3
|
+
require '../lib/dyi'
|
4
|
+
|
5
|
+
chart = DYI::Chart::PieChart.new 400,500,
|
6
|
+
:data_label_format => "{name}\n{percent}",
|
7
|
+
:represent_3d => true,
|
8
|
+
:moved_elements => [0.2,nil,nil,0.5],
|
9
|
+
:chart_colors => ['blue', 'red', 'yellow', 'green'],
|
10
|
+
:_3d_settings => {:dy => 30},
|
11
|
+
:chart_stroke_color => 'white'
|
12
|
+
|
13
|
+
reader = DYI::Chart::ExcelReader.read('data/currency.xlsx', :title_column=>0, :column_skip=>1)
|
14
|
+
chart.load_data reader
|
15
|
+
|
16
|
+
chart.save 'output/test.svg'
|
17
|
+
chart.save 'output/test.xaml', :xaml
|
18
|
+
chart.save 'output/test.eps', :eps
|
19
|
+
chart.save 'output/test.emf', :emf if defined? IRONRUBY_VERSION
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require '../lib/dyi'
|
2
|
+
|
3
|
+
canvas = DYI::Drawing::Canvas.new(500, 500)
|
4
|
+
|
5
|
+
pen = DYI::Drawing::Pen.new(:color => 'blue')
|
6
|
+
pen.draw_rectangle(canvas, [30, 30], 30, 30)
|
7
|
+
|
8
|
+
brush = DYI::Drawing::Brush.new(:color => 'rgb(255,255,127)', :width => 0)
|
9
|
+
center_point = DYI::Coordinate.new(100, 45)
|
10
|
+
brush.draw_circle(canvas, center_point, 20)
|
11
|
+
|
12
|
+
pen = DYI::Drawing::Pen.new(:color => '#CCFFCC', :width => 5)
|
13
|
+
pen.draw_line(canvas, [150,70], [80,140])
|
14
|
+
|
15
|
+
canvas.save 'output/test.svg'
|
data/lib/dyi.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# -*- encoding: UTF-8 -*-
|
2
|
+
|
3
|
+
# Copyright (c) 2009-2011 Sound-F Co., Ltd. All rights reserved.
|
4
|
+
#
|
5
|
+
# Author:: Mamoru Yuo
|
6
|
+
#
|
7
|
+
# This file is part of DYI.
|
8
|
+
#
|
9
|
+
# DYI is free software: you can redistribute it and/or modify it
|
10
|
+
# under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# DYI is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with DYI. If not, see <http://www.gnu.org/licenses/>.
|
21
|
+
|
22
|
+
|
23
|
+
module DYI
|
24
|
+
VERSION = '0.0.0'
|
25
|
+
end
|
26
|
+
|
27
|
+
%w(
|
28
|
+
|
29
|
+
util
|
30
|
+
dyi/length
|
31
|
+
dyi/coordinate
|
32
|
+
dyi/color
|
33
|
+
dyi/painting
|
34
|
+
dyi/font
|
35
|
+
dyi/matrix
|
36
|
+
dyi/type
|
37
|
+
dyi/svg_element
|
38
|
+
dyi/drawing
|
39
|
+
dyi/shape
|
40
|
+
dyi/formatter
|
41
|
+
dyi/chart
|
42
|
+
|
43
|
+
).each do |file_name|
|
44
|
+
require File.join(File.dirname(__FILE__), file_name)
|
45
|
+
end
|
46
|
+
|
47
|
+
if defined? IRONRUBY_VERSION
|
48
|
+
require File.join(File.dirname(__FILE__), 'ironruby')
|
49
|
+
end
|
data/lib/dyi/chart.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: UTF-8 -*-
|
2
|
+
|
3
|
+
# Copyright (c) 2009-2011 Sound-F Co., Ltd. All rights reserved.
|
4
|
+
#
|
5
|
+
# Author:: Mamoru Yuo
|
6
|
+
#
|
7
|
+
# This file is part of DYI.
|
8
|
+
#
|
9
|
+
# DYI is free software: you can redistribute it and/or modify it
|
10
|
+
# under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# DYI is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with DYI. If not, see <http://www.gnu.org/licenses/>.
|
21
|
+
|
22
|
+
%w(
|
23
|
+
|
24
|
+
base
|
25
|
+
line_chart
|
26
|
+
pie_chart
|
27
|
+
table
|
28
|
+
array_reader
|
29
|
+
csv_reader
|
30
|
+
excel_reader
|
31
|
+
|
32
|
+
).each do |file_name|
|
33
|
+
require File.join(File.dirname(__FILE__), 'chart', file_name)
|
34
|
+
end
|