processing 0.5.32 → 0.5.33

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f96427cef5e2add31fe4baa3c6055a94bdff9d126d1ae194cd937c24066d4af4
4
- data.tar.gz: a4a797bb6246dbb1de3450d6a802ec273553cdf4d5c4b8b2a87e82160f8a22b4
3
+ metadata.gz: dab32bbed423946f694674083de28850917630c66d56ad2014a0697aa775174d
4
+ data.tar.gz: 7ea5a81282e81365a2be85bbfd94ae4ae7586c03996aa8fb65aee32352cc633d
5
5
  SHA512:
6
- metadata.gz: 8d39fcf7857c9ad1b10597811adcb23b04f96f1f78e128ff089b2cd7cd1fe4b851ba0ff235813f8946853d940383ec82568300d9a9914ce028fc9d3622d58b4a
7
- data.tar.gz: 226f9d830533ae9f5836ad447bd84de2bb8939d8a5718d1b43c4f66dc073b776c67c7b5c5ccfa421e9271707a9511568b626a9124b6cfaf65dd61ba95fd88af5
6
+ metadata.gz: 25ac561f378c41c152c7959390a1a971621fb8633c591bd9e30df6cd06f6c7012681b2c220f5b44f6b3b619147488a949197cdbfa1c2fd2d827d17066676f832
7
+ data.tar.gz: 42b75f23f7f0aed79df3298507d0c40b0b0cc9c32752268e0f853937938dc5b3eb06cc1467a5ea85d348f8655ef702611770a1359fd32a22e4b80f9ddc5a436c
data/ChangeLog.md CHANGED
@@ -1,6 +1,48 @@
1
1
  # processing ChangeLog
2
2
 
3
3
 
4
+ ## [v0.5.33] - 2024-02-07
5
+
6
+ - Add curveDetail() and bezierDetail()
7
+ - Add curvePoint(), curveTangent(), curveTightness(), bezierPoint(), and bezierTangent()
8
+ - Add textLeading()
9
+ - Add deltaTime
10
+ - Add hue(), saturation(), and brightness()
11
+ - Add noiseSeed() and noiseDetail()
12
+ - Add randomGaussian()
13
+ - Add randomSeed()
14
+ - Add rotateX(), rotateY(), and rotateZ()
15
+ - Add rotateX(), rotateY(), and rotateZ() to Shape class
16
+ - Add shearX() and shearY()
17
+ - Add applyMatrix()
18
+ - Add printMatrix()
19
+ - Add fullscreen() (fullScreen()) function
20
+ - Add smooth() and noSmooth()
21
+ - Add keyIsDown()
22
+ - Add keyIsPressed()
23
+ - Add mouseWheel()
24
+ - Add doubleClicked()
25
+ - Add renderMode()
26
+
27
+ - Setup view projection matrix by using perspective() instead of ortho()
28
+ - Display window in the center of the screen by default
29
+ - loadImage() uses Net::HTTP.get() instead of URI.open() to retrieve images via http(s)
30
+ - loadImage() writes a file in streaming mode
31
+ - loadImage() raises Net::HTTPClientException instead of OpenURI::HTTPError
32
+ - Reimplement the noise() for better compatibility
33
+ - push/popStyle() manage colorMode, angleMode, blendMode, and miter_limit states
34
+ - size() and createCanvas() resize the window by themselves
35
+ - texture_mode/wrap -> texcoord_mode/wrap
36
+ - updatePixels() can take block
37
+
38
+ - Fix that textFont() did not return current font
39
+ - Fix that updatePixels() did not update the texture
40
+ - Fix the performance of requestImage() by calling Thread.pass
41
+ - Fix an issue with unintended canvas resizing when the screen pixel density changes
42
+ - Fix some missing attribute copies on the canvas
43
+ - Fix Matrix::to_a order
44
+
45
+
4
46
  ## [v0.5.32] - 2024-01-08
5
47
 
6
48
  - Add requestImage()
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.32
1
+ 0.5.33
@@ -2,7 +2,8 @@ require 'set'
2
2
  require 'digest/sha1'
3
3
  require 'pathname'
4
4
  require 'tmpdir'
5
- require 'open-uri'
5
+ require 'net/http'
6
+ require 'uri'
6
7
  require 'xot/inspectable'
7
8
  require 'reflex'
8
9
 
@@ -19,4 +20,5 @@ require 'processing/shader'
19
20
  require 'processing/capture'
20
21
  require 'processing/graphics_context'
