oekaki 0.0.7 → 0.0.8
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 +2 -2
- data/lib/oekaki.rb +53 -6
- 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: 1a9b7f41a63f1b438df88aa087ebe4546566673a
|
4
|
+
data.tar.gz: 44906bda39c48649ad8a32cc7a5357e5d5b455e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2ece5210210178d34ff7143aee2190137f5aeefecd7cdc0eec2e36757daff4a8c000592290c24c61d395e73be31320f2eb65b8771514df864464bfec5317ae4
|
7
|
+
data.tar.gz: ac0d3795a5c1ffd2608b303f607210db3ba1807c1deb56001ad6e9bea8290a4c01d8467f9ad317935e01fc12f83fa8c22ddb6b0a71e9189aca528f99aa0862d5
|
data/README
CHANGED
data/lib/oekaki.rb
CHANGED
@@ -2,7 +2,7 @@ require 'gtk2'
|
|
2
2
|
|
3
3
|
module Oekaki
|
4
4
|
W = Gtk::Window.new
|
5
|
-
class Tool
|
5
|
+
class Tool < Gtk::Window
|
6
6
|
def initialize
|
7
7
|
@window = W
|
8
8
|
@drawable = W.window
|
@@ -79,6 +79,11 @@ module Oekaki
|
|
79
79
|
def get_pic(x, y, width, height)
|
80
80
|
GdkPixbuf::Pixbuf.from_drawable(nil, @drawable, x, y, width, height)
|
81
81
|
end
|
82
|
+
|
83
|
+
def star(fill, x1, y1, x2, y2, color = nil)
|
84
|
+
set_color(color)
|
85
|
+
Star.new(fill, x1, y1, x2, y2, @color).draw
|
86
|
+
end
|
82
87
|
end
|
83
88
|
|
84
89
|
class Event < Tool
|
@@ -109,6 +114,49 @@ module Oekaki
|
|
109
114
|
w.show_all
|
110
115
|
w
|
111
116
|
end
|
117
|
+
|
118
|
+
def button(&bk)
|
119
|
+
b = Gtk::Button.new
|
120
|
+
b.instance_eval(&bk)
|
121
|
+
b
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
class Star < Tool
|
126
|
+
def initialize(fill, x1, y1, x2, y2, color)
|
127
|
+
@fill = fill
|
128
|
+
@o = []; @a = []; @b = []
|
129
|
+
@o[0], @o[1] = x1, y1
|
130
|
+
@a[0] = Vector[x2 - x1, y1 - y2]
|
131
|
+
θ = PI / 5
|
132
|
+
rt1 = Matrix[[cos(θ), -sin(θ)], [sin(θ), cos(θ)]]
|
133
|
+
rt2 = rt1 * rt1
|
134
|
+
1.upto(4) {|i| @a[i] = rt2 * @a[i - 1]}
|
135
|
+
t = cos(2 * θ) / cos(θ)
|
136
|
+
@b[0] = rt1 * @a[0] * t
|
137
|
+
1.upto(4) {|i| @b[i] = rt2 * @b[i - 1]}
|
138
|
+
super()
|
139
|
+
@color = color
|
140
|
+
end
|
141
|
+
|
142
|
+
def draw_triangle(n)
|
143
|
+
ar = [@a[n].to_w(@o), @b[n].to_w(@o), @b[(n - 1) % 5].to_w(@o)]
|
144
|
+
polygon(@fill, ar)
|
145
|
+
end
|
146
|
+
private :draw_triangle
|
147
|
+
|
148
|
+
def draw
|
149
|
+
if @fill
|
150
|
+
5.times {|i| draw_triangle(i)}
|
151
|
+
ar = []
|
152
|
+
5.times {|i| ar << @b[i].to_w(@o)}
|
153
|
+
polygon(@fill, ar)
|
154
|
+
else
|
155
|
+
ar = []
|
156
|
+
5.times {|i| ar << @a[i].to_w(@o); ar << @b[i].to_w(@o)}
|
157
|
+
polygon(@fill, ar)
|
158
|
+
end
|
159
|
+
end
|
112
160
|
end
|
113
161
|
|
114
162
|
def self.app(width: 300, height: 300, title: "oekaki", &bk)
|
@@ -125,10 +173,9 @@ module Oekaki
|
|
125
173
|
end
|
126
174
|
end
|
127
175
|
|
128
|
-
class
|
129
|
-
def
|
130
|
-
|
131
|
-
|
132
|
-
b
|
176
|
+
class Vector
|
177
|
+
def to_w(o)
|
178
|
+
v = self
|
179
|
+
[o[0] + v[0], o[1] - v[1]]
|
133
180
|
end
|
134
181
|
end
|
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.8
|
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-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gtk2
|