processing 0.4.0 → 0.5.0

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: 1b0e4311319c994f90579dafbd3a62b50f623977f6c60c26ba9f0b77a150b564
4
- data.tar.gz: d7f5d796d918ed68ba50cb20fc148a7548b8a84dce0901a4ce1f7236740a994a
3
+ metadata.gz: 530906b18ffcfc45cd88141c8c68857f9e05e4503399d5300188cfb105d1990f
4
+ data.tar.gz: e98b0aa812bbc7a1c3d58b548fe2216631eaba2c5486cca907ec33b5500536f4
5
5
  SHA512:
6
- metadata.gz: b176e101c82a244f61fa3210f5d6902c86f92f94eaac24858e4ab6671fc6983015f64d601d4f8e691ae7351002183cd350b31e27231407e7cc0b7aeb732cdbbd
7
- data.tar.gz: 6d450c5cfaeb5280ab0f600afd421581ceb2dfe25b672f93ea4bfd9ebefd1afacae8ba54c73408bafe828e4522fe003c676299e501831e77c74fd8ab69efdbb7
6
+ metadata.gz: 0e3daa052843fb58bb0842f5eaef522962c32dafdcb295c0e0bc02d0a9476d66d1106f4cc79532285060e776e7d82cebe3c8877908951dc44f8986af72d09f0a
7
+ data.tar.gz: 79b8e742b6922e46c31dcb5f2f0abb3d679fe29ef0bccbf0a188526ae20d771f5950b62351f3c7fa579690a4af26efb823bb25bfa1a39a1fd87ef0ed37c71dd9
@@ -12,10 +12,10 @@ jobs:
12
12
  - name: checkout
13
13
  uses: actions/checkout@v2
14
14
 
15
- - name: ruby 3.0
16
- uses: actions/setup-ruby@v1
15
+ - name: ruby 3.2
16
+ uses: ruby/setup-ruby@v1
17
17
  with:
18
- ruby-version: 3.0.x
18
+ ruby-version: 3.2
19
19
 
20
20
  - name: install gems
21
21
  run: |
@@ -25,7 +25,7 @@ jobs:
25
25
  - name: version
26
26
  id: version
27
27
  run: |
28
- echo ::set-output name=value::$(ruby -e 'print "${{ github.ref }}"[/\/v([\w\.\-]+)/, 1]')
28
+ echo value=$(ruby -e 'print "${{ github.ref }}"[/\/v([\w\.\-]+)/, 1]') >> $GITHUB_OUTPUT
29
29
 
30
30
  - name: create gem
31
31
  run: rake clean gem
@@ -13,10 +13,10 @@ jobs:
13
13
  steps:
14
14
  - uses: actions/checkout@v2
15
15
 
16
- - name: ruby 3.0
17
- uses: actions/setup-ruby@v1
16
+ - name: ruby 3.2
17
+ uses: ruby/setup-ruby@v1
18
18
  with:
19
- ruby-version: 3.0.x
19
+ ruby-version: 3.2
20
20
 
21
21
  - name: install gems
22
22
  run: |
data/ChangeLog.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Processing for CRuby ChangeLog
2
2
 
3
3
 
4
+ ## [0.5.0] - 2023-02-09
5
+
6
+ - requiring 'processing/include' is deprecated
7
+ - require 'processing' and 'using Processing' is now required
8
+ - do not show the window if a draw block is not given
9
+
10
+
4
11
  ## [0.4.0] - 2022-12-29
5
12
 
6
13
  - renamed from rubysketch.gem to processing.gem
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 xord.org
3
+ Copyright (c) 2023 xord.org
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
data/examples/breakout.rb CHANGED
@@ -2,7 +2,8 @@
2
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
4
 
5
- require 'processing/include'
5
+ require 'processing'
6
+ using Processing
6
7
 
7
8
 
8
9
  PADDING = 50
data/examples/camera.rb CHANGED
@@ -2,7 +2,8 @@
2
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
4
 
5
- require 'processing/include'
5
+ require 'processing'
6
+ using Processing
6
7
 
7
8
 
8
9
  cam = Capture.new 300, 300
data/examples/clock.rb CHANGED
@@ -2,7 +2,9 @@
2
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
4
 
5
- require 'processing/include'
5
+ require 'processing'
6
+ using Processing
7
+
6
8
 