21
22
  require 'processing/graphics'
23
+ require 'processing/events'
22
24
  require 'processing/context'
@@ -41,9 +41,10 @@ module Processing
41
41
 
42
42
  @window__ = window
43
43
  init__(
44
- @window__.canvas_image,
45
- @window__.canvas_painter.paint {background 0.8})
44
+ @window__.canvas.image,
45
+ @window__.canvas.painter.paint {background 0.8})
46
46
 
47
+ @smooth__ = true
47
48
  @loop__ = true
48
49
  @redraw__ = false
49
50
  @frameCount__ = 0
@@ -65,7 +66,7 @@ module Processing
65
66
 
66
67
  # @private
67
68
  def @window__.draw_screen(painter)
68
- @context__.drawImage__ painter
69
+ @context__.drawImage__ painter, image__: canvas.render
69
70
  end
70
71
 
71
72
  drawFrame = -> {
@@ -89,8 +90,8 @@ module Processing
89
90
  @key__ = event.chars
90
91
  @keyCode__ = event.key
91
92
  if pressed != nil
92
- set, key = @keysPressed__, event.key
93
- pressed ? set.add(key) : set.delete(key)
93
+ set = @keysPressed__
94
+ pressed ? set.add(@keyCode__) : set.delete(@keyCode__)
94
95
  end
95
96
  }
96
97
 
@@ -143,8 +144,8 @@ module Processing
143
144
  updatePointersPressedAndReleased.call e, false
144
145
  if e.any? {|p| p.id == @pointer__.id}
145
146
  @mouseReleasedBlock__&.call
146
- @mouseClickedBlock__&.call if
147
- (@pointer__.pos - @pointer__.down.pos).length < 3
147
+ @mouseClickedBlock__&.call if e.click_count > 0
148
+ @doubleClickedBlock__&.call if e.click_count == 2
148
149
  end
149
150
  @touchEndedBlock__&.call
150
151
  @pointersReleased__.clear
@@ -157,6 +158,10 @@ module Processing
157
158
  @touchMovedBlock__&.call
158
159
  end
159
160
 
161
+ @window__.wheel = proc do |e|
162
+ @mouseWheelBlock__&.call WheelEvent.new(e)
163
+ end
164
+
160
165
  @window__.move = proc do |e|
161
166
  @windowMovedBlock__&.call
162
167
  end
@@ -191,6 +196,8 @@ module Processing
191
196
  @mouseMovedBlock__ ||
192
197
  @mouseDraggedBlock__ ||
193
198
  @mouseClickedBlock__ ||
199
+ @doubleClickedBlock__ ||
200
+ @mouseWheelBlock__ ||
194
201
  @touchStartedBlock__ ||
195
202
  @touchEndedBlock__ ||
196
203
  @touchMovedBlock__ ||
@@ -214,7 +221,7 @@ module Processing
214
221
  #
215
222
  def keyPressed(&block)
216
223
  @keyPressedBlock__ = block if block
217
- not @keysPressed__.empty?
224
+ keyIsPressed
218
225
  end
219
226
 
220
227
  # Defines keyReleased block.
@@ -280,6 +287,24 @@ module Processing
280
287
  nil
281
288
  end
282
289
 
290
+ # Defines doubleClicked block.
291
+ #
292
+ # @return [nil] nil
293
+ #
294
+ def doubleClicked(&block)
295
+ @doubleClickedBlock__ = block if block
296
+ nil
297
+ end
298
+
299
+ # Defines mouseWheel block.
300
+ #
301
+ # @return [nil] nil
302
+ #
303
+ def mouseWheel(&block)
304
+ @mouseWheelBlock__ = block if block
305
+ nil
306
+ end
307
+
283
308
  # Defines touchStarted block.
284
309
  #
285
310
  # @return [nil] nil
@@ -343,7 +368,8 @@ module Processing
343
368
  # @return [nil] nil
344
369
  #
345
370
  def size(width, height, pixelDensity: self.pixelDensity)
346
- resizeCanvas__ :size, width, height, pixelDensity
371
+ windowResize width, height
372
+ resizeCanvas__ width, height, pixelDensity
347
373
  nil
348
374
  end
349
375
 
@@ -356,7 +382,8 @@ module Processing
356
382
  # @return [nil] nil
357
383
  #
358
384
  def createCanvas(width, height, pixelDensity: self.pixelDensity)
359
- resizeCanvas__ :createCanvas, width, height, pixelDensity
385
+ windowResize width, height
386
+ resizeCanvas__ width, height, pixelDensity
360
387
  nil
