rubysketch 0.3.17 → 0.3.18

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: '0394813335c89ce937297ef2c62819dc3c11f70dbbf74efd320eaf0a72f8b386'
4
- data.tar.gz: 9acea3187bd120239a7c387fa272e252593dc7ce0afa73425f39f65fe0b2d6bb
3
+ metadata.gz: 5a179e1170c79df6daea6d79f66eddc3aa7b50d22b2c685bcb36864f0644212e
4
+ data.tar.gz: 39565ddbcc31a7b6ef472c1fed40c91be91958531246b1673698afcd68ae621e
5
5
  SHA512:
6
- metadata.gz: 7d1824db8f17db944d6b1a2d6069b1acfcc4dafdf3d52facc2e5cdf0281108b825e89150e509c7e58ad8e2c7641d3ee9e6612f8486ebf9190ccd30cc48dbd1ae
7
- data.tar.gz: bdefffaabba512793dddc3204d749a22968096f464a9107214630012585f40f2aedd294216af321c4ae83f4fd5eb11e24d2eaab4fd1486cb39c3ecb50714c00f
6
+ metadata.gz: 435879c3538ece61aaecee0c19e6ece104934316fb113b2f23d9dc57394ded709417e30e32a7697ba1c465927b9d615fa945d1d4a4aa5068629509a33fcdbfff
7
+ data.tar.gz: b310a39f0c5e5fc55130d8c2cdd71c7620d17a42976d51fc73d7b09d41eeac15854482280bb213a937eda3474185935f27a1dcb6fd2983fad9a144c140fb337a
data/ChangeLog.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # RubySketch ChangeLog
2
2
 
3
3
 
4
+ ## [0.3.17] - 2021-12-5
5
+
6
+ - add 'mouseButton'
7
+ - pointer cancel event calls pointer_up block
8
+
9
+
4
10
  ## [0.3.16] - 2021-2-14
5
11
 
6
12
  - add key, keyCode and keyPressed system values
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.17
1
+ 0.3.18
@@ -1829,7 +1829,7 @@ module RubySketch
1829
1829
  @keysPressed__ = Set.new
1830
1830
  @pointerPos__ =
1831
1831
  @pointerPrevPos__ = [0, 0]
1832
- @pointersPressed__ = Set.new
1832
+ @pointersPressed__ = []
1833
1833
  @touches__ = []
1834
1834
  @motionGravity__ = createVector 0, 0
1835
1835
 
@@ -1864,12 +1864,21 @@ module RubySketch
1864
1864
  end
1865
1865
  }
1866
1866
 
1867
+ mouseButtonMap = {
1868
+ mouse_left: LEFT,
1869
+ mouse_right: RIGHT,
1870
+ mouse_middle: CENTER
1871
+ }
1872
+
1867
1873
  updatePointerStates = -> event, pressed = nil {
1868
1874
  @pointerPos__ = event.pos.to_a
1869
1875
  @touches__ = event.pointers.map {|p| Touch.new(p.id, *p.pos.to_a)}
1870
1876
  if pressed != nil
1871
- set, type = @pointersPressed__, event.type
1872
- pressed ? set.add(type) : set.delete(type)
1877
+ array = @pointersPressed__
1878
+ event.type
1879
+ .tap {|types| types.delete :mouse}
1880
+ .map {|type| mouseButtonMap[type] || type}
1881
+ .each {|type| pressed ? array.push(type) : array.delete(type)}
1873
1882
  end
1874
1883
  }
1875
1884
 
@@ -2142,6 +2151,14 @@ module RubySketch
2142
2151
  @pointerPrevPos__[1]
2143
2152
  end
2144
2153
 
2154
+ # Returns which mouse button was pressed
2155
+ #
2156
+ # @return [Numeric] LEFT, RIGHT, CENTER or 0
2157
+ #
2158
+ def mouseButton()
2159
+ (@pointersPressed__ & [LEFT, RIGHT, CENTER]).last || 0
2160
+ end
2161
+
2145
2162
  # Returns array of touches
2146
2163
  #
2147
2164
  # @return [Array] Touch objects
@@ -24,7 +24,7 @@ module RubySketch
24
24
  painter.miter_limit = 10
25
25
  resize_canvas 1, 1
26
26
 
27
- @canvas_view = add Reflex::View.new {|v|
27
+ @canvas_view = add Reflex::View.new(name: :canvas) {|v|
28
28
  v.on(:update) {|e| on_canvas_update e}
29
29
  v.on(:draw) {|e| on_canvas_draw e}
30
30
  v.on(:pointer) {|e| on_canvas_pointer e}
@@ -58,7 +58,7 @@ module RubySketch
58
58
  end
59
59
 
60
60
  def on_key(e)
61
- block = case e.type
61
+ block = case e.action
62
62
  when :down then @key_down
63
63
  when :up then @key_up
64
64
  end
@@ -81,9 +81,9 @@ module RubySketch
81
81
 
82
82
  def on_canvas_pointer(e)
83
83
  block = case e.action
84
- when :down then @pointer_down
85
- when :up then @pointer_up
86
- when :move then e.drag? ? @pointer_drag : @pointer_move
84
+ when :down then @pointer_down
85
+ when :up, :cancel then @pointer_up
86
+ when :move then e.drag? ? @pointer_drag : @pointer_move
87
87
  end
88
88
  draw_canvas {call_block block, e} if block
89
89
  end
data/rubysketch.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.platform = Gem::Platform::RUBY
29
29
  s.required_ruby_version = '>= 2.6.0'
30
30
 
31
- s.add_runtime_dependency 'reflexion', '~> 0.1'
31
+ s.add_runtime_dependency 'reflexion', '~> 0.1.24'
32
32
 
33
33
  s.files = `git ls-files`.split $/
34
34
  s.test_files = s.files.grep %r{^(test|spec|features)/}
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.3.17
4
+ version: 0.3.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-20 00:00:00.000000000 Z
11
+ date: 2021-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reflexion
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.1'
19
+ version: 0.1.24
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.1'
26
+ version: 0.1.24
27
27
  description: Creative Coding Framework have API compatible to Processing API or p5.js.
28
28
  email: xordog@gmail.com
29
29
  executables: []