-
Notifications
You must be signed in to change notification settings - Fork 2
/
arcs02.rb.html
86 lines (74 loc) · 2.89 KB
/
arcs02.rb.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE public PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta name="generator" content="ex2html.rb" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/popup.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script>
hljs.configure({ cssSelector: "pre" });
hljs.highlightAll();
</script>
<title>RMagick example: arcs02.rb</title>
</head>
<body>
<h1>arcs02.rb</h1>
<div class="bodybox">
<div class="bodyfloat">
<pre class="language-ruby">
# frozen_string_literal: true
require 'rvg/rvg'
Magick::RVG.dpi = 90
PATH_STYLES = { fill: 'none', stroke: 'red', stroke_width: 6 }
BASE_ELLIPSES_STYLES = { font_size: 20, font_family: 'Verdana', fill: 'none', stroke: '#888', stroke_width: 2 }
rvg = Magick::RVG.new(12.cm, 5.25.cm).viewbox(0, 0, 1200, 525) do |canvas|
canvas.title = 'Example arcs02 - arc options in paths'
canvas.desc = <<-END_DESC
Pictures showing the result of setting
large-arc-flag and sweep-flag to the four
possible combinations of 0 and 1.
END_DESC
canvas.background_fill = 'white'
base_ellipses = Magick::RVG::Group.new.styles(BASE_ELLIPSES_STYLES) do |base|
base.ellipse(100, 50, 125, 125)
base.ellipse(100, 50, 225, 75)
base.text(35, 70, 'Arc start')
base.text(225, 145, 'Arc end')
end
canvas.rect(1196, 522, 1, 1).styles(fill: 'none', stroke: 'blue', stroke_width: 1)
canvas.g.styles(font_size: 30, font_family: 'Verdana', font_weight: 'normal', font_style: 'normal') do |grp|
grp.use(base_ellipses)
grp.g.translate(400, 0) do |grp2|
grp2.text(50, 210, 'large-arc-flag=0')
grp2.text(50, 250, 'sweep-flag=0')
grp2.use(base_ellipses)
grp2.path('M 125,75 a100,50 0 0,0 100,50').styles(PATH_STYLES)
end
grp.g.translate(800, 0) do |grp2|
grp2.text(50, 210, 'large-arc-flag=0')
grp2.text(50, 250, 'sweep-flag=1')
grp2.use(base_ellipses)
grp2.path('M 125,75 a100,50 0 0,1 100,50').styles(PATH_STYLES)
end
grp.g.translate(400, 250) do |grp2|
grp2.text(50, 210, 'large-arc-flag=1')
grp2.text(50, 250, 'sweep-flag=0')
grp2.use(base_ellipses)
grp2.path('M 125,75 a100,50 0 1,0 100,50').styles(PATH_STYLES)
end
grp.g.translate(800, 250) do |grp2|
grp2.text(50, 210, 'large-arc-flag=1')
grp2.text(50, 250, 'sweep-flag=1')
grp2.use(base_ellipses)
grp2.path('M 125,75 a100,50 0 1,1 100,50').styles(PATH_STYLES)
end
end
end
rvg.draw.write('arcs02.gif')
</pre>
</div>
</div>
<div id="close"><a href="javascript:window.close();">Close window</a></div>
</body>
</html>