jruby_art 0.2.6.pre → 0.3.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/k9 +2 -2
- data/lib/jruby_art.rb +18 -23
- data/lib/jruby_art/app.rb +118 -130
- data/lib/jruby_art/config.rb +7 -9
- data/lib/jruby_art/creators/creator.rb +189 -0
- data/lib/jruby_art/helper_methods.rb +41 -31
- data/lib/jruby_art/helpers/camel_string.rb +2 -1
- data/lib/jruby_art/helpers/numeric.rb +1 -2
- data/lib/jruby_art/helpers/range.rb +3 -7
- data/lib/jruby_art/helpers/string_extra.rb +1 -1
- data/lib/jruby_art/library_loader.rb +127 -96
- data/lib/jruby_art/runner.rb +208 -63
- data/lib/jruby_art/runners/base.rb +51 -0
- data/lib/jruby_art/runners/run.rb +6 -0
- data/lib/jruby_art/runners/watch.rb +59 -0
- data/lib/jruby_art/version.rb +1 -2
- data/lib/rpextras.jar +0 -0
- data/library/library_proxy/README.md +97 -0
- data/library/library_proxy/library_proxy.rb +8 -1
- data/library/video_event/video_event.rb +4 -0
- data/vendors/Rakefile +33 -78
- metadata +54 -60
- data/CHANGELOG.md +0 -60
- data/LICENSE.md +0 -39
- data/README.md +0 -91
- data/Rakefile +0 -85
- data/lib/core.jar +0 -0
- data/lib/gluegen-rt-natives-linux-amd64.jar +0 -0
- data/lib/gluegen-rt-natives-linux-armv6hf.jar +0 -0
- data/lib/gluegen-rt-natives-linux-i586.jar +0 -0
- data/lib/gluegen-rt-natives-macosx-universal.jar +0 -0
- data/lib/gluegen-rt-natives-windows-amd64.jar +0 -0
- data/lib/gluegen-rt-natives-windows-i586.jar +0 -0
- data/lib/gluegen-rt.jar +0 -0
- data/lib/jogl-all-natives-linux-amd64.jar +0 -0
- data/lib/jogl-all-natives-linux-armv6hf.jar +0 -0
- data/lib/jogl-all-natives-linux-i586.jar +0 -0
- data/lib/jogl-all-natives-macosx-universal.jar +0 -0
- data/lib/jogl-all-natives-windows-amd64.jar +0 -0
- data/lib/jogl-all-natives-windows-i586.jar +0 -0
- data/lib/jogl-all.jar +0 -0
- data/lib/jruby_art/creator.rb +0 -100
- data/lib/jruby_art/parse.rb +0 -59
- data/lib/jruby_art/writer.rb +0 -40
- data/library/file_chooser/file_chooser.rb +0 -82
- data/library/grammar/grammar.rb +0 -31
- data/library/video/lib/export.txt +0 -1
- data/library/video/lib/macosx64.txt +0 -1
- data/library/video/lib/windows.txt +0 -3
- data/library/video/video.rb +0 -12
- data/spec/app_spec.rb +0 -208
- data/spec/deglut_spec.rb +0 -25
- data/spec/library_loader_spec.rb +0 -23
- data/spec/spec_helper.rb +0 -96
- data/spec/vecmath_spec.rb +0 -483
- data/vendors/config.tar.gz +0 -0
data/CHANGELOG.md
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
## JRubyArt CHANGELOG
|
2
|
-
|
3
|
-
It might seem a little of that this log starts at version 0.1.2, the reason for this is that previous version relate to earlier versions which were essentially a clone of ruby-processing.
|
4
|
-
### Version 0.2.6
|
5
|
-
|
6
|
-
Enable use of 'videoEvent' and 'captureEvent' java reflection methods by creating a 'VideoInterface' in a java class.
|
7
|
-
|
8
|
-
|
9
|
-
### Version 0.2.5
|
10
|
-
|
11
|
-
jruby-1.7.20 version
|
12
|
-
Revert to Processing::Proxy as a module, but implement :method_missing (after tyfkda processing ruby-mode), and java_import PConstants in that module. Require 'yaml' rather than 'psych' as workaround for builtin 'psych' in jruby.
|
13
|
-
|
14
|
-
### Version 0.2.4
|
15
|
-
|
16
|
-
Can't wait forever for jruby-9000, this release is required to promote the new [toxiclibs gem][].
|
17
|
-
|
18
|
-
### Version 0.2.3
|
19
|
-
|
20
|
-
Now using curl instead of wget "following the path of least resistance for enfeebled Mac users" and also there might be better Windows support for curl vs wget. Now includes a library loader for jars (supports video and sound library etc), added control_panel and boids library.
|
21
|
-
|
22
|
-
### Version 0.2.2
|
23
|
-
This was meant to be the pre-jruby-9000 version, but is now the pre library_loader
|
24
|
-
version
|
25
|
-
|
26
|
-
### Version 0.2.1
|
27
|
-
|
28
|
-
Features jruby-complete-1.7.19 and filtered native jars (attempt at load according to OS and Arch) works linux64
|
29
|
-
|
30
|
-
### Version 0.2.0
|
31
|
-
|
32
|
-
First pre release version features jruby-complete-1.7.18
|
33
|
-
|
34
|
-
### Version 0.1.7
|
35
|
-
|
36
|
-
Now installs jruby-complete-1.7.17 (which is a good deal smaller), also includes experimental Proxy extension to access draw, pre and post loops by reflection
|
37
|
-
|
38
|
-
### Version 0.1.6
|
39
|
-
|
40
|
-
Vec2D and Vec3D get `:to_curve_vertex`, see included example. Also new in examples is how to use jar libraries (toxiclibs) with JRubyArt.
|
41
|
-
|
42
|
-
### Version 0.1.5
|
43
|
-
|
44
|
-
Now you can wrap a bare sketch with `k9 wrap sketch.rb` sensibly wraps bare P2D, P3D and default processing mode sketches. The runner now laso makes a similar check.
|
45
|
-
|
46
|
-
### Version 0.1.4
|
47
|
-
|
48
|
-
Now with k9 you can run `bare` sketches, like original ruby-processing but with less sugar. So instead of `cos` use `Math,cos` etc, further no attempt has been made to mimic processing inner-class behaviour (bad OO practice).
|
49
|
-
|
50
|
-
|
51
|
-
### Version 0.1.3
|
52
|
-
|
53
|
-
Move config file from ~/.k9rc to ~/.jruby_art/config.yml, created installer for jruby-complete.jar. For sketches needing to be run with jruby-complete use `k9 run sketch.rb` (this includes shader sketches with `load_image`) or use netbeans with jruby-plugin to develop your sketches. For 3D sketches (or to use P2D) inherit from AppGL, both AppGL and App inherit directly from PApplet. Examples have been moved to there own repo `k9 setup install` downloads and install jruby-complete and downloads and extracts sample to users HOME directory.
|
54
|
-
|
55
|
-
|
56
|
-
### Version 0.1.2
|
57
|
-
|
58
|
-
First point release, requires user build, supports 2D and opengl sketches, but no library support. Sketches will only run with jruby (jruby-complete is not included). To run sketches with load_image jruby-complete is required, so either provide that or use netbeans as your ide (with jruby plugin).
|
59
|
-
|
60
|
-
[toxiclibs gem]:https://github.com/ruby-processing/toxicgem
|
data/LICENSE.md
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
JRubyArt is released under the MIT License.
|
2
|
-
You can do pretty much whatever you'd like with it.
|
3
|
-
|
4
|
-
___
|
5
|
-
|
6
|
-
Copyright (c) 2013 Martin Prout
|
7
|
-
|
8
|
-
Permission is hereby granted, free of charge,
|
9
|
-
to any person obtaining a copy of this software
|
10
|
-
and associated documentation files (the "Software"),
|
11
|
-
to deal in the Software without restriction,
|
12
|
-
including without limitation the rights to use,
|
13
|
-
copy, modify, merge, publish, distribute, sublicense,
|
14
|
-
and/or sell copies of the Software, and to permit
|
15
|
-
persons to whom the Software is furnished to do so,
|
16
|
-
subject to the following conditions:
|
17
|
-
|
18
|
-
The above copyright notice and this permission
|
19
|
-
notice shall be included in all copies or substantial
|
20
|
-
portions of the Software.
|
21
|
-
|
22
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY
|
23
|
-
OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
24
|
-
LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
25
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
26
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
27
|
-
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
28
|
-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
29
|
-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
30
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
-
|
32
|
-
___
|
33
|
-
|
34
|
-
JRubyArt depends on core components
|
35
|
-
of both [JRuby][] and [Processing][] both of which are
|
36
|
-
licensed under the GNU lesser public license
|
37
|
-
|
38
|
-
[jruby]: http://www.jruby.org/
|
39
|
-
[processing]: http://www.processing.org/
|
data/README.md
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
## JRubyArt
|
2
|
-
[![Gem Version](https://badge.fury.io/rb/jruby_art.svg)](http://badge.fury.io/rb/jruby_art)
|
3
|
-
|
4
|
-
Is an alternative implementation of [ruby-processing][] that provides a ruby-wrapper for the java version of [processing][]. It is currently at the pre-release stage, but is ready for testing, and available from rubygems.org.
|
5
|
-
Core processing jars are included, so it does not require a vanilla processing install..., you should perhaps consider making a contribution to the [processing foundation][].
|
6
|
-
|
7
|
-
### Requirements
|
8
|
-
|
9
|
-
Java runtime 7+, and ruby (can be MRI ruby), curl (to download jruby-complete and examples, although there is a workaround).
|
10
|
-
|
11
|
-
### Getting Started
|
12
|
-
|
13
|
-
```bash
|
14
|
-
gem install jruby-art --pre
|
15
|
-
k9 setup install # uses curl to to download jruby-complete and examples
|
16
|
-
cd examples/contributed
|
17
|
-
k9 run clock.rb # if you've got jruby on your machine `jruby clock.rb` also works
|
18
|
-
```
|
19
|
-
|
20
|
-
### Creating your own
|
21
|
-
```bash
|
22
|
-
k9 create my_sketch 200 200
|
23
|
-
vim my_sketch.rb # other editors are available
|
24
|
-
```
|
25
|
-
Output:
|
26
|
-
```ruby
|
27
|
-
require 'jruby_art'
|
28
|
-
|
29
|
-
class MySketch < Processing::App
|
30
|
-
def setup
|
31
|
-
size 200, 200
|
32
|
-
end
|
33
|
-
|
34
|
-
def draw
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
MySketch.new(title: 'My Sketch')
|
40
|
-
```
|
41
|
-
The above is an example of class wrapped sketch (that can be run using `jruby my_sketch.rb` or `k9 run my_sketch.rb`), bare sketches also work. See [examples/bare_sketches][]
|
42
|
-
```ruby
|
43
|
-
def setup
|
44
|
-
size 200, 200
|
45
|
-
end
|
46
|
-
|
47
|
-
def draw
|
48
|
-
|
49
|
-
end
|
50
|
-
```
|
51
|
-
However such sketches must be run with `k9 run sketch.rb`, however you can do 'k9 wrap sketch.rb` which converts bare sketches to a class wrapped form.
|
52
|
-
|
53
|
-
###Ruby Versions
|
54
|
-
|
55
|
-
jruby-1.7.20 (when sketches run with jruby command)
|
56
|
-
|
57
|
-
jruby-9.0.0.0.pre2 also seems to work (the next pre-release will probably target jruby-9.0.0.0-pre2)
|
58
|
-
|
59
|
-
or
|
60
|
-
|
61
|
-
ruby-2.1.2+ (when sketches are run using k9 command, ie using jruby-complete with jruby-9.0.0.0)
|
62
|
-
|
63
|
-
### Using netbeans as an ide for JRubyArt
|
64
|
-
|
65
|
-
See [netbeans][]
|
66
|
-
|
67
|
-
___
|
68
|
-
|
69
|
-
[Contributing][]
|
70
|
-
|
71
|
-
[License][]
|
72
|
-
|
73
|
-
[Acknowledgements][]
|
74
|
-
|
75
|
-
[Examples][]
|
76
|
-
|
77
|
-
[CHANGELOG][]
|
78
|
-
|
79
|
-
[Building latest gem](https://github.com/ruby-processing/JRubyArt/wiki/Building-latest-gem/)
|
80
|
-
[Acknowledgements]:ACKNOWLEDGEMENTS.md
|
81
|
-
[CHANGELOG]:CHANGELOG.md
|
82
|
-
[Contributing]:CONTRIBUTING.md
|
83
|
-
[Examples]:https://github.com/ruby-processing/JRubyArt-examples
|
84
|
-
[examples/bare_sketches]:https://github.com/ruby-processing/JRubyArt-examples/tree/master/bare_sketches
|
85
|
-
[License]:LICENSE.md
|
86
|
-
[processing]:https://github.com/processing/processing
|
87
|
-
[ruby-processing]:https://github.com/jashkenas/ruby-processing
|
88
|
-
[netbeans]:http://learning-ruby-processing.blogspot.co.uk/2014/10/alternative-ruby-processing-implentation.html
|
89
|
-
[processing-2.2.1]:https://processing.org/download/
|
90
|
-
[processing-core]:https://github.com/ruby-processing/processing-core/blob/master/README.md
|
91
|
-
[processing foundation]:https://processing.org/download/
|
data/Rakefile
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'rake/clean'
|
4
|
-
require 'rubygems/package_task'
|
5
|
-
require 'rdoc/task'
|
6
|
-
require 'rake/testtask'
|
7
|
-
require_relative 'lib/jruby_art/version'
|
8
|
-
|
9
|
-
CLEAN.include('tmp')
|
10
|
-
CLOBBER.include(Rake::FileList.new('lib/*.jar'))
|
11
|
-
|
12
|
-
spec = Gem::Specification.new do |s|
|
13
|
-
s.name = 'jruby_art'
|
14
|
-
s.version = JRubyArt::VERSION
|
15
|
-
s.has_rdoc = true
|
16
|
-
s.extra_rdoc_files = ['README.md', 'LICENSE.md', 'CHANGELOG.md']
|
17
|
-
s.summary = 'Ruby processing development branch'
|
18
|
-
s.description = "A ruby wrapper for processing, that doesn't require a separate install of processing"
|
19
|
-
s.license = 'MIT'
|
20
|
-
s.author = 'Martin Prout'
|
21
|
-
s.email = 'mamba2928@yahoo.co.uk'
|
22
|
-
s.homepage = 'https://github.com/ruby-processing/JRubyArt'
|
23
|
-
s.executables << 'k9'
|
24
|
-
s.files = %w(LICENSE.md README.md Rakefile CHANGELOG.md) + Dir.glob('{bin,lib,library,spec,vendors}/**/*')
|
25
|
-
s.require_path = 'lib'
|
26
|
-
s.required_ruby_version = '~> 2.0'
|
27
|
-
s.add_development_dependency 'rake', '~> 10.4'
|
28
|
-
s.add_development_dependency 'rspec', '~> 3.2'
|
29
|
-
s.add_development_dependency 'rake-compiler', '~> 0.9'
|
30
|
-
s.requirements << 'A decent graphics card'
|
31
|
-
s.requirements << 'java runtime >= 1.7+'
|
32
|
-
end
|
33
|
-
|
34
|
-
# -*- ruby -*-
|
35
|
-
|
36
|
-
require 'java'
|
37
|
-
require 'rake/javaextensiontask'
|
38
|
-
|
39
|
-
# -*- encoding: utf-8 -*-
|
40
|
-
require 'psych'
|
41
|
-
|
42
|
-
def copy_jars(name, dest)
|
43
|
-
conf = '~/.jruby_art/config.yml'
|
44
|
-
begin
|
45
|
-
path = File.expand_path(conf)
|
46
|
-
rp_config = (Psych.load_file(path))
|
47
|
-
source = "#{rp_config['PROCESSING_ROOT']}/core/library/"
|
48
|
-
rescue
|
49
|
-
raise "WARNING: you must set PROCESSING_ROOT in #{conf} compile"
|
50
|
-
end
|
51
|
-
body = proc {
|
52
|
-
Dir["#{source}/*.jar"].each do |f|
|
53
|
-
puts "Copying #{f} To #{dest}"
|
54
|
-
FileUtils.cp f, dest
|
55
|
-
end
|
56
|
-
}
|
57
|
-
Rake::Task.define_task(name, &body)
|
58
|
-
end
|
59
|
-
|
60
|
-
copy_jars(:processing_jars, 'lib')
|
61
|
-
|
62
|
-
Rake::JavaExtensionTask.new('processing') do |ext|
|
63
|
-
jars = FileList['lib/*.jar']
|
64
|
-
ext.classpath = jars.map { |x| File.expand_path x }.join ':'
|
65
|
-
ext.name = 'rpextras'
|
66
|
-
ext.debug = true
|
67
|
-
ext.lib_dir = 'lib'
|
68
|
-
ext.source_version = '1.7'
|
69
|
-
ext.target_version = '1.7'
|
70
|
-
end
|
71
|
-
|
72
|
-
Gem::PackageTask.new(spec) do |p|
|
73
|
-
p.gem_spec = spec
|
74
|
-
p.need_tar = false
|
75
|
-
p.need_zip = false
|
76
|
-
end
|
77
|
-
|
78
|
-
Rake::RDocTask.new do |rdoc|
|
79
|
-
files = ['README.md', 'LICENSE.md', 'lib/**/*.rb', 'library']
|
80
|
-
rdoc.rdoc_files.add(files)
|
81
|
-
rdoc.main = 'README.md' # page to start on
|
82
|
-
rdoc.title = 'JRubyArt Docs'
|
83
|
-
rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
|
84
|
-
rdoc.options << '--line-numbers'
|
85
|
-
end
|
data/lib/core.jar
DELETED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/gluegen-rt.jar
DELETED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/jogl-all.jar
DELETED
Binary file
|
data/lib/jruby_art/creator.rb
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
CLASS_BASIC = <<-CODE
|
2
|
-
require 'jruby_art'
|
3
|
-
|
4
|
-
class %s < Processing::App
|
5
|
-
def setup
|
6
|
-
size %s, %s
|
7
|
-
end
|
8
|
-
|
9
|
-
def draw
|
10
|
-
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
%s.new(title: '%s')
|
15
|
-
CODE
|
16
|
-
|
17
|
-
CLASS_MODE = <<-CODE
|
18
|
-
require 'jruby_art'
|
19
|
-
|
20
|
-
class %s < Processing::AppGL
|
21
|
-
def setup
|
22
|
-
size %s, %s, %s
|
23
|
-
end
|
24
|
-
|
25
|
-
def draw
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
%s.new(title: '%s')
|
31
|
-
CODE
|
32
|
-
|
33
|
-
module Processing
|
34
|
-
require_relative '../jruby_art/helpers/string_extra'
|
35
|
-
require_relative '../jruby_art/helpers/camel_string'
|
36
|
-
# Write file to disk
|
37
|
-
class SketchWriter
|
38
|
-
attr_reader :file
|
39
|
-
def initialize(path)
|
40
|
-
underscore = StringExtra.new(path).underscore
|
41
|
-
@file = "#{File.dirname(path)}/#{underscore}.rb"
|
42
|
-
end
|
43
|
-
|
44
|
-
def save(template)
|
45
|
-
File.open(file, 'w+') do |f|
|
46
|
-
f.write(template)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# An abstract class providing common methods for real creators
|
52
|
-
class Creator
|
53
|
-
ALL_DIGITS = /\A\d+\Z/
|
54
|
-
|
55
|
-
def already_exist(path)
|
56
|
-
underscore = StringExtra.new(path).underscore
|
57
|
-
new_file = "#{File.dirname(path)}/#{underscore}.rb"
|
58
|
-
return if !FileTest.exist?(path) && !FileTest.exist?(new_file)
|
59
|
-
puts 'That file already exists!'
|
60
|
-
exit
|
61
|
-
end
|
62
|
-
|
63
|
-
# Show the help/usage message for create.
|
64
|
-
def usage
|
65
|
-
puts <<-USAGE
|
66
|
-
|
67
|
-
Usage: k9 create <sketch_to_generate> <width> <height>
|
68
|
-
Examples: k9 create my_app 800 600
|
69
|
-
k9 create my_app 800 600 p3d
|
70
|
-
|
71
|
-
USAGE
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# This class creates class wrapped sketches, with an optional render mode
|
76
|
-
class ClassSketch < Creator
|
77
|
-
def class_template
|
78
|
-
format(CLASS_BASIC, @name, @width, @height, @name, @title)
|
79
|
-
end
|
80
|
-
|
81
|
-
def class_template_mode
|
82
|
-
format(CLASS_MODE, @name, @width, @height, @mode, @name, @title)
|
83
|
-
end
|
84
|
-
|
85
|
-
# Create a bare blank sketch, given a path.
|
86
|
-
def create!(path, args)
|
87
|
-
return usage if /\?/ =~ path || /--help/ =~ path
|
88
|
-
main_file = File.basename(path, '.rb') # allow uneeded extension input
|
89
|
-
# Check to make sure that the main file doesn't exist already
|
90
|
-
already_exist(path)
|
91
|
-
@name = CamelString.new(main_file).camelize
|
92
|
-
writer = SketchWriter.new(main_file)
|
93
|
-
@title = StringExtra.new(main_file).titleize
|
94
|
-
@width, @height = args[0], args[1]
|
95
|
-
@mode = args[2].upcase unless args[2].nil?
|
96
|
-
template = @mode.nil? ? class_template : class_template_mode
|
97
|
-
writer.save(template)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
data/lib/jruby_art/parse.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
SKETCH_PATH ||= ARGV.shift
|
4
|
-
SKETCH_ROOT ||= File.dirname(SKETCH_PATH)
|
5
|
-
|
6
|
-
require_relative '../jruby_art'
|
7
|
-
require_relative '../jruby_art/'
|
8
|
-
require_relative '../jruby_art/helpers/string_extra'
|
9
|
-
# The top level module
|
10
|
-
module Processing
|
11
|
-
# For use with "bare" sketches that don't want to define a class or methods
|
12
|
-
BARE_TEMPLATE = <<-EOS
|
13
|
-
require 'jruby_art'
|
14
|
-
|
15
|
-
class Sketch < %s
|
16
|
-
%s
|
17
|
-
end
|
18
|
-
|
19
|
-
Sketch.new(title: '%s')
|
20
|
-
EOS
|
21
|
-
|
22
|
-
NAKED_TEMPLATE = <<-EOS
|
23
|
-
require 'jruby_art'
|
24
|
-
|
25
|
-
class Sketch < Processing::App
|
26
|
-
|
27
|
-
def setup
|
28
|
-
%s
|
29
|
-
no_loop
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
Sketch.new(title: '%s')
|
34
|
-
EOS
|
35
|
-
|
36
|
-
# This method is the common entry point to run a sketch, bare or complete.
|
37
|
-
def self.load_and_run_sketch
|
38
|
-
source = read_sketch_source
|
39
|
-
has_sketch = !source.match(/^[^#]*< Processing::App/).nil?
|
40
|
-
has_methods = !source.match(/^[^#]*(def\s+setup|def\s+draw)/).nil?
|
41
|
-
return load File.join(SKETCH_ROOT, SKETCH_PATH) if has_sketch
|
42
|
-
title = StringExtra.new(File.basename(SKETCH_PATH).sub(/(\.rb)$/, '')).titleize
|
43
|
-
if has_methods
|
44
|
-
default = source.match(/P(2|3)D/)
|
45
|
-
mode = default ? 'Processing::App' : 'Processing::AppGL'
|
46
|
-
code = format(BARE_TEMPLATE, mode, source, title)
|
47
|
-
else
|
48
|
-
code = format(NAKED_TEMPLATE, source, title)
|
49
|
-
end
|
50
|
-
Object.class_eval code, SKETCH_PATH, -1
|
51
|
-
end
|
52
|
-
|
53
|
-
# Read in the sketch source code. Needs to work both online and offline.
|
54
|
-
def self.read_sketch_source
|
55
|
-
File.read(SKETCH_PATH)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
Processing.load_and_run_sketch
|