processing 1.1.12 → 1.1.14
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/CLAUDE.md +22 -0
- data/ChangeLog.md +19 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/VERSION +1 -1
- data/lib/processing/all.rb +4 -2
- data/lib/processing/events.rb +4 -2
- data/lib/processing/font.rb +2 -2
- data/lib/processing/graphics.rb +22 -0
- data/lib/processing/graphics_context.rb +104 -29
- data/lib/processing/image.rb +1 -0
- data/lib/processing/vector.rb +1 -1
- data/lib/processing/window.rb +42 -20
- data/processing.gemspec +4 -4
- data/test/test_graphics.rb +20 -2
- metadata +11 -34
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f18e4e393f628f012fd86b5e22cadc1376ed3e5e057cb246c0c905876cc91ae
|
|
4
|
+
data.tar.gz: f9b9b760ebbe8e10d5b7daa90f11f73a8f1b020de1a55583282bcbeededda2ef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bfc3729dc47ad1846dc1036e4dc8d5b5e69ef35e0bbe00f0f3b69e7c7337bde9ea3bfe0a9cc554295da4dc3dd438ff07dd25f5c95b506df7f757eff9836a964b
|
|
7
|
+
data.tar.gz: 306b81eb048502285e1ac6dce41cd4ad4bd9dab3eec645ec0485aeb220ec26ea2d673f99691765a3277e5d6266d48459883de8e8d2e0781a3ec525b38188d061
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Processing
|
|
2
|
+
|
|
3
|
+
Processing/p5.js-compatible creative coding framework for Ruby.
|
|
4
|
+
|
|
5
|
+
## Dual API
|
|
6
|
+
|
|
7
|
+
- Default: Processing-compatible camelCase (`colorMode`, `ellipseMode`)
|
|
8
|
+
- Optional: `Processing(snake_case: true)` enables snake_case aliases
|
|
9
|
+
|
|
10
|
+
## Naming Convention
|
|
11
|
+
|
|
12
|
+
- Internal methods use `__` suffix (e.g., `init__`, `beginDraw__`, `@context__`)
|
|
13
|
+
- Methods matching `/__[!?]?$/` are excluded from the public API
|
|
14
|
+
|
|
15
|
+
## Visual Regression Testing
|
|
16
|
+
|
|
17
|
+
Set `TEST_WITH_BROWSER=1` to enable browser-based drawing tests via Ferrum.
|
|
18
|
+
`assert_p5_draw` performs screenshot comparison.
|
|
19
|
+
|
|
20
|
+
## GraphicsContext
|
|
21
|
+
|
|
22
|
+
Drawing logic is concentrated in the `GraphicsContext` module, mixed into both `Context` (top-level) and `Graphics` (offscreen buffer).
|
data/ChangeLog.md
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
# processing ChangeLog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [v1.1.14] - 2026-04-09
|
|
5
|
+
|
|
6
|
+
- Add Graphics#size
|
|
7
|
+
- Add Graphics#initialize_copy
|
|
8
|
+
- Add the 'smooth' param to createFont() and loadFont()
|
|
9
|
+
- loadFont() can take size parameter
|
|
10
|
+
- WheelEvent#delta returns dy and dx
|
|
11
|
+
- Image#resize does nothing when called with the same width and height
|
|
12
|
+
- Text is now vertically centered based on ascent rather than total height
|
|
13
|
+
- Handle key and midi events in focused canvas view
|
|
14
|
+
- Update dependencies
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [v1.1.13] - 2025-07-06
|
|
18
|
+
|
|
19
|
+
- Add method docs for background(), fill(), stroke(), point(), line(), rect(), ellipse(), circle(), image(), translate(), scale(), and rotate()
|
|
20
|
+
- Add deepwiki badge
|
|
21
|
+
|
|
22
|
+
|
|
4
23
|
## [v1.1.12] - 2025-05-22
|
|
5
24
|
|
|
6
25
|
- Add control_change event handler block
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# Processing for CRuby - Processing compatible Creative Coding Framework
|
|
2
2
|
|
|
3
|
+
[](https://deepwiki.com/xord/processing)
|
|
3
4
|

|
|
4
5
|

|
|
5
6
|

|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.1.
|
|
1
|
+
1.1.14
|
data/lib/processing/all.rb
CHANGED
|
@@ -22,6 +22,8 @@ module Processing
|
|
|
22
22
|
windowMoved windowResized motion
|
|
23
23
|
]
|
|
24
24
|
|
|
25
|
+
SUFFIX_PRIVATE = /__[!?]?$/
|
|
26
|
+
|
|
25
27
|
# @private
|
|
26
28
|
def self.setup__(namespace)
|
|
27
29
|
w = (ENV['WIDTH'] || 500).to_i
|
|
@@ -36,7 +38,7 @@ module Processing
|
|
|
36
38
|
# @private
|
|
37
39
|
def self.funcs__(context)
|
|
38
40
|
(context.methods - Object.instance_methods)
|
|
39
|
-
.reject {_1 =~
|
|
41
|
+
.reject {_1 =~ SUFFIX_PRIVATE} # methods for internal use
|
|
40
42
|
end
|
|
41
43
|
|
|
42
44
|
# @private
|
|
@@ -47,7 +49,7 @@ module Processing
|
|
|
47
49
|
# @private
|
|
48
50
|
def self.alias_snake_case_methods__(klass, recursive = 1)
|
|
49
51
|
to_snake_case__(klass.instance_methods false)
|
|
50
|
-
.reject {|camel, snake| camel =~
|
|
52
|
+
.reject {|camel, snake| camel =~ SUFFIX_PRIVATE}
|
|
51
53
|
.reject {|camel, snake| klass.method_defined? snake}
|
|
52
54
|
.each {|camel, snake| klass.alias_method snake, camel}
|
|
53
55
|
if recursive > 0
|
data/lib/processing/events.rb
CHANGED
data/lib/processing/font.rb
CHANGED
data/lib/processing/graphics.rb
CHANGED
|
@@ -21,6 +21,28 @@ module Processing
|
|
|
21
21
|
init__ image, image.painter
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
def initialize_copy(o)
|
|
25
|
+
super
|
|
26
|
+
raise 'cannot duplicate during drawing' if @drawing__
|
|
27
|
+
raise 'cannot duplicate because each stack is not empty' unless
|
|
28
|
+
@matrixStack__.empty? && @styleStack__.empty?
|
|
29
|
+
|
|
30
|
+
image = getInternal__.dup
|
|
31
|
+
updateCanvas__ image, image.painter
|
|
32
|
+
restoreStyles__ o.styles__
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
alias w width
|
|
36
|
+
alias h height
|
|
37
|
+
|
|
38
|
+
# Returns the width and height of graphics.
|
|
39
|
+
#
|
|
40
|
+
# @return [Array<Numeric>] [width, height]
|
|
41
|
+
#
|
|
42
|
+
def size()
|
|
43
|
+
[width, height]
|
|
44
|
+
end
|
|
45
|
+
|
|
24
46
|
# Start drawing.
|
|
25
47
|
#
|
|
26
48
|
# @see https://processing.org/reference/PGraphics_beginDraw_.html
|
|
@@ -994,6 +994,11 @@ module Processing
|
|
|
994
994
|
#
|
|
995
995
|
# @return [nil] nil
|
|
996
996
|
#
|
|
997
|
+
# @example
|
|
998
|
+
# fill(255) # White fill
|
|
999
|
+
# fill(255, 0, 0) # Red fill
|
|
1000
|
+
# fill(0, 255, 0, 128) # Semi-transparent green fill
|
|
1001
|
+
#
|
|
997
1002
|
# @see https://processing.org/reference/fill_.html
|
|
998
1003
|
# @see https://p5js.org/reference/p5/fill/
|
|
999
1004
|
#
|
|
@@ -1032,6 +1037,11 @@ module Processing
|
|
|
1032
1037
|
#
|
|
1033
1038
|
# @return [nil] nil
|
|
1034
1039
|
#
|
|
1040
|
+
# @example
|
|
1041
|
+
# stroke(0) # Black stroke
|
|
1042
|
+
# stroke(255, 0, 0) # Red stroke
|
|
1043
|
+
# stroke(0, 0, 255, 128) # Semi-transparent blue stroke
|
|
1044
|
+
#
|
|
1035
1045
|
# @see https://processing.org/reference/stroke_.html
|
|
1036
1046
|
# @see https://p5js.org/reference/p5/stroke/
|
|
1037
1047
|
#
|
|
@@ -1444,6 +1454,12 @@ module Processing
|
|
|
1444
1454
|
#
|
|
1445
1455
|
# @return [nil] nil
|
|
1446
1456
|
#
|
|
1457
|
+
# @example
|
|
1458
|
+
# background(255) # White background
|
|
1459
|
+
# background(0) # Black background
|
|
1460
|
+
# background(255, 0, 0) # Red background
|
|
1461
|
+
# background(255, 0, 0, 128) # Semi-transparent red background
|
|
1462
|
+
#
|
|
1447
1463
|
# @see https://processing.org/reference/background_.html
|
|
1448
1464
|
# @see https://p5js.org/reference/p5/background/
|
|
1449
1465
|
#
|
|
@@ -1473,6 +1489,10 @@ module Processing
|
|
|
1473
1489
|
#
|
|
1474
1490
|
# @return [nil] nil
|
|
1475
1491
|
#
|
|
1492
|
+
# @example
|
|
1493
|
+
# point(50, 50) # Draw point at (50,50)
|
|
1494
|
+
# point(100, 200) # Draw point at (100,200)
|
|
1495
|
+
#
|
|
1476
1496
|
# @see https://processing.org/reference/point_.html
|
|
1477
1497
|
# @see https://p5js.org/reference/p5/point/
|
|
1478
1498
|
#
|
|
@@ -1493,6 +1513,10 @@ module Processing
|
|
|
1493
1513
|
#
|
|
1494
1514
|
# @return [nil] nil
|
|
1495
1515
|
#
|
|
1516
|
+
# @example
|
|
1517
|
+
# line(10, 20, 50, 80) # Draw line from (10,20) to (50,80)
|
|
1518
|
+
# line(0, 0, width, height) # Draw diagonal line from top-left to bottom-right
|
|
1519
|
+
#
|
|
1496
1520
|
# @see https://processing.org/reference/line_.html
|
|
1497
1521
|
# @see https://p5js.org/reference/p5/line/
|
|
1498
1522
|
#
|
|
@@ -1524,6 +1548,11 @@ module Processing
|
|
|
1524
1548
|
#
|
|
1525
1549
|
# @return [nil] nil
|
|
1526
1550
|
#
|
|
1551
|
+
# @example
|
|
1552
|
+
# rect(10, 20, 30, 40) # Draw rectangle at (10,20) with width 30, height 40
|
|
1553
|
+
# rect(10, 20, 30, 40, 5) # Draw rectangle with rounded corners (radius 5)
|
|
1554
|
+
# rect(10, 20, 30, 40, 5, 3, 7, 2) # Draw rectangle with different corner radii
|
|
1555
|
+
#
|
|
1527
1556
|
# @see https://processing.org/reference/rect_.html
|
|
1528
1557
|
# @see https://p5js.org/reference/p5/rect/
|
|
1529
1558
|
#
|
|
@@ -1555,6 +1584,11 @@ module Processing
|
|
|
1555
1584
|
#
|
|
1556
1585
|
# @return [nil] nil
|
|
1557
1586
|
#
|
|
1587
|
+
# @example
|
|
1588
|
+
# ellipse(50, 50, 80, 80) # Draw circle at (50,50) with diameter 80
|
|
1589
|
+
# ellipse(50, 50, 80, 60) # Draw ellipse at (50,50) with width 80, height 60
|
|
1590
|
+
# ellipse(50, 50, 80) # Draw circle at (50,50) with diameter 80
|
|
1591
|
+
#
|
|
1558
1592
|
# @see https://processing.org/reference/ellipse_.html
|
|
1559
1593
|
# @see https://p5js.org/reference/p5/ellipse/
|
|
1560
1594
|
#
|
|
@@ -1575,6 +1609,10 @@ module Processing
|
|
|
1575
1609
|
#
|
|
1576
1610
|
# @return [nil] nil
|
|
1577
1611
|
#
|
|
1612
|
+
# @example
|
|
1613
|
+
# circle(50, 60, 80) # Draw circle at (50,60) with diameter 80
|
|
1614
|
+
# circle(100, 200, 60) # Draw circle at (100,200) with diameter 60
|
|
1615
|
+
#
|
|
1578
1616
|
# @see https://processing.org/reference/circle_.html
|
|
1579
1617
|
# @see https://p5js.org/reference/p5/circle/
|
|
1580
1618
|
#
|
|
@@ -1748,21 +1786,23 @@ module Processing
|
|
|
1748
1786
|
#
|
|
1749
1787
|
def text(str, x, y, x2 = nil, y2 = nil)
|
|
1750
1788
|
assertDrawing__
|
|
1789
|
+
font = @painter__.font
|
|
1751
1790
|
if x2
|
|
1752
1791
|
raise ArgumentError, "missing y2 parameter" unless y2
|
|
1753
1792
|
x, y, w, h = toXYWH__ @rectMode__, x, y, x2, y2
|
|
1754
1793
|
case @textAlignH__
|
|
1755
|
-
when RIGHT then x += w -
|
|
1756
|
-
when CENTER then x += (w -
|
|
1794
|
+
when RIGHT then x += w - font.width(str)
|
|
1795
|
+
when CENTER then x += (w - font.width(str)) / 2.0
|
|
1757
1796
|
end
|
|
1758
1797
|
case @textAlignV__
|
|
1759
|
-
when BOTTOM then y += h -
|
|
1760
|
-
when CENTER then y += (h -
|
|
1798
|
+
when BOTTOM then y += h - font.ascent
|
|
1799
|
+
when CENTER then y += (h - font.ascent) / 2.0
|
|
1761
1800
|
else
|
|
1762
1801
|
end
|
|
1763
1802
|
else
|
|
1764
|
-
y -=
|
|
1803
|
+
y -= font.ascent
|
|
1765
1804
|
end
|
|
1805
|
+
x, y = x.round, y.round unless font.smooth
|
|
1766
1806
|
@painter__.text str, x, y
|
|
1767
1807
|
nil
|
|
1768
1808
|
end
|
|
@@ -1784,6 +1824,11 @@ module Processing
|
|
|
1784
1824
|
#
|
|
1785
1825
|
# @return [nil] nil
|
|
1786
1826
|
#
|
|
1827
|
+
# @example
|
|
1828
|
+
# image(img, 10, 20) # Draw image at (10,20) with original size
|
|
1829
|
+
# image(img, 10, 20, 50, 80) # Draw image at (10,20) with width 50, height 80
|
|
1830
|
+
# image(img, 0, 0, width, height) # Draw image to fill entire canvas
|
|
1831
|
+
#
|
|
1787
1832
|
# @see https://processing.org/reference/image_.html
|
|
1788
1833
|
# @see https://p5js.org/reference/p5/image/
|
|
1789
1834
|
#
|
|
@@ -2102,6 +2147,10 @@ module Processing
|
|
|
2102
2147
|
#
|
|
2103
2148
|
# @return [nil] nil
|
|
2104
2149
|
#
|
|
2150
|
+
# @example
|
|
2151
|
+
# translate(50, 100) # Move coordinate system by (50, 100)
|
|
2152
|
+
# translate(width/2, height/2) # Move origin to center of canvas
|
|
2153
|
+
#
|
|
2105
2154
|
# @see https://processing.org/reference/translate_.html
|
|
2106
2155
|
# @see https://p5js.org/reference/p5/translate/
|
|
2107
2156
|
#
|
|
@@ -2124,6 +2173,11 @@ module Processing
|
|
|
2124
2173
|
#
|
|
2125
2174
|
# @return [nil] nil
|
|
2126
2175
|
#
|
|
2176
|
+
# @example
|
|
2177
|
+
# scale(2) # Scale uniformly by 2x
|
|
2178
|
+
# scale(2, 3) # Scale by 2x horizontally, 3x vertically
|
|
2179
|
+
# scale(0.5) # Scale down by half
|
|
2180
|
+
#
|
|
2127
2181
|
# @see https://processing.org/reference/scale_.html
|
|
2128
2182
|
# @see https://p5js.org/reference/p5/scale/
|
|
2129
2183
|
#
|
|
@@ -2139,6 +2193,11 @@ module Processing
|
|
|
2139
2193
|
#
|
|
2140
2194
|
# @return [nil] nil
|
|
2141
2195
|
#
|
|
2196
|
+
# @example
|
|
2197
|
+
# rotate(PI/4) # Rotate 45 degrees (PI/4 radians) in RADIANS mode
|
|
2198
|
+
# angleMode(DEGREES); rotate(45) # Rotate 45 degrees in DEGREES mode
|
|
2199
|
+
# angleMode(RADIANS); rotate(PI/2) # Rotate 90 degrees in RADIANS mode
|
|
2200
|
+
#
|
|
2142
2201
|
# @see https://processing.org/reference/rotate_.html
|
|
2143
2202
|
# @see https://p5js.org/reference/p5/rotate/
|
|
2144
2203
|
#
|
|
@@ -2340,7 +2399,28 @@ module Processing
|
|
|
2340
2399
|
#
|
|
2341
2400
|
def pushStyle(&block)
|
|
2342
2401
|
assertDrawing__
|
|
2343
|
-
@styleStack__.push
|
|
2402
|
+
@styleStack__.push styles__
|
|
2403
|
+
block.call if block
|
|
2404
|
+
ensure
|
|
2405
|
+
popStyle if block
|
|
2406
|
+
end
|
|
2407
|
+
|
|
2408
|
+
# Restore style values from the style stack.
|
|
2409
|
+
#
|
|
2410
|
+
# @return [nil] nil
|
|
2411
|
+
#
|
|
2412
|
+
# @see https://processing.org/reference/popStyle_.html
|
|
2413
|
+
#
|
|
2414
|
+
def popStyle()
|
|
2415
|
+
assertDrawing__
|
|
2416
|
+
raise "style stack underflow" if @styleStack__.empty?
|
|
2417
|
+
restoreStyles__ @styleStack__.pop
|
|
2418
|
+
nil
|
|
2419
|
+
end
|
|
2420
|
+
|
|
2421
|
+
# @private
|
|
2422
|
+
def styles__()
|
|
2423
|
+
[
|
|
2344
2424
|
@painter__.fill,
|
|
2345
2425
|
@painter__.stroke,
|
|
2346
2426
|
@painter__.stroke_width,
|
|
@@ -2376,20 +2456,10 @@ module Processing
|
|
|
2376
2456
|
@textFont__,
|
|
2377
2457
|
@tint__,
|
|
2378
2458
|
]
|
|
2379
|
-
block.call if block
|
|
2380
|
-
ensure
|
|
2381
|
-
popStyle if block
|
|
2382
2459
|
end
|
|
2383
2460
|
|
|
2384
|
-
#
|
|
2385
|
-
|
|
2386
|
-
# @return [nil] nil
|
|
2387
|
-
#
|
|
2388
|
-
# @see https://processing.org/reference/popStyle_.html
|
|
2389
|
-
#
|
|
2390
|
-
def popStyle()
|
|
2391
|
-
assertDrawing__
|
|
2392
|
-
raise "style stack underflow" if @styleStack__.empty?
|
|
2461
|
+
# @private
|
|
2462
|
+
def restoreStyles__(styles)
|
|
2393
2463
|
@painter__.fill,
|
|
2394
2464
|
@painter__.stroke,
|
|
2395
2465
|
@painter__.stroke_width,
|
|
@@ -2423,9 +2493,8 @@ module Processing
|
|
|
2423
2493
|
@textAlignH__,
|
|
2424
2494
|
@textAlignV__,
|
|
2425
2495
|
@textFont__,
|
|
2426
|
-
@tint__ =
|
|
2496
|
+
@tint__ = styles
|
|
2427
2497
|
@textFont__.setSize__ @painter__.font.size
|
|
2428
|
-
nil
|
|
2429
2498
|
end
|
|
2430
2499
|
|
|
2431
2500
|
# Save current styles and transformations to stack.
|
|
@@ -3129,16 +3198,18 @@ module Processing
|
|
|
3129
3198
|
|
|
3130
3199
|
# Creates a new font object.
|
|
3131
3200
|
#
|
|
3132
|
-
# @param name
|
|
3133
|
-
# @param size
|
|
3201
|
+
# @param name [String] font name
|
|
3202
|
+
# @param size [Numeric] font size (max 256)
|
|
3203
|
+
# @param smooth [Boolean] anti-aliased or pixel-perfect
|
|
3134
3204
|
#
|
|
3135
3205
|
# @return [Font] new font
|
|
3136
3206
|
#
|
|
3137
3207
|
# @see https://processing.org/reference/createFont_.html
|
|
3138
3208
|
#
|
|
3139
|
-
def createFont(name, size)
|
|
3140
|
-
size
|
|
3141
|
-
|
|
3209
|
+
def createFont(name, size, smooth: true)
|
|
3210
|
+
size ||= FONT_SIZE_DEFAULT__
|
|
3211
|
+
size = FONT_SIZE_MAX__ if size > FONT_SIZE_MAX__
|
|
3212
|
+
Font.new Rays::Font.new(name, size, smooth)
|
|
3142
3213
|
end
|
|
3143
3214
|
|
|
3144
3215
|
# Creates a new image object.
|
|
@@ -3291,19 +3362,23 @@ module Processing
|
|
|
3291
3362
|
|
|
3292
3363
|
# Loads font from file.
|
|
3293
3364
|
#
|
|
3294
|
-
# @param filename
|
|
3365
|
+
# @param filename [String] file name to load font file
|
|
3366
|
+
# @param smooth [Boolean] anti-aliased or pixel-perfect
|
|
3295
3367
|
#
|
|
3296
3368
|
# @return [Font] loaded font object
|
|
3297
3369
|
#
|
|
3298
3370
|
# @see https://processing.org/reference/loadFont_.html
|
|
3299
3371
|
# @see https://p5js.org/reference/p5/loadFont/
|
|
3300
3372
|
#
|
|
3301
|
-
def loadFont(filename)
|
|
3373
|
+
def loadFont(filename, size: nil, smooth: true)
|
|
3302
3374
|
ext = File.extname filename
|
|
3303
3375
|
raise "unsupported font type -- '#{ext}'" unless ext =~ /^\.?(ttf|otf)$/i
|
|
3304
3376
|
|
|
3305
|
-
filename
|
|
3306
|
-
|
|
3377
|
+
filename = httpGet__ filename, ext if filename =~ %r|^https?://|
|
|
3378
|
+
font = Rays::Font.load filename
|
|
3379
|
+
font.size = size if size
|
|
3380
|
+
font.smooth = smooth
|
|
3381
|
+
Font.new font
|
|
3307
3382
|
end
|
|
3308
3383
|
|
|
3309
3384
|
# Loads image.
|
data/lib/processing/image.rb
CHANGED
|
@@ -140,6 +140,7 @@ module Processing
|
|
|
140
140
|
# @see https://p5js.org/reference/p5.Image/resize/
|
|
141
141
|
#
|
|
142
142
|
def resize(width, height)
|
|
143
|
+
return nil if width == @image.width && height == @image.height
|
|
143
144
|
@image = Rays::Image.new(width, height).paint do |painter|
|
|
144
145
|
painter.image getInternal__, 0, 0, width, height
|
|
145
146
|
end
|
data/lib/processing/vector.rb
CHANGED
data/lib/processing/window.rb
CHANGED
|
@@ -18,7 +18,9 @@ module Processing
|
|
|
18
18
|
@overlay_view = @canvas_view.add Reflex::View.new name: :overlay
|
|
19
19
|
|
|
20
20
|
super(*args, size: [width, height], **kwargs, &block)
|
|
21
|
+
|
|
21
22
|
self.center = screen.center
|
|
23
|
+
@canvas_view.focus
|
|
22
24
|
end
|
|
23
25
|
|
|
24
26
|
attr_accessor :setup, :update, :draw, :move, :resize, :motion,
|
|
@@ -83,26 +85,6 @@ module Processing
|
|
|
83
85
|
update_canvas_view
|
|
84
86
|
end
|
|
85
87
|
|
|
86
|
-
def on_key_down(e)
|
|
87
|
-
draw_canvas {call_block @key_down, e} if @key_down
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def on_key_up(e)
|
|
91
|
-
draw_canvas {call_block @key_up, e} if @key_up
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def on_note_on(e)
|
|
95
|
-
draw_canvas {call_block @note_on, e} if @note_on
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def on_note_off(e)
|
|
99
|
-
draw_canvas {call_block @note_off, e} if @note_off
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def on_control_change(e)
|
|
103
|
-
draw_canvas {call_block @control_change, e} if @control_change
|
|
104
|
-
end
|
|
105
|
-
|
|
106
88
|
def on_move(e)
|
|
107
89
|
draw_canvas {call_block @move, e} if @move
|
|
108
90
|
end
|
|
@@ -126,6 +108,14 @@ module Processing
|
|
|
126
108
|
draw_screen e.painter
|
|
127
109
|
end
|
|
128
110
|
|
|
111
|
+
def on_canvas_key_down(e)
|
|
112
|
+
draw_canvas {call_block @key_down, e} if @key_down
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def on_canvas_key_up(e)
|
|
116
|
+
draw_canvas {call_block @key_up, e} if @key_up
|
|
117
|
+
end
|
|
118
|
+
|
|
129
119
|
def on_canvas_pointer(e)
|
|
130
120
|
block = case e.action
|
|
131
121
|
when :down then @pointer_down
|
|
@@ -139,6 +129,18 @@ module Processing
|
|
|
139
129
|
draw_canvas {call_block @wheel, e} if @wheel
|
|
140
130
|
end
|
|
141
131
|
|
|
132
|
+
def on_canvas_note_on(e)
|
|
133
|
+
draw_canvas {call_block @note_on, e} if @note_on
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def on_canvas_note_off(e)
|
|
137
|
+
draw_canvas {call_block @note_off, e} if @note_off
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def on_canvas_control_change(e)
|
|
141
|
+
draw_canvas {call_block @control_change, e} if @control_change
|
|
142
|
+
end
|
|
143
|
+
|
|
142
144
|
def on_canvas_resize(e)
|
|
143
145
|
resize_canvas e.width, e.height if @auto_resize
|
|
144
146
|
draw_canvas {call_block @resize, e} if @resize
|
|
@@ -330,6 +332,14 @@ module Processing
|
|
|
330
332
|
window.on_canvas_draw e
|
|
331
333
|
end
|
|
332
334
|
|
|
335
|
+
def on_key_down(e)
|
|
336
|
+
window.on_canvas_key_down e
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
def on_key_up(e)
|
|
340
|
+
window.on_canvas_key_up e
|
|
341
|
+
end
|
|
342
|
+
|
|
333
343
|
def on_pointer(e)
|
|
334
344
|
window.on_canvas_pointer e
|
|
335
345
|
end
|
|
@@ -338,6 +348,18 @@ module Processing
|
|
|
338
348
|
window.on_canvas_wheel e
|
|
339
349
|
end
|
|
340
350
|
|
|
351
|
+
def on_note_on(e)
|
|
352
|
+
window.on_canvas_note_on e
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
def on_note_off(e)
|
|
356
|
+
window.on_canvas_note_off e
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
def on_control_change(e)
|
|
360
|
+
window.on_canvas_control_change e
|
|
361
|
+
end
|
|
362
|
+
|
|
341
363
|
def on_resize(e)
|
|
342
364
|
window.on_canvas_resize e
|
|
343
365
|
end
|
data/processing.gemspec
CHANGED
|
@@ -26,10 +26,10 @@ Gem::Specification.new do |s|
|
|
|
26
26
|
s.required_ruby_version = '>= 3.0.0'
|
|
27
27
|
|
|
28
28
|
s.add_dependency 'rexml'
|
|
29
|
-
s.add_dependency 'xot', '~> 0.3.
|
|
30
|
-
s.add_dependency 'rucy', '~> 0.3.
|
|
31
|
-
s.add_dependency 'rays', '~> 0.3.
|
|
32
|
-
s.add_dependency 'reflexion', '~> 0.3.
|
|
29
|
+
s.add_dependency 'xot', '~> 0.3.10'
|
|
30
|
+
s.add_dependency 'rucy', '~> 0.3.10'
|
|
31
|
+
s.add_dependency 'rays', '~> 0.3.10'
|
|
32
|
+
s.add_dependency 'reflexion', '~> 0.3.11'
|
|
33
33
|
|
|
34
34
|
s.files = `git ls-files`.split $/
|
|
35
35
|
s.test_files = s.files.grep %r{^(test|spec|features)/}
|
data/test/test_graphics.rb
CHANGED
|
@@ -3,6 +3,25 @@ require_relative 'helper'
|
|
|
3
3
|
|
|
4
4
|
class TestGraphics < Test::Unit::TestCase
|
|
5
5
|
|
|
6
|
+
def test_dup()
|
|
7
|
+
g = graphics 1, 1
|
|
8
|
+
assert_equal g.color(0, 0, 0, 0), g.dup.loadPixels[0]
|
|
9
|
+
|
|
10
|
+
g.fill 255, 0, 0
|
|
11
|
+
g.noStroke
|
|
12
|
+
g.beginDraw {g.rect 0, 0, 1, 1}
|
|
13
|
+
assert_equal g.color(255, 0, 0, 255), g.dup.loadPixels[0]
|
|
14
|
+
|
|
15
|
+
g.fill 0, 255, 0
|
|
16
|
+
assert_equal(
|
|
17
|
+
g.color(0, 255, 0, 255),
|
|
18
|
+
g.dup.tap {|gg| gg.beginDraw {gg.rect 0, 0, 1, 1}}.loadPixels[0])
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_size()
|
|
22
|
+
assert_equal [1, 2], graphics(1, 2).size
|
|
23
|
+
end
|
|
24
|
+
|
|
6
25
|
def test_beginDraw()
|
|
7
26
|
g = graphics
|
|
8
27
|
g.beginDraw
|
|
@@ -10,8 +29,7 @@ class TestGraphics < Test::Unit::TestCase
|
|
|
10
29
|
end
|
|
11
30
|
|
|
12
31
|
def test_save()
|
|
13
|
-
g = graphics 100, 100
|
|
14
|
-
g.beginDraw do
|
|
32
|
+
g = graphics 100, 100 do |g|
|
|
15
33
|
g.background 200
|
|
16
34
|
g.fill 255
|
|
17
35
|
g.stroke 0
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: processing
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- xordog
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-04-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rexml
|
|
@@ -30,80 +30,56 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0.3.
|
|
34
|
-
- - ">="
|
|
35
|
-
- !ruby/object:Gem::Version
|
|
36
|
-
version: 0.3.8
|
|
33
|
+
version: 0.3.10
|
|
37
34
|
type: :runtime
|
|
38
35
|
prerelease: false
|
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
37
|
requirements:
|
|
41
38
|
- - "~>"
|
|
42
39
|
- !ruby/object:Gem::Version
|
|
43
|
-
version: 0.3.
|
|
44
|
-
- - ">="
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: 0.3.8
|
|
40
|
+
version: 0.3.10
|
|
47
41
|
- !ruby/object:Gem::Dependency
|
|
48
42
|
name: rucy
|
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
|
50
44
|
requirements:
|
|
51
45
|
- - "~>"
|
|
52
46
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: 0.3.
|
|
54
|
-
- - ">="
|
|
55
|
-
- !ruby/object:Gem::Version
|
|
56
|
-
version: 0.3.8
|
|
47
|
+
version: 0.3.10
|
|
57
48
|
type: :runtime
|
|
58
49
|
prerelease: false
|
|
59
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
60
51
|
requirements:
|
|
61
52
|
- - "~>"
|
|
62
53
|
- !ruby/object:Gem::Version
|
|
63
|
-
version: 0.3.
|
|
64
|
-
- - ">="
|
|
65
|
-
- !ruby/object:Gem::Version
|
|
66
|
-
version: 0.3.8
|
|
54
|
+
version: 0.3.10
|
|
67
55
|
- !ruby/object:Gem::Dependency
|
|
68
56
|
name: rays
|
|
69
57
|
requirement: !ruby/object:Gem::Requirement
|
|
70
58
|
requirements:
|
|
71
59
|
- - "~>"
|
|
72
60
|
- !ruby/object:Gem::Version
|
|
73
|
-
version: 0.3.
|
|
74
|
-
- - ">="
|
|
75
|
-
- !ruby/object:Gem::Version
|
|
76
|
-
version: 0.3.8
|
|
61
|
+
version: 0.3.10
|
|
77
62
|
type: :runtime
|
|
78
63
|
prerelease: false
|
|
79
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
80
65
|
requirements:
|
|
81
66
|
- - "~>"
|
|
82
67
|
- !ruby/object:Gem::Version
|
|
83
|
-
version: 0.3.
|
|
84
|
-
- - ">="
|
|
85
|
-
- !ruby/object:Gem::Version
|
|
86
|
-
version: 0.3.8
|
|
68
|
+
version: 0.3.10
|
|
87
69
|
- !ruby/object:Gem::Dependency
|
|
88
70
|
name: reflexion
|
|
89
71
|
requirement: !ruby/object:Gem::Requirement
|
|
90
72
|
requirements:
|
|
91
73
|
- - "~>"
|
|
92
74
|
- !ruby/object:Gem::Version
|
|
93
|
-
version: 0.3.
|
|
94
|
-
- - ">="
|
|
95
|
-
- !ruby/object:Gem::Version
|
|
96
|
-
version: 0.3.9
|
|
75
|
+
version: 0.3.11
|
|
97
76
|
type: :runtime
|
|
98
77
|
prerelease: false
|
|
99
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
100
79
|
requirements:
|
|
101
80
|
- - "~>"
|
|
102
81
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: 0.3.
|
|
104
|
-
- - ">="
|
|
105
|
-
- !ruby/object:Gem::Version
|
|
106
|
-
version: 0.3.9
|
|
82
|
+
version: 0.3.11
|
|
107
83
|
description: Creative Coding Framework has API compatible to Processing or p5.js.
|
|
108
84
|
email: xordog@gmail.com
|
|
109
85
|
executables: []
|
|
@@ -118,6 +94,7 @@ files:
|
|
|
118
94
|
- ".github/workflows/utils.rb"
|
|
119
95
|
- ".gitignore"
|
|
120
96
|
- ".yardopts"
|
|
97
|
+
- CLAUDE.md
|
|
121
98
|
- CONTRIBUTING.md
|
|
122
99
|
- ChangeLog.md
|
|
123
100
|
- Gemfile
|