-
Notifications
You must be signed in to change notification settings - Fork 2
/
gravity.rb.html
104 lines (93 loc) · 2.93 KB
/
gravity.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!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: gravity.rb</title>
</head>
<body>
<h1>gravity.rb</h1>
<div class="bodybox">
<div class="bodyfloat">
<pre class="language-ruby">
# frozen_string_literal: true
#
# A RMagick version of Magick++/demo/gravity.cpp
#
require 'rmagick'
x = 100
y = 100
begin
pic = Magick::ImageList.new
lines = Magick::Draw.new
lines.stroke '#600'
lines.fill_opacity 0
lines.line 300, 100, 300, 500
lines.line 100, 300, 500, 300
lines.rectangle 100, 100, 500, 500
draw = Magick::Draw.new
draw.pointsize = 30
draw.fill = '#600'
draw.undercolor = 'red'
0.step(330, 30) do |angle|
puts "angle #{angle}"
pic.new_image(600, 600) { |info| info.background_color = 'white' }
lines.draw pic
draw.annotate(pic, 0, 0, x, y, 'NorthWest') do |options|
options.gravity = Magick::NorthWestGravity
options.rotation = angle
end
draw.annotate(pic, 0, 0, 0, y, 'North') do |options|
options.gravity = Magick::NorthGravity
options.rotation = angle
end
draw.annotate(pic, 0, 0, x, y, 'NorthEast') do |options|
options.gravity = Magick::NorthEastGravity
options.rotation = angle
end
draw.annotate(pic, 0, 0, x, 0, 'East') do |options|
options.gravity = Magick::EastGravity
options.rotation = angle
end
draw.annotate(pic, 0, 0, 0, 0, 'Center') do |options|
options.gravity = Magick::CenterGravity
options.rotation = angle
end
draw.annotate(pic, 0, 0, x, y, 'SouthEast') do |options|
options.gravity = Magick::SouthEastGravity
options.rotation = angle
end
draw.annotate(pic, 0, 0, 0, y, 'South') do |options|
options.gravity = Magick::SouthGravity
options.rotation = angle
end
draw.annotate(pic, 0, 0, x, y, 'SouthWest') do |options|
options.gravity = Magick::SouthWestGravity
options.rotation = angle
end
draw.annotate(pic, 0, 0, x, 0, 'West') do |options|
options.gravity = Magick::WestGravity
options.rotation = angle
end
end
puts 'Writing image "rm_gravity_out.miff"...'
pic.delay = 20
pic.write './rm_gravity_out.miff'
rescue StandardError
puts "#{$ERROR_INFO} exception raised."
exit 1
end
exit 0
</pre>
</div>
</div>
<div id="close"><a href="javascript:window.close();">Close window</a></div>
</body>
</html>