rubysketch 0.5.5 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11852910038d162e39601eb01056ee3b4161c4ac0576ac93aef87e25eed557ee
4
- data.tar.gz: 6d978cf96d2e8d32df00477e77f03c645840bb70985f74e5d254ff5f47f5cd4c
3
+ metadata.gz: a9465d904b4ad4eed514cb114281c1f19b49e692750456714152033cbabd3bea
4
+ data.tar.gz: aff3bf85d73c1dc26fc200647a77c0dc2c0133630450f33bb0e98c62b5ac6f5e
5
5
  SHA512:
6
- metadata.gz: '0593125c1c609a1f1c38eb45631f558fcb525db85792335524a37718d306c770d12f12012d3ddf5752080318070eb139d8ece676fb436f5a10abd88af02b2c8b'
7
- data.tar.gz: 2d78202eb29f9541886efc54ec44142caf1cbd192ff58e51a26af5d3a0b8cb242c80be05171013f215b698a01cd70b9878fb10a2364abb4259402c48f6ea8475
6
+ metadata.gz: 68579b3732c2a114b8d421b61a92cbe611d412ed84bc3f1bb7cb3d81ff2cd28ecbbd35aa2469cad156fb7510cafcf624d79630a4422f4ba85ce98fd47a06b8c4
7
+ data.tar.gz: a8227ef0c4a0e7c9653f0825c3b8dfb74036058b2550cc1e5075f85d85579c1450e69f93d5bfd543e66f883b2798eca98af04b2f2747da7e54bdafeb5b99e60e
data/ChangeLog.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # rubysketch ChangeLog
2
2
 
3
3
 
4
+ ## [v0.5.7] - 2023-05-13
5
+
6
+ - Update dependencies
7
+
8
+
9
+ ## [v0.5.6] - 2023-05-11
10
+
11
+ - Add Sprite#center accessor
12
+ - Add Sprite#size=, Sprite#width=, and Sprite#height=
13
+
14
+
4
15
  ## [v0.5.5] - 2023-05-08
5
16
 
6
17
  - Add Sprite#draw()
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.5
1
+ 0.5.7
@@ -78,18 +78,18 @@ module RubySketch
78
78
  f, degrees, pivot = view.frame, view.angle, view.pivot
79
79
  if draw
80
80
  push do
81
- translate f.x + pivot.x * f.w, f.y + pivot.y * f.h
81
+ translate f.x + pivot.x * f.w, f.y + pivot.y * f.h
82
82
  rotate fromDegrees__ degrees
83
- translate -pivot.x * f.w, -pivot.y * f.h
83
+ translate (-pivot.x) * f.w, (-pivot.y) * f.h
84
84
  draw.call {drawSprite__ sp, 0, 0, f.w, f.h}
85
85
  end
86
86
  elsif degrees == 0
87
87
  drawSprite__ sp, f.x, f.y, f.w, f.h
88
88
  else
89
89
  pushMatrix do
90
- translate f.x + pivot.x * f.w, f.y + pivot.y * f.h
90
+ translate f.x + pivot.x * f.w, f.y + pivot.y * f.h
91
91
  rotate fromDegrees__ degrees
92
- translate -pivot.x * f.w, -pivot.y * f.h
92
+ translate (-pivot.x) * f.w, (-pivot.y) * f.h
93
93
  drawSprite__ sp, 0, 0, f.w, f.h
94
94
  end
95
95
  end
@@ -118,6 +118,30 @@ module RubySketch
118
118
  alias pos position
119
119
  alias pos= position=
120
120
 
121
+ # Returns the center position of the sprite.
122
+ #
123
+ # @return [Vector] center position
124
+ #
125
+ def center()
126
+ Vector.new(x + w / 2, y + h / 2)
127
+ end
128
+
129
+ # Sets the center position of the sprite.
130
+ #
131
+ # @overload center=(vec)
132
+ # @param [Vector] vec center position
133
+ #
134
+ # @overload center=(ary)
135
+ # @param [Array<Numeric>] ary an array of centerX and centerY
136
+ #
137
+ # @return [Vector] center position
138
+ #
139
+ def center=(arg)
140
+ x, y = *(arg.is_a?(Vector) ? arg.getInternal__.to_a : arg)
141
+ self.pos = [x - w / 2, y - h / 2]
142
+ self.center
143
+ end
144
+
121
145
  # Returns the size of the sprite.
122
146
  #
123
147
  # @return [Vector] size
@@ -126,6 +150,15 @@ module RubySketch
126
150
  @view__.size.toVector
127
151
  end
128
152
 
