ruby-processing 2.6.10 → 2.6.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rpextras.jar +0 -0
- data/lib/ruby-processing/runners/watch.rb +1 -1
- data/lib/ruby-processing/version.rb +1 -1
- data/lib/templates/application/Contents/Info.plist.erb +1 -1
- data/library/library_proxy/README.md +97 -0
- data/library/library_proxy/library_proxy.rb +10 -0
- data/library/video_event/video_event.rb +12 -0
- data/vendors/Rakefile +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95f093af92488a7783924a932a086c10e2e81058
|
4
|
+
data.tar.gz: 77868bd9e219521101a104c4d6d0207f77b5c877
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76ad255dc7e19dc407f787523d0c26d1be56cdcfbb8329ff4f0fae5c2b5e3a609bc4f7d310a7f7abb342808fb892acf3b183e429cca8b0f3a72641bf604977ad
|
7
|
+
data.tar.gz: ef356cde4063ee9b2d7bd5f1e8fb00e5f8e37898ef9b6a68426bde2d3d8e9cb92e74171d336a47050c5bb422bcb481be552bf4b5ddba1f9987485637189179a9
|
data/lib/rpextras.jar
CHANGED
Binary file
|
@@ -0,0 +1,97 @@
|
|
1
|
+
### Using the LibraryProxy in your sketches
|
2
|
+
In the sketch you should `load_library :library_proxy` and your library class should inherit
|
3
|
+
from LibraryProxy and implement pre(), draw() and post() methods (can be empty method if not
|
4
|
+
required). For simplicity initialize your `processing library` in the sketch `setup`.
|
5
|
+
|
6
|
+
### Example library
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
require 'forwardable'
|
10
|
+
|
11
|
+
# A custom Array created using forwardable (that can also access the PApplet pre,
|
12
|
+
# post and draw loops by extending our new LibraryProxy class. Also has access
|
13
|
+
# to custom background(int), fill(int) and stroke(int) methods.
|
14
|
+
class CustomArray < LibraryProxy
|
15
|
+
extend Forwardable
|
16
|
+
def_delegators(:@objs, :each, :<<)
|
17
|
+
include Enumerable
|
18
|
+
|
19
|
+
attr_reader :app
|
20
|
+
|
21
|
+
# We must initialize class with the PApplet instance
|
22
|
+
def initialize(app)
|
23
|
+
@app = app
|
24
|
+
@objs = []
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_object(mx, my, x, y, speed)
|
28
|
+
self << Particle.new(x.to_i, y.to_i, mx, my, Sketch::UNIT, speed, 1, 1)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Access the processing post loop (gets called after draw)
|
32
|
+
def post
|
33
|
+
each do |obj|
|
34
|
+
update_x obj
|
35
|
+
next unless obj.y >= Sketch::UNIT || obj.x <= 0
|
36
|
+
obj.ydir *= -1
|
37
|
+
obj.y += obj.ydir
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def update_x(obj)
|
42
|
+
obj.x += obj.speed * obj.xdir
|
43
|
+
return if (0..Sketch::UNIT).cover? obj.x
|
44
|
+
obj.xdir *= -1
|
45
|
+
obj.x += obj.xdir
|
46
|
+
obj.y += obj.ydir
|
47
|
+
end
|
48
|
+
|
49
|
+
# We need this to fulfill the contract of implementing abstract methods of
|
50
|
+
# LibraryProxy which is an alias for Java::ProcessingCore::AbstractLibrary
|
51
|
+
def pre
|
52
|
+
end
|
53
|
+
|
54
|
+
# Access the processing draw loop here, using our custom background and fill
|
55
|
+
# note: use of 'app' to access ellipse functionality as would otherwise be
|
56
|
+
# required for background and fill
|
57
|
+
def draw
|
58
|
+
background(0)
|
59
|
+
fill(255)
|
60
|
+
each do |obj|
|
61
|
+
app.ellipse(obj.mx + obj.x, obj.my + obj.y, 6, 6)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# The Particle object
|
67
|
+
|
68
|
+
Particle = Struct.new(:x, :y, :mx, :my, :size, :speed, :xdir, :ydir)
|
69
|
+
```
|
70
|
+
### Example sketch
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
# A minimalist sketch that demonstrates a possible approach to creating a custom
|
74
|
+
# array of objects using forwardable. Also demonstrates how to use LibraryProxy.
|
75
|
+
|
76
|
+
load_library :library_proxy # loads the JRubyArt LibraryProxy abstract class
|
77
|
+
require_relative 'custom_array' # loads our custom 'library' class
|
78
|
+
|
79
|
+
UNIT = 40
|
80
|
+
|
81
|
+
def setup
|
82
|
+
size 640, 360
|
83
|
+
wide_count = width / UNIT
|
84
|
+
height_count = height / UNIT
|
85
|
+
custom_array = CustomArray.new(self)
|
86
|
+
height_count.times do |i|
|
87
|
+
wide_count.times do |j|
|
88
|
+
custom_array.add_object(j * UNIT, i * UNIT, UNIT / 2, UNIT / 2, rand(0.05..0.8))
|
89
|
+
end
|
90
|
+
end
|
91
|
+
no_stroke
|
92
|
+
end
|
93
|
+
|
94
|
+
# does nothing here see custom_array.rb
|
95
|
+
def draw
|
96
|
+
end
|
97
|
+
```
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'rpextras'
|
2
|
+
|
3
|
+
LibraryProxy = Java::ProcessingCore::AbstractLibrary
|
4
|
+
|
5
|
+
# classes that inherit from Library are expected to implement
|
6
|
+
# the abstract methods of processing.core.AbstractLibrary
|
7
|
+
# def pre...
|
8
|
+
# def draw...
|
9
|
+
# def post...
|
10
|
+
# NOOP is fine...
|
data/vendors/Rakefile
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-processing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Ashkenas
|
@@ -16,7 +16,7 @@ authors:
|
|
16
16
|
autorequire:
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
|
-
date: 2015-
|
19
|
+
date: 2015-06-07 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,6 +90,7 @@ extensions: []
|
|
90
90
|
extra_rdoc_files: []
|
91
91
|
files:
|
92
92
|
- bin/rp5
|
93
|
+
- lib/rpextras.jar
|
93
94
|
- lib/ruby-processing.rb
|
94
95
|
- lib/ruby-processing/app.rb
|
95
96
|
- lib/ruby-processing/config.rb
|
@@ -123,9 +124,11 @@ files:
|
|
123
124
|
- library/control_panel/control_panel.rb
|
124
125
|
- library/fastmath/fastmath.rb
|
125
126
|
- library/file_chooser/file_chooser.rb
|
127
|
+
- library/library_proxy/README.md
|
128
|
+
- library/library_proxy/library_proxy.rb
|
126
129
|
- library/vecmath/vecmath.rb
|
130
|
+
- library/video_event/video_event.rb
|
127
131
|
- vendors/Rakefile
|
128
|
-
- lib/rpextras.jar
|
129
132
|
homepage: http://wiki.github.com/jashkenas/ruby-processing
|
130
133
|
licenses:
|
131
134
|
- MIT
|
@@ -149,7 +152,7 @@ requirements:
|
|
149
152
|
- java runtime >= 1.7+
|
150
153
|
- processing = 2.2.1+
|
151
154
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.
|
155
|
+
rubygems_version: 2.4.6
|
153
156
|
signing_key:
|
154
157
|
specification_version: 4
|
155
158
|
summary: Code as Art, Art as Code. Processing and Ruby are meant for each other.
|