7
9
  COLORS = %w[ #F99292 #FFBC61 #FFC679 #FFF4E0 ]
8
10
 
@@ -2,7 +2,8 @@
2
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
4
 
5
- require 'processing/include'
5
+ require 'processing'
6
+ using Processing
6
7
 
7
8
 
8
9
  w, h = width, height
data/examples/hello.rb CHANGED
@@ -2,7 +2,8 @@
2
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
4
 
5
- require 'processing/include'
5
+ require 'processing'
6
+ using Processing
6
7
 
7
8
 
8
9
  draw do
data/examples/image.rb CHANGED
@@ -2,7 +2,8 @@
2
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
4
 
5
- require 'processing/include'
5
+ require 'processing'
6
+ using Processing
6
7
 
7
8
 
8
9
  icon = loadImage 'https://xord.org/rubysketch/images/rubysketch128.png'
data/examples/shapes.rb CHANGED
@@ -2,7 +2,8 @@
2
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
4
 
5
- require 'processing/include'
5
+ require 'processing'
6
+ using Processing
6
7
 
7
8
 
8
9
  setup do
@@ -0,0 +1,20 @@
1
+ require 'set'
2
+ require 'digest/sha1'
3
+ require 'pathname'
4
+ require 'tmpdir'
5
+ require 'open-uri'
6
+ require 'reflex'
7
+
8
+ require 'processing/module'
9
+ require 'processing/app'
10
+ require 'processing/window'
11
+
12
+ require 'processing/vector'
13
+ require 'processing/image'
14
+ require 'processing/font'
15
+ require 'processing/touch'
16
+ require 'processing/shader'
17
+ require 'processing/capture'
18
+ require 'processing/graphics_context'
19
+ require 'processing/graphics'
20
+ require 'processing/context'
@@ -0,0 +1,119 @@
1
+ module Processing
2
+
3
+
4
+ # Camera object.
5
+ #
6
+ class Capture
7
+
8
+ # Returns a list of available camera device names
9
+ #
10
+ # @return [Array] device name list
11
+ #
12
+ def self.list()
13
+ Rays::Camera.device_names
14
+ end
15
+
16
+ # Initialize camera object.
17
+ #
18
+ # @overload Capture.new()
19
+ # @overload Capture.new(cameraName)
20
+ # @overload Capture.new(requestWidth, requestHeight)
21
+ # @overload Capture.new(requestWidth, requestHeight, cameraName)
22
+ #
23
+ # @param requestWidth [Integer] captured image width
24
+ # @param requestHeight [Integer] captured image height
25
+ # @param cameraName [String] camera device name
26
+ #
27
+ def initialize(*args)
28
+ width, height, name =
29
+ if args.empty?
30
+ [-1, -1, nil]
31
+ elsif args[0].kind_of?(String)
32
+ [-1, -1, args[0]]
33
+ elsif args[0].kind_of?(Numeric) && args[1].kind_of?(Numeric)
34
+ [args[0], args[1], args[2]]
35
+ else
36
+ raise ArgumentError
37
+ end
38
+ @camera = Rays::Camera.new width, height, device_name: name
39
+ end
40
+
41
+ # Start capturing.
42
+ #
43
+ # @return [nil] nil
44
+ #
45
+ def start()
46
+ raise "Failed to start capture" unless @camera.start
47
+ nil
48
+ end
49
+
50
+ # Stop capturing.
51
+ #
52
+ # @return [nil] nil
53
+ #
54
+ def stop()
55
+ @camera.stop
56
+ nil
57
+ end
58
+
59
+ # Returns is the next captured image available?
60
+ #
61
+ # @return [Boolean] true means object has next frame
62
+ #
63
+ def available()
64
+ @camera.active?
65
+ end
66
+
67
+ # Reads next frame image
68
+ #
69
+ def read()
70
+ @camera.image
71
+ end
72
+
73
+ # Returns the width of captured image
74
+ #
75
+ # @return [Numeric] the width of captured image
76
+ #
77
+ def width()
78
+ @camera.image&.width || 0
79
+ end
80
+
81
+ # Returns the height of captured image
82
+ #
83
+ # @return [Numeric] the height of captured image
84
+ #
85
+ def height()
86
+ @camera.image&.height || 0
87
+ end
88
+
89
+ # Applies an image filter.
90
+ #
91
+ # overload filter(shader)
92
+ # overload filter(type)
93
+ # overload filter(type, param)
94
+ #
95
+ # @param shader [Shader] a fragment shader to apply
96
+ # @param type [THRESHOLD, GRAY, INVERT, BLUR] filter type
97
+ # @param param [Numeric] a parameter for each filter
98
+ #
99
+ def filter(*args)
100
+ @filter = Shader.createFilter__(*args)
101
+ end
102
+
103
+ # @private
104
+ def getInternal__()
105
+ @camera.image || (@dummyImage ||= Rays::Image.new 1, 1)
106
+ end
107
+
108
+ # @private
109
+ def drawImage__(painter, *args, **states)
110
+ shader = painter.shader || @filter&.getInternal__
111
+ painter.push shader: shader, **states do |_|
112
+ painter.image getInternal__, *args
113
+ end
114
+ end
115
+
116
+ end# Capture
117
+
118
+
119
+ end# Processing