361
388
  end
362
389
 
@@ -378,15 +405,49 @@ module Processing
378
405
  # @return [Numeric] current pixel density
379
406
  #
380
407
  def pixelDensity(density = nil)
381
- resizeCanvas__ :pixelDensity, width, height, density if density
382
- @painter__.pixel_density
408
+ resizeCanvas__ width, height, density if density
409
+ @window__.canvas.pixel_density
383
410
  end
384
411
 
385
- # @private
386
- def resizeCanvas__(name, width, height, pixelDensity)
387
- raise '#{name}() must be called on startup or setup block' if @started__
412
+ # Toggles full-screen state or returns the current state.
413
+ #
414
+ # @param state [Boolean] Whether to display full-screen or not
415
+ #
416
+ # @return [Boolean] current state
417
+ #
418
+ # @see https://processing.org/reference/fullScreen_.html
419
+ # @see https://p5js.org/reference/#/p5/fullscreen
420
+ #
421
+ def fullscreen(state = nil)
422
+ @window__.fullscreen = state if state != nil
423
+ @window__.fullscreen?
424
+ end
425
+
426
+ alias fullScreen fullscreen
388
427
 
389
- @window__.resize_canvas width, height, pixelDensity
428
+ # Enables anti-aliasing.
429
+ # (Anti-aliasing is disabled on high DPI screen)
430
+ #
431
+ # @return [nil] nil
432
+ #
433
+ def smooth()
434
+ @smooth__ = true
435
+ resizeCanvas__ width, height, pixelDensity
436
+ nil
437
+ end
438
+
439
+ # Disables anti-aliasing.
440
+ #
441
+ # @return [nil] nil
442
+ #
443
+ def noSmooth()
444
+ @smooth__ = false
445
+ resizeCanvas__ width, height, pixelDensity
446
+ end
447
+
448
+ # @private
449
+ def resizeCanvas__(width, height, pixelDensity)
450
+ @window__.resize_canvas width, height, pixelDensity, antialiasing: @smooth__
390
451
  @window__.auto_resize = false
391
452
  end
392
453
 
@@ -515,6 +576,14 @@ module Processing
515
576
  @window__.event.fps
516
577
  end
517
578
 
579
+ # Returns the elapsed time after previous drawing event
580
+ #
581
+ # @return [Float] elapsed time in milliseconds
582
+ #
583
+ def deltaTime()
584
+ @window__.event.dt * 1000
585
+ end
586
+
518
587
  # Returns the last key that was pressed or released.
519
588
  #
520
589
  # @return [String] last key
@@ -531,6 +600,24 @@ module Processing
531
600
  @keyCode__
532
601
  end
533
602
 
603
+ # Returns whether or not any key is pressed.
604
+ #
605
+ # @return [Boolean] is any key pressed or not
606
+ #
607
+ def keyIsPressed()
608
+ not @keysPressed__.empty?
609
+ end
610
+
611
+ # Returns weather or not the key is currently pressed.
612
+ #
613
+ # @param keyCode [Numeric] code for the key
614
+ #
615
+ # @return [Boolean] is the key pressed or not
616
+ #
617
+ def keyIsDown(keyCode)
618
+ @keysPressed__.include? keyCode
619
+ end
620
+
534
621
  # Returns mouse x position
535
622
  #
536
623
  # @return [Numeric] horizontal position of mouse
@@ -0,0 +1,22 @@
1
+ module Processing
2
+
3
+
4
+ # Mouse wheel event object.
5
+ #
6
+ class WheelEvent
7
+
8
+ # @private
9
+ def initialize(event)
10
+ @event = event
11
+ end
12
+
13
+ def delta()
14
+ @event.dy
15
+ end
16
+
17
+ alias getCount delta
18
+
19
+ end# WheelEvent
20
+
21
+
22
+ end# Processing
@@ -18,8 +18,8 @@ module Processing
18
18
  # Start drawing.
19
19
  #
20
20
  def beginDraw(&block)
21
- beginDraw__
22
21
  @painter__.__send__ :begin_paint
22
+ beginDraw__
23
23
  push
24
24
  if block
25
25
  begin
@@ -34,8 +34,8 @@ module Processing
34
34
  #
35
35
  def endDraw()
36
36
  pop
37
- @painter__.__send__ :end_paint
38
37
  endDraw__
38
+ @painter__.__send__ :end_paint
39
39
  end
40
40
 
41
41
  end# Graphics