oekaki 0.1.5 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +217 -0
  3. data/lib/oekaki.rb +1 -0
  4. metadata +3 -3
  5. data/README +0 -213
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c96851106c0f57e9f13fa74fbd356b5ca0b8b16b
4
- data.tar.gz: 23096e87b6d8ecac83c0d5d644a4300edf231a26
3
+ metadata.gz: b808243f3e9aff41d6c70c1579889633bc821e25
4
+ data.tar.gz: c616f7796e6ae2424cc99d2bf8a944922cacaef0
5
5
  SHA512:
6
- metadata.gz: 112c0c43213190106f6e2482847ed2163ab4e79a1dd337ced6fa3158607f482dc6a26c8fad68f74f82e8e919b282dd4d4f73d2efc399639c5d76cc9475ee2c55
7
- data.tar.gz: 9c33099cddcf14aab96e84b20bc7a5cd7bf9d76fe7bb4f7aa0bbc7c1d7523df808e922dab7104cc716fcbf52e4120fe837c039e6ee500c570a106536321909b4
6
+ metadata.gz: 70e792830c60476dfd891d2e624d63717d63f246ce3d1c004d8965dd5c45ac780accaa0110addf5b905594c2ba933e5957b69951fa4ccb49888b67f2bd54d1f9
7
+ data.tar.gz: f4af8bb668d4cba91cc9fb343a546dc3e5d83f0a8bf7d3789c5a6028cdaa22ab32514e0d8a2387404f404baf74142335cbaedc99562bb5b777601469ef7fa9a3
@@ -0,0 +1,217 @@
1
+ ```ruby
2
+ require 'oekaki'
3
+ include Math
4
+
5
+ L = 400
6
+ R1 = 150; R2 = (L - R1 * 2) / 2 - 5
7
+ STP1 = (PI / 180) * 0.5; STP2 = (PI / 180) * 10
8
+
9
+ Oekaki.app width: L, height: L do
10
+ draw do
11
+ clear
12
+ end
13
+
14
+ i = 0
15
+
16
+ timer(20) do
17
+ x = L / 2 + (R1 * cos(STP1 * i) + R2 * cos(STP2 * i))
18
+ y = L / 2 - (R1 * sin(STP1 * i) + R2 * sin(STP2 * i))
19
+ color(0, 65535, 0)
20
+ arc(false, x, y, 3, 3, 0, 64 * 360)
21
+ i += 1
22
+ end
23
+
24
+ key_in do |w, e|
25
+ Gtk.main_quit if e.keyval == Gdk::Keyval::GDK_Return
26
+ end
27
+ end
28
+ ```
29
+
30
+ ```ruby
31
+ require 'oekaki'
32
+
33
+ Oekaki.app width: 300, height: 300 do
34
+ draw do
35
+ white = color(65535, 65535, 65535)
36
+ red = color(65535, 0, 0)
37
+ blue = color(0, 0, 65535)
38
+
39
+ rectangle(true, 0, 0, 300, 300, white)
40
+
41
+ ar = []
42
+ 50.times {ar << [rand(300), rand(300)]} #線の数は50本(配列に座標を入れる)
43
+ polygon(true, ar, blue) #多角形を描く
44
+
45
+ text("Polygon", 180, 260, 20 * 1000, red) #文字列を描く
46
+
47
+ img = get_pic(0, 0, 300, 300) #画像の取り込み
48
+ save_pic(img, "sample.png") #画像ファイルに保存
49
+ end
50
+ end
51
+ ```
52
+
53
+ ```ruby
54
+ require 'oekaki'
55
+
56
+ L = 400
57
+
58
+ Oekaki.app width: L, height: L, title: "Circle Fall" do
59
+ timer(10) do
60
+ show = proc do |y|
61
+ x = rand(L - 10)
62
+ color(rand(65535), rand(65535), rand(65535))
63
+ arc(true, x, y, 10, 10, 0, 64 * 360)
64
+ end
65
+
66
+ show.call(0) if rand < 0.15
67
+ show.call(rand(L - 10)) if rand < 0.05
68
+
69
+ img = get_pic(0, 0, L, L)
70
+ show_pic(img, 0, 1)
71
+ color(0, 0, 0)
72
+ rectangle(true, 0, 0, L, 1)
73
+ end
74
+
75
+ key_in do |w, e|
76
+ Gtk.main_quit if e.keyval == Gdk::Keyval::GDK_Return
77
+ end
78
+
79
+ draw do
80
+ color(0, 0, 0)
81
+ rectangle(true, 0, 0, L, L)
82
+ end
83
+ end
84
+ ```
85
+
86
+ ```ruby
87
+ require 'oekaki'
88
+
89
+ L = 500; R = 25
90
+
91
+ Oekaki.app width: L, height: L do
92
+ draw do
93
+ clear
94
+ end
95
+
96
+ quit_window = proc do
97
+ make_window do |w|
98
+ w.title = ""
99
+ b = button do
100
+ set_size_request(120, 40)
101
+ add(Gtk::Label.new.set_markup('<span size="x-large">Quit!</span>'))
102
+ signal_connect("clicked") {Gtk.main_quit}
103
+ end
104
+ add(b)
105
+ end
106
+ end
107
+
108
+ mouse_button do |w, e|
109
+ quit_window.call if e.button != 1
110
+ color(rand(65536), rand(65536), rand(65536))
111
+ arc(true, e.x - R, e.y - R, R * 2, R * 2, 0, 64 * 360)
112
+ end
113
+ end
114
+ ```
115
+
116
+ ```ruby
117
+ require 'oekaki'
118
+
119
+ Width, Height = if ARGV.size == 2
120
+ ARGV.map(&:to_i)
121
+ else
122
+ [1000, 700]
123
+ end
124
+
125
+ Max_r, Min_r = 40, 10
126
+ ColorMax = 65535
127
+ MaxNum = 60
128
+
129
+
130
+ class Circle
131
+ def initialize(ob)
132
+ @slot = ob
133
+ @width, @height = Width, Height
134
+ renewal
135
+ @y = rand(@height)
136
+ end
137
+ attr_reader :height
138
+ attr_writer :y
139
+
140
+ def renewal
141
+ @width, @height = @slot.get_window_size
142
+ @max_r = rand(Max_r - Min_r) + Min_r
143
+ @x = rand(@width)
144
+ @y = -rand(@max_r)
145
+ @color = [rand(ColorMax), rand(ColorMax), rand(ColorMax)]
146
+ @fall_step = 1 + rand * 3
147
+ @r = 1
148
+ @r_step = rand * 0.2 + 0.8
149
+ end
150
+
151
+ def paint
152
+ @slot.color(@color[0], @color[1], @color[2])
153
+ @slot.circle(true, @x, @y, @r)
154
+ @y += @fall_step
155
+ @r += @r_step
156
+ @r_step *= -1 if @r > @max_r or @r < 1
157
+ renewal if @y > @height + Max_r
158
+ true
159
+ end
160
+ end
161
+
162
+
163
+ Oekaki.app width: Width, height: Height, resizable: true do
164
+ circles = []
165
+ MaxNum.times {circles << Circle.new(self)}
166
+ black = color(0, 0, 0)
167
+
168
+ draw do
169
+ clear
170
+ end
171
+
172
+ timer(60) do
173
+ clear(black)
174
+ circles.each(&:paint)
175
+ end
176
+
177
+ window_changed do
178
+ clear(black)
179
+ circles.each do |c|
180
+ c.renewal
181
+ c.y = rand(c.height)
182
+ c.paint
183
+ end
184
+ end
185
+ end
186
+ ```
187
+
188
+ ```ruby
189
+ require 'oekaki'
190
+
191
+ Width, Height = 600, 400
192
+
193
+ Oekaki.app width: Width, height: Height, title: "C curve" do
194
+ draw do
195
+ clear
196
+
197
+ t = Oekaki::Turtle.new
198
+ t.move(-130, -100)
199
+ t.color(0, 65535, 0)
200
+ ratio = sqrt(2) / 2
201
+
202
+ drawing = lambda do |length, depth|
203
+ if depth.zero?
204
+ t.forward(length)
205
+ else
206
+ t.left(45)
207
+ drawing[length * ratio, depth - 1]
208
+ t.right(90)
209
+ drawing[length * ratio, depth - 1]
210
+ t.left(45)
211
+ end
212
+ end
213
+
214
+ drawing[260.0, 10]
215
+ end
216
+ end
217
+ ```
@@ -194,6 +194,7 @@ module Oekaki
194
194
 
