rubysketch 0.5.8 → 0.5.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +13 -0
- data/VERSION +1 -1
- data/lib/rubysketch/sprite.rb +47 -7
- data/rubysketch.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e4589a97dabb9fd55efdc88db52b3b47026a10888c8e2a80109137830746399
|
4
|
+
data.tar.gz: df12166d8d9b4711bbf0a957181658e63dfcaf43bca5fa557a24404d69ae02cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1bcac7645dbf4c4a80a24339149b73f165f3bac7c366fef65e7bf6a5f7d60033564dac70178a10bbcc43bb77718ddb1e927514a207c99191a68d0ce9b30c6a2
|
7
|
+
data.tar.gz: a3635cceb2cb9f7fdf1a665892fed34e1ca826e7337a98a228d93e25fe35f054a241ab031b8aab128b247700f0b168082f45f60835c13852d2597344dd625e2d
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,19 @@
|
|
1
1
|
# rubysketch ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.5.10] - 2023-05-21
|
5
|
+
|
6
|
+
- Update dependencies
|
7
|
+
|
8
|
+
|
9
|
+
## [v0.5.9] - 2023-05-19
|
10
|
+
|
11
|
+
- Add Sprite#clickCount()
|
12
|
+
- Add Sprite#from_screen() and to_screen()
|
13
|
+
- Sprite#update returns nil
|
14
|
+
- Sprite#center includes z
|
15
|
+
|
16
|
+
|
4
17
|
## [v0.5.8] - 2023-05-18
|
5
18
|
|
6
19
|
- Dispatch pointer events only to the topmost sprite
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.10
|
data/lib/rubysketch/sprite.rb
CHANGED
@@ -142,7 +142,7 @@ module RubySketch
|
|
142
142
|
# @return [Vector] center position
|
143
143
|
#
|
144
144
|
def center()
|
145
|
-
Vector.new(x + w / 2, y + h / 2)
|
145
|
+
Vector.new(x + w / 2, y + h / 2, z)
|
146
146
|
end
|
147
147
|
|
148
148
|
# Sets the center position of the sprite.
|
@@ -157,7 +157,7 @@ module RubySketch
|
|
157
157
|
#
|
158
158
|
def center=(arg)
|
159
159
|
x, y = *(arg.is_a?(Vector) ? arg.getInternal__.to_a : arg)
|
160
|
-
self.pos = [x - w / 2, y - h / 2]
|
160
|
+
self.pos = [x - w / 2, y - h / 2, z]
|
161
161
|
self.center
|
162
162
|
end
|
163
163
|
|
@@ -492,6 +492,26 @@ module RubySketch
|
|
492
492
|
alias rest restitution
|
493
493
|
alias rest= restitution=
|
494
494
|
|
495
|
+
# Converts a vector from the screen coordinate
|
496
|
+
#
|
497
|
+
# @param [Vector] vec screen coordinate vector
|
498
|
+
#
|
499
|
+
# @return [Vector] sprite coordinate vector
|
500
|
+
#
|
501
|
+
def from_screen(vec)
|
502
|
+
@view__.from_parent(vec.getInternal__).toVector
|
503
|
+
end
|
504
|
+
|
505
|
+
# Converts a vector to the screen coordinate
|
506
|
+
#
|
507
|
+
# @param [Vector] vec sprite coordinate vector
|
508
|
+
#
|
509
|
+
# @return [Vector] screen coordinate vector
|
510
|
+
#
|
511
|
+
def to_screen(vec)
|
512
|
+
@view__.to_parent(vec.getInternal__).toVector
|
513
|
+
end
|
514
|
+
|
495
515
|
# Returns the x-position of the mouse in the sprite coordinates.
|
496
516
|
#
|
497
517
|
# @return [Numeric] x position
|
@@ -532,6 +552,14 @@ module RubySketch
|
|
532
552
|
@view__.mouseButton
|
533
553
|
end
|
534
554
|
|
555
|
+
# Returns the mouse button click count on the sprite.
|
556
|
+
#
|
557
|
+
# @return [Numeric] click count
|
558
|
+
#
|
559
|
+
def clickCount()
|
560
|
+
@view__.clickCount
|
561
|
+
end
|
562
|
+
|
535
563
|
# Returns the touch objects touched on the sprite.
|
536
564
|
#
|
537
565
|
# @return [Array<Touch>] touches
|
@@ -551,6 +579,7 @@ module RubySketch
|
|
551
579
|
#
|
552
580
|
def update(&block)
|
553
581
|
@view__.update = block
|
582
|
+
nil
|
554
583
|
end
|
555
584
|
|
556
585
|
# Defines draw block.
|
@@ -756,23 +785,27 @@ module RubySketch
|
|
756
785
|
((@pointersPressed + @pointersReleased) & [LEFT, RIGHT, CENTER]).last
|
757
786
|
end
|
758
787
|
|
788
|
+
def clickCount()
|
789
|
+
clicked? ? 1 : 0
|
790
|
+
end
|
791
|
+
|
759
792
|
def on_update(e)
|
760
793
|
@update&.call
|
761
794
|
end
|
762
795
|
|
763
796
|
def on_pointer_down(e)
|
764
797
|
updatePointerStates e, true
|
765
|
-
@pointerDownStartPos = @pointerPos
|
798
|
+
@pointerDownStartPos = to_screen @pointerPos
|
766
799
|
(@touchStarted || @mousePressed)&.call if e.view_index == 0
|
767
800
|
end
|
768
801
|
|
769
802
|
def on_pointer_up(e)
|
770
803
|
updatePointerStates e, false
|
771
|
-
|
772
|
-
|
773
|
-
@mouseClicked&.call if
|
774
|
-
@pointerDownStartPos = nil
|
804
|
+
if e.view_index == 0
|
805
|
+
(@touchEnded || @mouseReleased)&.call
|
806
|
+
@mouseClicked&.call if clicked?
|
775
807
|
end
|
808
|
+
@pointerDownStartPos = nil
|
776
809
|
@pointersReleased.clear
|
777
810
|
end
|
778
811
|
|
@@ -819,6 +852,13 @@ module RubySketch
|
|
819
852
|
end
|
820
853
|
end
|
821
854
|
|
855
|
+
def clicked?()
|
856
|
+
return false unless @pointerPos && @pointerDownStartPos
|
857
|
+
[to_screen(@pointerPos), @pointerDownStartPos]
|
858
|
+
.map {|pos| Rays::Point.new pos.x, pos.y, 0}
|
859
|
+
.then {|pos, startPos| (pos - startPos).length < 3}
|
860
|
+
end
|
861
|
+
|
822
862
|
end# SpriteView
|
823
863
|
|
824
864
|
|
data/rubysketch.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_runtime_dependency 'beeps', '~> 0.1.37'
|
34
34
|
s.add_runtime_dependency 'rays', '~> 0.1.37'
|
35
35
|
s.add_runtime_dependency 'reflexion', '~> 0.1.39'
|
36
|
-
s.add_runtime_dependency 'processing', '~> 0.5.
|
36
|
+
s.add_runtime_dependency 'processing', '~> 0.5.11'
|
37
37
|
|
38
38
|
s.add_development_dependency 'rake'
|
39
39
|
s.add_development_dependency 'test-unit'
|
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.
|
4
|
+
version: 0.5.10
|
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-
|
11
|
+
date: 2023-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xot
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.5.
|
89
|
+
version: 0.5.11
|
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.
|
96
|
+
version: 0.5.11
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|