processing 0.5.34 → 1.0.1

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: e54026be3e0523b71c57d18c46525a46dd0291fea20c916c9a77d06398735e15
4
- data.tar.gz: 7c38db77660d2ddddaba759396e54ea6245b1bca132684292e25d306273e433e
3
+ metadata.gz: d7ebe70f2fc384d5892bfc8bf33773451585c82aecc01e36f594803cbd3cbe4c
4
+ data.tar.gz: fccd650cf7fa9e38f499c7d279624c5a30aa5eb40bde70d9a3c6c5c4ce8805f9
5
5
  SHA512:
6
- metadata.gz: 7d2f9f2a261da953754a3476140069d6493b17d1d476bdc7907e35662ce1f9e7633339995f2613871fa3a0f3053cc1397300d1827382270e0783dad80b5f8640
7
- data.tar.gz: 97c6eeff19b69a6874db4f1672bd0d140081fda349ca64850f5c10b7ecf343517e3a87e60bb5b5c5a2b005d89103a8ca1308ce460d55736507c33cb206c9a50f
6
+ metadata.gz: 875bdd9a5bdce3f8aa0b9490e7dd8fa526859999dbef0ac6fe7dcb4984f6c1f76435b550dfbf249ff817fb7e5b07dabea543e9d70c99887baebb0a7c0ecc5c23
7
+ data.tar.gz: 1f7348aaa12c5fc0893e9a6ca6c177daa2efc1c98934ebb5d50fb714638da2a7fd09c563c51c4fdd00ea2f9e634e460d3e5a6ad5ba3e68e9ca09f02c004d28b0
data/ChangeLog.md CHANGED
@@ -1,6 +1,24 @@
1
1
  # processing ChangeLog
2
2
 
3
3
 
4
+ ## [v1.0.1] - 2024-03-14
5
+
6
+ - Add 'rexml' to Gemfile
7
+
8
+
9
+ ## [v1.0] - 2024-03-14
10
+
11
+ - Add stroke(), setStroke(), and setStrokeWeight() to Shape class
12
+ - Add setStrokeCap() and setStrokeJoin() to Shape class
13
+ - Add join type 'miter-clip' and 'arcs'
14
+ - Add color codes
15
+ - Add loadShape()
16
+
17
+ - Rename the join type 'SQUARE' to 'BEVEL'
18
+
19
+ - Fix that <circle> and <ellipse> had half diameters
20
+
21
+
4
22
  ## [v0.5.34] - 2024-02-16
5
23
 
6
24
  - Add '@see' links to documents
data/Gemfile CHANGED
@@ -1,5 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'rexml'
3
4
  gem 'rake'
4
5
  gem 'test-unit'
5
6
  gem 'yard'
data/Gemfile.lock CHANGED
@@ -12,6 +12,7 @@ GEM
12
12
  power_assert (2.0.3)
13
13
  public_suffix (5.0.3)
14
14
  rake (13.1.0)
15
+ rexml (3.2.6)
15
16
  test-unit (3.6.1)
16
17
  power_assert
17
18
  webrick (1.7.0)
@@ -28,6 +29,7 @@ PLATFORMS
28
29
  DEPENDENCIES
29
30
  ferrum
30
31
  rake
32
+ rexml
31
33
  test-unit
32
34
  yard
33
35
 
data/Rakefile CHANGED
@@ -14,15 +14,15 @@ require 'reflex/extension'
14
14
  require 'processing/extension'
15
15
 
16
16
 
17
- def test_with_p5()
18
- ENV['TEST_WITH_P5'] = '1'
17
+ def test_with_browser()
18
+ ENV['TEST_WITH_BROWSER'] = '1'
19
19
  end
20
20
 
21
21
  EXTENSIONS = [Xot, Rucy, Rays, Reflex, Processing]
22
22
 
23
23
  ENV['RDOC'] = 'yardoc --no-private'
24
24
 
25
- #test_with_p5 if ci?
25
+ #test_with_browser if ci?
26
26
 
27
27
  default_tasks
28
28
  use_bundler