195
195
  class Turtle < Tool
196
196
  def initialize
197
+ super
197
198
  @pen = Tool.new
198
199
  @pen_po = Vector[0, 0]
199
200
  @dir = Vector[1, 0]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oekaki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - obelisk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-06 00:00:00.000000000 Z
11
+ date: 2018-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gtk2
@@ -30,7 +30,7 @@ executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
- - README
33
+ - README.md
34
34
  - example/oekaki_sample1.rb
35
35
  - example/oekaki_sample10.rb
36
36
  - example/oekaki_sample12.rb
data/README DELETED
@@ -1,213 +0,0 @@
1
-  
2
- require 'oekaki'
3
- include Math
4
-
5
- L = 400
6
- R1 = 150; R2 = (L - R1 * 2) / 2 - 5
7
- STP1 = (PI / 180) * 0.5; STP2 = (PI / 180) * 10
8
-
9
- Oekaki.app width: L, height: L do
10
- draw do
11
- clear
12
- end
13
-
14
- i = 0
15
-
16
- timer(20) do
17
- x = L / 2 + (R1 * cos(STP1 * i) + R2 * cos(STP2 * i))
18
- y = L / 2 - (R1 * sin(STP1 * i) + R2 * sin(STP2 * i))
19
- color(0, 65535, 0)
20
- arc(false, x, y, 3, 3, 0, 64 * 360)
21
- i += 1
22
- end
23
-
24
- key_in do |w, e|
25
- Gtk.main_quit if e.keyval == Gdk::Keyval::GDK_Return
26
- end
27
- end
28
-  
29
-  
30
- require 'oekaki'
31
-
32
- Oekaki.app width: 300, height: 300 do
33
- draw do
34
- white = color(65535, 65535, 65535)
35
- red = color(65535, 0, 0)
36
- blue = color(0, 0, 65535)
37
-
38
- rectangle(true, 0, 0, 300, 300, white)
39
-
40
- ar = []
41
- 50.times {ar << [rand(300), rand(300)]} #線の数は50本(配列に座標を入れる)
42
- polygon(true, ar, blue) #多角形を描く
43
-
44
- text("Polygon", 180, 260, 20 * 1000, red) #文字列を描く
45
-
46
- img = get_pic(0, 0, 300, 300) #画像の取り込み
47
- save_pic(img, "sample.png") #画像ファイルに保存
48
- end
49
- end
50
-  
51
-  
52
- require 'oekaki'
53
-
54
- L = 400
55
-
56
- Oekaki.app width: L, height: L, title: "Circle Fall" do
57
- timer(10) do
58
- show = proc do |y|
59
- x = rand(L - 10)
60
- color(rand(65535), rand(65535), rand(65535))
61
- arc(true, x, y, 10, 10, 0, 64 * 360)
62
- end
63
-
64
- show.call(0) if rand < 0.15
65
- show.call(rand(L - 10)) if rand < 0.05
66
-
67
- img = get_pic(0, 0, L, L)
68
- show_pic(img, 0, 1)
69
- color(0, 0, 0)
70
- rectangle(true, 0, 0, L, 1)
71
- end
72
-
73
- key_in do |w, e|
74
- Gtk.main_quit if e.keyval == Gdk::Keyval::GDK_Return
75
- end
76
-
77
- draw do
78
- color(0, 0, 0)
79
- rectangle(true, 0, 0, L, L)
80
- end
81
- end
82
-  
83
-  
84
- require 'oekaki'
85
-
86
- L = 500; R = 25
87
-
88
- Oekaki.app width: L, height: L do
89
- draw do
90
- clear
91
- end
92
-
93
- quit_window = proc do
94
- make_window do |w|
95
- w.title = ""
96
- b = button do
97
- set_size_request(120, 40)
98
- add(Gtk::Label.new.set_markup('<span size="x-large">Quit!</span>'))
99
- signal_connect("clicked") {Gtk.main_quit}
100
- end
101
- add(b)
102
- end
103
- end
104
-
105
- mouse_button do |w, e|
106
- quit_window.call if e.button != 1
107
- color(rand(65536), rand(65536), rand(65536))
108
- arc(true, e.x - R, e.y - R, R * 2, R * 2, 0, 64 * 360)
109
- end
110
- end
111
-  
112
-  
113
- require 'oekaki'
114
-
115
- Width, Height = if ARGV.size == 2
116
- ARGV.map(&:to_i)
117
- else
118
- [1000, 700]
119
- end
120
-
121
- Max_r, Min_r = 40, 10
122
- ColorMax = 65535
123
- MaxNum = 60
124
-
125
-
126
- class Circle
127
- def initialize(ob)
128
- @slot = ob
129
- @width, @height = Width, Height
130
- renewal
131
- @y = rand(@height)
132
- end
133
- attr_reader :height
134
- attr_writer :y
135
-
136
- def renewal
137
- @width, @height = @slot.get_window_size
138
- @max_r = rand(Max_r - Min_r) + Min_r
139
- @x = rand(@width)
140
- @y = -rand(@max_r)
141
- @color = [rand(ColorMax), rand(ColorMax), rand(ColorMax)]
142
- @fall_step = 1 + rand * 3
143
- @r = 1
144
- @r_step = rand * 0.2 + 0.8
145
- end
146
-
147
- def paint
148
- @slot.color(@color[0], @color[1], @color[2])
149
- @slot.circle(true, @x, @y, @r)
150
- @y += @fall_step
151
- @r += @r_step
152
- @r_step *= -1 if @r > @max_r or @r < 1
153
- renewal if @y > @height + Max_r
154
- true
155
- end
156
- end
157
-
158
-
159
- Oekaki.app width: Width, height: Height, resizable: true do
160
- circles = []
161
- MaxNum.times {circles << Circle.new(self)}
162
- black = color(0, 0, 0)
163
-
164
- draw do
165
- clear
166
- end
167
-
168
- timer(60) do
169
- clear(black)
170
- circles.each(&:paint)
171
- end
172
-
173
- window_changed do
174
- clear(black)
175
- circles.each do |c|
176
- c.renewal
177
- c.y = rand(c.height)
178
- c.paint
179
- end
180
- end
181
- end
182
-  
183
-  
184
- require 'oekaki'
185
-
186
- Width, Height = 600, 400
187
-
188
- Oekaki.app width: Width, height: Height, title: "C curve" do
189
- draw do
190
- clear
191
-
192
- t = Oekaki::Turtle.new
193
- t.move(-130, -100)
194
- t.color(0, 65535, 0)
195
- ratio = sqrt(2) / 2
196
-
197
- drawing = lambda do |length, depth|
198
- if depth.zero?
199
- t.forward(length)
200
- else
201
- t.left(45)
202
- drawing[length * ratio, depth - 1]
203
- t.right(90)
204
- drawing[length * ratio, depth - 1]
205
- t.left(45)
206
- end
207
- end
208
-
209
- drawing[260.0, 10]
210
- end
211
- end
212
-  
213
-