oekaki 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README +70 -1
- data/lib/oekaki.rb +23 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b474bb33eb9954503ae6bf8d34a36df2fd8c4936
|
4
|
+
data.tar.gz: c72e524da5a1fd593327a3da94225e0dc656c2f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f41a72287d4f6790c90a7446d73a176d291c76829cd6d0cee3b51d423cbe4a9dcb5cd9fe59616e74906b71f476f7c734917aeff3130c9ff6570804513897d8f
|
7
|
+
data.tar.gz: e456c6f20c07bf7d0a94c05776c1763a350f34a926642cadfca16fce6cab35e274ab8adbb2c568998a85dd6c8f5a3e04dc54fd3c73a444917394ec9844334dde
|
data/README
CHANGED
@@ -110,5 +110,74 @@
|
|
110
110
|
arc(true, e.x - R, e.y - R, R * 2, R * 2, 0, 64 * 360)
|
111
111
|
end
|
112
112
|
end
|
113
|
-
|
114
113
|
|
114
|
+
|
115
|
+
require 'oekaki'
|
116
|
+
|
117
|
+
Width, Height = if ARGV.size == 2
|
118
|
+
ARGV.map(&:to_i)
|
119
|
+
else
|
120
|
+
[1000, 700]
|
121
|
+
end
|
122
|
+
|
123
|
+
Max_r, Min_r = 40, 10
|
124
|
+
ColorMax = 65535
|
125
|
+
MaxNum = 60
|
126
|
+
|
127
|
+
|
128
|
+
class Circle
|
129
|
+
def initialize(ob)
|
130
|
+
@slot = ob
|
131
|
+
@width, @height = Width, Height
|
132
|
+
renewal
|
133
|
+
@y = rand(@height)
|
134
|
+
end
|
135
|
+
attr_reader :height
|
136
|
+
attr_writer :y
|
137
|
+
|
138
|
+
def renewal
|
139
|
+
@width, @height = @slot.get_window_size
|
140
|
+
@max_r = rand(Max_r - Min_r) + Min_r
|
141
|
+
@x = rand(@width)
|
142
|
+
@y = -rand(@max_r)
|
143
|
+
@color = [rand(ColorMax), rand(ColorMax), rand(ColorMax)]
|
144
|
+
@fall_step = 1 + rand * 3
|
145
|
+
@r = 1
|
146
|
+
@r_step = rand * 0.2 + 0.8
|
147
|
+
end
|
148
|
+
|
149
|
+
def paint
|
150
|
+
@slot.color(@color[0], @color[1], @color[2])
|
151
|
+
@slot.circle(true, @x, @y, @r)
|
152
|
+
@y += @fall_step
|
153
|
+
@r += @r_step
|
154
|
+
@r_step *= -1 if @r > @max_r or @r < 1
|
155
|
+
renewal if @y > @height + Max_r
|
156
|
+
true
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
Oekaki.app width: Width, height: Height do
|
162
|
+
circles = []
|
163
|
+
MaxNum.times {circles << Circle.new(self)}
|
164
|
+
black = color(0, 0, 0)
|
165
|
+
|
166
|
+
draw do
|
167
|
+
clear
|
168
|
+
end
|
169
|
+
|
170
|
+
timer(60) do
|
171
|
+
clear(black)
|
172
|
+
circles.each(&:paint)
|
173
|
+
end
|
174
|
+
|
175
|
+
window_changed do
|
176
|
+
clear(black)
|
177
|
+
circles.each do |c|
|
178
|
+
c.renewal
|
179
|
+
c.y = rand(c.height)
|
180
|
+
c.paint
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
data/lib/oekaki.rb
CHANGED
@@ -12,8 +12,10 @@ module Oekaki
|
|
12
12
|
@colormap = Gdk::Colormap.system
|
13
13
|
@color = Gdk::Color.new(0, 0, 0)
|
14
14
|
@fontdesc = Pango::FontDescription.new
|
15
|
+
@width, @height = 0, 0
|
15
16
|
end
|
16
17
|
attr_reader :window
|
18
|
+
attr_accessor :width, :height
|
17
19
|
|
18
20
|
def color(r, g, b)
|
19
21
|
@color = Gdk::Color.new(r, g, b)
|
@@ -94,6 +96,15 @@ module Oekaki
|
|
94
96
|
set_color(color)
|
95
97
|
Star.new(fill, x1, y1, x2, y2, @color).draw
|
96
98
|
end
|
99
|
+
|
100
|
+
def clear(color = nil)
|
101
|
+
set_color(color)
|
102
|
+
rectangle(true, 0, 0, @width, @height)
|
103
|
+
end
|
104
|
+
|
105
|
+
def get_window_size
|
106
|
+
W.size
|
107
|
+
end
|
97
108
|
end
|
98
109
|
|
99
110
|
class Event < Tool
|
@@ -124,6 +135,13 @@ module Oekaki
|
|
124
135
|
w.show_all
|
125
136
|
w
|
126
137
|
end
|
138
|
+
|
139
|
+
def window_changed(&bk)
|
140
|
+
W.signal_connect("configure_event") do
|
141
|
+
@width, @height = get_window_size
|
142
|
+
yield
|
143
|
+
end
|
144
|
+
end
|
127
145
|
end
|
128
146
|
|
129
147
|
class Star < Tool
|
@@ -168,8 +186,12 @@ module Oekaki
|
|
168
186
|
W.set_size_request(width, height)
|
169
187
|
W.set_app_paintable(true)
|
170
188
|
W.realize
|
189
|
+
|
190
|
+
e = Event.new
|
191
|
+
e.width, e.height = width, height
|
192
|
+
e.clear
|
171
193
|
|
172
|
-
|
194
|
+
e.instance_eval(&bk)
|
173
195
|
|
174
196
|
W.signal_connect("destroy") {Gtk.main_quit}
|
175
197
|
W.show_all
|
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.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- obelisk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gtk2
|