@@ -37,8 +37,8 @@ namespace :test do
37
37
  sh %( rm -rf test/.png/*.png )
38
38
  end
39
39
 
40
- task :with_p5 do
41
- test_with_p5
40
+ task :with_browser do
41
+ test_with_browser
42
42
  end
43
43
 
44
44
  ::Rake::TestTask.new :draw do |t|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.34
1
+ 1.0.1
@@ -1,9 +1,11 @@
1
1
  require 'set'
2
+ require 'strscan'
2
3
  require 'digest/sha1'
3
4
  require 'pathname'
4
5
  require 'tmpdir'
5
- require 'net/http'
6
6
  require 'uri'
7
+ require 'rexml'
8
+ require 'net/http'
7
9
  require 'xot/inspectable'
8
10
  require 'reflex'
9
11
 
@@ -16,6 +18,7 @@ require 'processing/image'
16
18
  require 'processing/font'
17
19
  require 'processing/touch'
18
20
  require 'processing/shape'
21
+ require 'processing/svg'
19
22
  require 'processing/shader'
20
23
  require 'processing/capture'
21
24
  require 'processing/graphics_context'
@@ -593,7 +593,6 @@ module Processing
593
593
  #
594
594
  # @return [nil] nil
595
595
  #
596
- #
597
596
  def windowOrientation(*orientations)
598
597
  @window__.orientations = orientations.flatten.uniq
599
598
  end
@@ -70,6 +70,14 @@ module Processing
70
70
  #
71
71
  RADIUS = :radius
72
72
 
73
+ # Mode for strokeCap() and strokeJoin().
74
+ #
75
+ ROUND = :round
76
+
77
+ # Mode for strokeCap().
78
+ #
79
+ SQUARE = :butt
80
+
73
81
  # Mode for strokeCap().
74
82
  #
75
83
  PROJECT = :square
@@ -80,11 +88,7 @@ module Processing
80
88
 
81
89
  # Mode for strokeCap() and strokeJoin().
82
90
  #
83
- ROUND = :round
84
-
85
- # Mode for strokeCap() and strokeJoin().
86
- #
87
- SQUARE = :butt
91
+ BEVEL = :square
88
92
 
89
93
  # Mode for blendMode().
90
94
  #
@@ -292,6 +296,158 @@ module Processing
292
296
  UP = :up
293
297
  DOWN = :down
294
298
 
299
+ COLOR_CODES = {
300
+ aliceblue: '#f0f8ff',
301
+ antiquewhite: '#faebd7',
302
+ aqua: '#00ffff',
303
+ aquamarine: '#7fffd4',
304
+ azure: '#f0ffff',
305
+ beige: '#f5f5dc',
306
+ bisque: '#ffe4c4',
307
+ black: '#000000',
308
+ blanchedalmond: '#ffebcd',
309
+ blue: '#0000ff',
310
+ blueviolet: '#8a2be2',
311
+ brown: '#a52a2a',
312
+ burlywood: '#deb887',
313
+ cadetblue: '#5f9ea0',
314
+ chartreuse: '#7fff00',
315
+ chocolate: '#d2691e',
316
+ coral: '#ff7f50',
317
+ cornflowerblue: '#6495ed',
318
+ cornsilk: '#fff8dc',
319
+ crimson: '#dc143c',
320
+ cyan: '#00ffff',
321
+ darkblue: '#00008b',
322
+ darkcyan: '#008b8b',
323
+ darkgoldenrod: '#b8860b',
324
+ darkgray: '#a9a9a9',
325
+ darkgreen: '#006400',
326
+ darkgrey: '#a9a9a9',
327
+ darkkhaki: '#bdb76b',
328
+ darkmagenta: '#8b008b',
329
+ darkolivegreen: '#556b2f',
330
+ darkorange: '#ff8c00',
331
+ darkorchid: '#9932cc',
332
+ darkred: '#8b0000',
333
+ darksalmon: '#e9967a',
334
+ darkseagreen: '#8fbc8f',
335
+ darkslateblue: '#483d8b',
336
+ darkslategray: '#2f4f4f',
337
+ darkslategrey: '#2f4f4f',
338
+ darkturquoise: '#00ced1',
339
+ darkviolet: '#9400d3',
340
+ deeppink: '#ff1493',
341
+ deepskyblue: '#00bfff',
342
+ dimgray: '#696969',
343
+ dimgrey: '#696969',
344
+ dodgerblue: '#1e90ff',
345
+ firebrick: '#b22222',
346
+ floralwhite: '#fffaf0',
347
+ forestgreen: '#228b22',
348
+ fuchsia: '#ff00ff',
349
+ gainsboro: '#dcdcdc',
350
+ ghostwhite: '#f8f8ff',
351
+ goldenrod: '#daa520',
352
+ gold: '#ffd700',
353
+ gray: '#808080',
354
+ green: '#008000',
355
+ greenyellow: '#adff2f',
356
+ grey: '#808080',
357
+ honeydew: '#f0fff0',
358
+ hotpink: '#ff69b4',
359
+ indianred: '#cd5c5c',
360
+ indigo: '#4b0082',
361
+ ivory: '#fffff0',
362
+ khaki: '#f0e68c',
363
+ lavenderblush: '#fff0f5',
364
+ lavender: '#e6e6fa',
365
+ lawngreen: '#7cfc00',
366
+ lemonchiffon: '#fffacd',
367
+ lightblue: '#add8e6',
368
+ lightcoral: '#f08080',
369
+ lightcyan: '#e0ffff',
370
+ lightgoldenrodyellow: '#fafad2',
371
+ lightgray: '#d3d3d3',
372
+ lightgreen: '#90ee90',
373
+ lightgrey: '#d3d3d3',
374
+ lightpink: '#ffb6c1',
375
+ lightsalmon: '#ffa07a',
376
+ lightseagreen: '#20b2aa',
377
+ lightskyblue: '#87cefa',
378
+ lightslategray: '#778899',
379
+ lightslategrey: '#778899',
380
+ lightsteelblue: '#b0c4de',
381
+ lightyellow: '#ffffe0',
382
+ lime: '#00ff00',
383
+ limegreen: '#32cd32',
384
+ linen: '#faf0e6',
385
+ magenta: '#ff00ff',
386
+ maroon: '#800000',
387
+ mediumaquamarine: '#66cdaa',
388
+ mediumblue: '#0000cd',
389
+ mediumorchid: '#ba55d3',
390
+ mediumpurple: '#9370db',
391
+ mediumseagreen: '#3cb371',
392
+ mediumslateblue: '#7b68ee',
393
+ mediumspringgreen: '#00fa9a',
394
+ mediumturquoise: '#48d1cc',
395
+ mediumvioletred: '#c71585',
396
+ midnightblue: '#191970',
397
+ mintcream: '#f5fffa',
398
+ mistyrose: '#ffe4e1',
399
+ moccasin: '#ffe4b5',
400
+ navajowhite: '#ffdead',
401
+ navy: '#000080',
402
+ oldlace: '#fdf5e6',
403
+ olive: '#808000',
404
+ olivedrab: '#6b8e23',
405
+ orange: '#ffa500',
406
+ orangered: '#ff4500',
407
+ orchid: '#da70d6',
408
+ palegoldenrod: '#eee8aa',
409
+ palegreen: '#98fb98',
410
+ paleturquoise: '#afeeee',
411
+ palevioletred: '#db7093',
412
+ papayawhip: '#ffefd5',
413
+ peachpuff: '#ffdab9',
414
+ peru: '#cd853f',
415
+ pink: '#ffc0cb',
416
+ plum: '#dda0dd',
417
+ powderblue: '#b0e0e6',
418
+ purple: '#800080',
419
+ rebeccapurple: '#663399',
420
+ red: '#ff0000',
421
+ rosybrown: '#bc8f8f',
422
+ royalblue: '#4169e1',
423
+ saddlebrown: '#8b4513',
424
+ salmon: '#fa8072',
425
+ sandybrown: '#f4a460',
426
+ seagreen: '#2e8b57',
427
+ seashell: '#fff5ee',
428
+ sienna: '#a0522d',
429
+ silver: '#c0c0c0',
430
+ skyblue: '#87ceeb',
431
+ slateblue: '#6a5acd',
432
+ slategray: '#708090',
433
+ slategrey: '#708090',
434
+ snow: '#fffafa',
435
+ springgreen: '#00ff7f',
436
+ steelblue: '#4682b4',
437
+ tan: '#d2b48c',
438
+ teal: '#008080',
439
+ thistle: '#d8bfd8',
440
+ tomato: '#ff6347',
441
+ turquoise: '#40e0d0',
442
+ violet: '#ee82ee',
443
+ wheat: '#f5deb3',
444
+ white: '#ffffff',
445
+ whitesmoke: '#f5f5f5',
446
+ yellow: '#ffff00',
447
+ yellowgreen: '#9acd32',
448
+ none: '#00000000',
449
+ }
450
+
295
451
  # @private
296
452
  DEG2RAD__ = Math::PI / 180.0
297
453
 
@@ -535,6 +691,15 @@ module Processing
535
691
  .then {|r, g, b, a| Image.toColor__ r, g, b, a}
536
692
  end
537
693
 
694
+ # @private
695
+ private def color2raw__(color)
696
+ Rays::Color.new(
697
+ ((color >> 16) & 0xff) / 255.0,
698
+ ((color >> 8) & 0xff) / 255.0,
699
+ ( color & 0xff) / 255.0,
700
+ ((color >> 24) & 0xff) / 255.0)
701
+ end
702
+
538
703
  # Returns the red value of the color.
539
704
  #
540
705
  # @param color [Numeric] color value
@@ -597,7 +762,7 @@ module Processing
597
762
  # @see https://p5js.org/reference/#/p5/hue
598
763
  #
599
764
  def hue(color)
600
- h, = toRawColor__(color).to_hsv
765
+ h, = color2raw__(color).to_hsv
601
766
  h * (@hsbColor__ ? @colorMaxes__[0] : 1)
602
767
  end
603
768
 
@@ -611,7 +776,7 @@ module Processing
611
776
  # @see https://p5js.org/reference/#/p5/saturation
612
777
  #
613
778
  def saturation(color)
614
- _, s, = toRawColor__(color).to_hsv
779
+ _, s, = color2raw__(color).to_hsv
615
780
  s * (@hsbColor__ ? @colorMaxes__[1] : 1)
616
781
  end
617
782
 
@@ -625,36 +790,42 @@ module Processing
625
790
  # @see https://p5js.org/reference/#/p5/brightness
626
791
  #
627
792
  def brightness(color)
628
- _, _, b = toRawColor__(color).to_hsv
793
+ _, _, b = color2raw__(color).to_hsv
629
794
  b * (@hsbColor__ ? @colorMaxes__[2] : 1)
630
795
  end
631
796
 
632
797
  # @private
633
798
  private def toRGBA__(*args)
634
- a, b = args
635
- return parseColor__(a, b || alphaMax__) if a.kind_of?(String)
636
- rawColor__(*args).to_a
799
+ toRawColor__(*args).to_a
637
800
  end
638
801
 
639
802
  # @private
640
- def rawColor__(*args)
803
+ def toRawColor__(*args)
641
804
  a, b, c, d = args
642
- rgba = case args.size
805
+ return parseColor__(a, b || alphaMax__) if a.is_a?(String) || a.is_a?(Symbol)
806
+ rgba =
807
+ case args.size
643
808
  when 1, 2 then [a, a, a, b || alphaMax__]
644
809
  when 3, 4 then [a, b, c, d || alphaMax__]
645
810
  else raise ArgumentError
646
811
  end
647
- rgba = rgba.map.with_index {|value, i| value / @colorMaxes__[i]}
812
+ rgba = rgba.map.with_index {|n, i| n / @colorMaxes__[i]}
648
813
  @hsbColor__ ? Rays::Color.hsv(*rgba) : Rays::Color.new(*rgba)
649
814
  end
650
815
 
651
816
  # @private
652
817
  private def parseColor__(str, alpha)
653
- result = str.match(/^\s*##{'([0-9a-f]{2})' * 3}\s*$/i)
654
- raise ArgumentError, "invalid color code: '#{str}'" unless result
655
-
656
- rgb = result[1..3].map.with_index {|hex, i| hex.to_i(16) / 255.0}
657
- return *rgb, (alpha / alphaMax__)
818
+ str = COLOR_CODES[str.downcase.to_sym] || str if str !~ /^\s*#\d+/
819
+ r, g, b, a =
820
+ case str
821
+ when /^\s*##{'([0-9a-f]{2})' * 3}([0-9a-f]{2})?\s*$/i
822
+ $~[1..4].map {|n| n.to_i(16) / 255.0 if n}
823
+ when /^\s*##{'([0-9a-f]{1})' * 3}([0-9a-f]{1})?\s*$/i
824
+ $~[1..4].map {|n| n.to_i(16) / 15.0 if n}
825
+ else
826
+ raise ArgumentError, "invalid color code: '#{str}'"
827
+ end
828
+ Rays::Color.new(r, g, b, a || (alpha / alphaMax__))
658
829
  end
659
830
 
660
831
  # @private
@@ -662,15 +833,6 @@ module Processing
662
833
  @colorMaxes__[3]
663
834
  end
664
835
 
665
- # @private
666
- private def toRawColor__(color)
667
- Rays::Color.new(
668
- ((color >> 16) & 0xff) / 255.0,
669
- ((color >> 8) & 0xff) / 255.0,
670
- ( color & 0xff) / 255.0,
671
- ((color >> 24) & 0xff) / 255.0)
672
- end
673
-
674
836
  # Sets angle mode.
675
837
  #
676
838
  # @param mode [RADIANS, DEGREES] RADIANS or DEGREES
@@ -835,11 +997,6 @@ module Processing
835
997
  nil
836
998
  end
837
999
 
838
- # @private
839
- def getFill__()
840
- @painter__.fill
841
- end
842
-
843
1000
  # Disables filling.
844
1001
  #
845
1002
  # @return [nil] nil
@@ -905,8 +1062,9 @@ module Processing
905
1062
  end
906
1063
 
907
1064
  # Sets stroke cap mode.
1065
+ # The default cap if ROUND.
908
1066
  #
909
- # @param cap [BUTT, ROUND, SQUARE]
1067
+ # @param cap [ROUND, SQUARE, PROJECT]
910
1068
  #
911
1069
  # @return [nil] nil
912
1070
  #
@@ -919,8 +1077,9 @@ module Processing
919
1077
  end
920
1078
 
921
1079
  # Sets stroke join mode.
1080
+ # The default join is MITER.
922
1081
  #
923
- # @param join [MITER, ROUND, SQUARE]
1082
+ # @param join [MITER, BEVEL, ROUND]
924
1083
  #
925
1084
  # @return [nil] nil
926
1085
  #
@@ -2288,6 +2447,11 @@ module Processing
2288
2447
  popStyle
2289
2448
  end
2290
2449
 
2450
+ # @private
2451
+ def getPainter__()
2452
+ @painter__
2453
+ end
2454
+
2291
2455
  # @private
2292
2456
  def getInternal__()
2293
2457
  @image__
@@ -3021,19 +3185,19 @@ module Processing
3021
3185
  end
3022
3186
 
3023
3187
  # @private
3024
- private def createLineShape__(x1, y1, x2, y2)
3188
+ def createLineShape__(x1, y1, x2, y2)
3025
3189
  Shape.new Rays::Polygon.line(x1, y1, x2, y2), context: self
3026
3190
  end
3027
3191
 
3028
3192
  # @private
3029
- private def createRectShape__(a, b, c, d)
3030
- x, y, w, h = toXYWH__ @rectMode__, a, b, c, d
3031
- Shape.new Rays::Polygon.rect(x, y, w, h), context: self
3193
+ def createRectShape__(a, b, c, d, *args, mode: @rectMode__)
3194
+ x, y, w, h = toXYWH__ mode, a, b, c, d
3195
+ Shape.new Rays::Polygon.rect(x, y, w, h, *args), context: self
3032
3196
  end
3033
3197
 
3034
3198
  # @private
3035
- private def createEllipseShape__(a, b, c, d)
3036
- x, y, w, h = toXYWH__ @ellipseMode__, a, b, c, d
3199
+ def createEllipseShape__(a, b, c, d, mode: @ellipseMode__)
3200
+ x, y, w, h = toXYWH__ mode, a, b, c, d
3037
3201
  Shape.new Rays::Polygon.ellipse(x, y, w, h), context: self
3038
3202
  end
3039
3203
 
@@ -3174,6 +3338,10 @@ module Processing
3174
3338
  img
3175
3339
  end
3176
3340
 
3341
+ def loadShape(filename)
3342
+ Processing::SVGLoader.new(self).load filename
3343
+ end
3344
+
3177
3345
  # Loads shader file.
3178
3346
  #
3179
3347
  # @overload loadShader(fragPath)
@@ -214,11 +214,6 @@ module Processing
214
214
  raise NotImplementedError
215
215
  end
216
216
 
217
- # @private
218
- def setFrame__()
219
- raise NotImplementedError
220
- end
221
-
222
217
  # @private
223
218
  def getCurrentFrame__()
224
219
  raise NotImplementedError