Closed 97-109-107 closed 11 years ago
In the examples there is a ruby library called hilbert.rb, this has been placed in a folder hilbert. Then you can use:-
load_libraries 'hilbert'
to load the library/libraries
I tried mimicking that structure to use perlin_noise library. The core file that is the equivalent of hilbert.rb contains the following:
require 'rubygems'
require 'matrix'
require 'version'
require 'curve'
require 'gradient_table'
require 'noise'
the rest of the .rb files that make up for the gem are placed inside another directory called perlin. I experimented with placing them inside that directory (one level down from the equivalent of hilbert) and besides the equivalent of hilbert.rb This is the error reported
uninitialized constant Perlin::Noise
Which leads me to believe that the library isn't loaded correctly.
@97-109-107 How did you install the gem? This worked for me (I actually needed sudo on archlinux) note needs jruby installed (Instructions for pure ruby library does not refer to gems)
jruby -S gem install perlin_noise
rp5 run --jruby perlin_test.rb (you should use external jruby to run the sketch)
require 'perlin_noise'
def setup
size 200, 200
n1d = Perlin::Noise.new 1
0.step(100, 0.01) do |x|
puts n1d[x]
end
end
NB: That is all the code you now need since "bare" sketches are the new standard for ruby-processing Worked for me with my development version of ruby-processing https://github.com/monkstone/ruby-processing. If that doesn't work take desperate measures:-
sudo jruby -S gem install ruby-processing # (do the same for libraries you wish to run)
jruby -S rp5 run --jruby ruby_perlin_force.rb
@mcfiredrill does this solve your problem to?
also see worked example here
I'm trying to figure out how to load a pure ruby library into a sketch. The readme doesn't seem to have an answer, I looked into library_loader.rb and found this comment:
But this doesn't help me much. How should the 'library' folder structure look like and how to import the library?
Thanks