153
+ # Returns the size of the sprite.
154
+ #
155
+ # @return [Vector] size
156
+ #
157
+ def size=(arg)
158
+ @view__.size = arg.is_a?(Vector) ? arg.getInternal__ : arg
159
+ arg
160
+ end
161
+
129
162
  # Returns the width of the sprite.
130
163
  #
131
164
  # @return [Numeric] width
@@ -134,6 +167,16 @@ module RubySketch
134
167
  @view__.width
135
168
  end
136
169
 
170
+ # Sets the width of the sprite.
171
+ #
172
+ # @param [Numeric] w width
173
+ #
174
+ # @return [Numeric] width
175
+ #
176
+ def width=(w)
177
+ @view__.width = w
178
+ end
179
+
137
180
  # Returns the height of the sprite.
138
181
  #
139
182
  # @return [Numeric] height
@@ -142,8 +185,20 @@ module RubySketch
142
185
  @view__.height
143
186
  end
144
187
 
145
- alias w width
146
- alias h height
188
+ # Sets the height of the sprite.
189
+ #
190
+ # @param [Numeric] h height
191
+ #
192
+ # @return [Numeric] height
193
+ #
194
+ def height=(h)
195
+ @view__.height = h
196
+ end
197
+
198
+ alias w width
199
+ alias w= width=
200
+ alias h height
201
+ alias h= height=
147
202
 
148
203
  # Returns the rotation angle of sprite.
149
204
  #
data/rubysketch.gemspec CHANGED
@@ -31,9 +31,9 @@ Gem::Specification.new do |s|
31
31
  s.add_runtime_dependency 'xot', '~> 0.1.35'
32
32
  s.add_runtime_dependency 'rucy', '~> 0.1.35'
33
33
  s.add_runtime_dependency 'beeps', '~> 0.1.36'
34
- s.add_runtime_dependency 'rays', '~> 0.1.35'
35
- s.add_runtime_dependency 'reflexion', '~> 0.1.36'
36
- s.add_runtime_dependency 'processing', '~> 0.5.6'
34
+ s.add_runtime_dependency 'rays', '~> 0.1.36'
35
+ s.add_runtime_dependency 'reflexion', '~> 0.1.38'
36
+ s.add_runtime_dependency 'processing', '~> 0.5.8'
37
37
 
38
38
  s.add_development_dependency 'rake'
39
39
  s.add_development_dependency 'test-unit'
data/test/test_sprite.rb CHANGED
@@ -64,16 +64,49 @@ class TestSprite < Test::Unit::TestCase
64
64
  assert_equal vec(1, 2), s.pos
65
65
  end
66
66
 
67
+ def test_center()
68
+ s = sprite 0, 0, 10, 20
69
+ assert_equal vec( 5, 10), s.center
70
+
71
+ s.center = vec 100, 200
72
+ assert_equal vec( 95, 190), s.pos
73
+
74
+ s.center = [300, 400]
75
+ assert_equal vec(295, 390), s.pos
76
+ end
77
+
67
78
  def test_size()
68
79
  assert_equal vec(0, 0), sprite .size
69
80
  assert_equal vec(1, 0), sprite(0, 0, 1) .size
70
81
  assert_equal vec(1, 2), sprite(0, 0, 1, 2) .size
71
82
  assert_equal vec(3, 4), sprite(image: image(3, 4)).size
83
+
84
+ s = sprite
85
+ s.size = vec 10, 20
86
+ assert_equal vec(10, 20), s.size
87
+
88
+ s.size = [30, 40]
89
+ assert_equal vec(30, 40), s.size
72
90
  end
73
91
 
74
92
  def test_wh()
75
93
  assert_equal 1, sprite(0, 0, 1, 2).width
94
+ assert_equal 1, sprite(0, 0, 1, 2).w
76
95
  assert_equal 2, sprite(0, 0, 1, 2).height
96
+ assert_equal 2, sprite(0, 0, 1, 2).h
97
+
98
+ s = sprite
99
+ s.width = 10
100
+ assert_equal vec(10, 0), s.size
101
+
102
+ s.w = 20
103
+ assert_equal vec(20, 0), s.size
104
+
105
+ s.height = 30
106
+ assert_equal vec(20, 30), s.size
107
+
108
+ s.h = 40
109
+ assert_equal vec(20, 40), s.size
77
110
  end
78
111
 
79
112
  def test_angle()
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubysketch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-08 00:00:00.000000000 Z
11
+ date: 2023-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -58,42 +58,42 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.35
61
+ version: 0.1.36
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.1.35
68
+ version: 0.1.36
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: reflexion
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.1.36
75
+ version: 0.1.38
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.1.36
82
+ version: 0.1.38
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: processing
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.5.6
89
+ version: 0.5.8
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.5.6
96
+ version: 0.5.8
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement