-
Notifications
You must be signed in to change notification settings - Fork 2
/
evenodd.rb.html
68 lines (61 loc) · 3.09 KB
/
evenodd.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
<!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: evenodd.rb</title>
</head>
<body>
<h1>evenodd.rb</h1>
<div class="bodybox">
<div class="bodyfloat">
<pre class="language-ruby">
# frozen_string_literal: true
require 'rvg/rvg'
Magick::RVG.dpi = 90
rvg = Magick::RVG.new(12.cm, 4.cm).viewbox(0, 0, 1200, 400) do |canvas|
canvas.background_fill = 'white'
canvas.desc = "Example fillrule - nonzero - demonstrates fill_rule=>'nonzero'"
canvas.rect(1195, 393, 1, 1).styles(fill: 'none', stroke: 'blue')
triangle = Magick::RVG::Group.new do |defs|
defs.path('M 16,0 L -8,9 v-18 z').styles(fill: 'black', stroke: 'none')
end
canvas.g.styles(clip_rule: 'evenodd', fill: 'red', stroke: 'black', stroke_width: 3) do |grp|
grp.path('M 250,75 L 323,301 131,161 369,161 177,301 z')
grp.use(triangle).translate(306.21, 249).rotate(72)
grp.use(triangle).translate(175.16, 193.2).rotate(216)
grp.use(triangle).translate(314.26, 161).rotate(0)
grp.use(triangle).translate(221.16, 268.8).rotate(144)
grp.use(triangle).translate(233.21, 126.98).rotate(288)
grp.path('M 600,81 A 107,107 0 0,1 600,295 A 107,107 0 0,1 600,81 z' \
'M 600,139 A 49,49 0 0,1 600,237 A 49,49 0 0,1 600,139 z')
grp.use(triangle).translate(600, 188).rotate(0).translate(107, 0).rotate(90)
grp.use(triangle).translate(600, 188).rotate(120).translate(107, 0).rotate(90)
grp.use(triangle).translate(600, 188).rotate(240).translate(107, 0).rotate(90)
grp.use(triangle).translate(600, 188).rotate(60).translate(49, 0).rotate(90)
grp.use(triangle).translate(600, 188).rotate(180).translate(49, 0).rotate(90)
grp.use(triangle).translate(600, 188).rotate(300).translate(49, 0).rotate(90)
grp.path('M 950,81 A 107,107 0 0,1 950,295 A 107,107 0 0,1 950,81 z' \
'M 950,139 A 49,49 0 0,0 950,237 A 49,49 0 0,0 950,139 z')
grp.use(triangle).translate(950, 188).rotate(0).translate(107, 0).rotate(90)
grp.use(triangle).translate(950, 188).rotate(120).translate(107, 0).rotate(90)
grp.use(triangle).translate(950, 188).rotate(240).translate(107, 0).rotate(90)
grp.use(triangle).translate(950, 188).rotate(60).translate(49, 0).rotate(-90)
grp.use(triangle).translate(950, 188).rotate(180).translate(49, 0).rotate(-90)
grp.use(triangle).translate(950, 188).rotate(300).translate(49, 0).rotate(-90)
end
end
rvg.draw.write('evenodd.gif')
</pre>
</div>
</div>
<div id="close"><a href="javascript:window.close();">Close window</a></div>
</body>
</html>