-
Notifications
You must be signed in to change notification settings - Fork 4
Glossary
Processing provides degrees(val) and radians(val) as convenience methods, in ruby-processing Numeric has been extended to provide:-
- val.degrees (eg PI.degrees)
- val.radians (eg 80.radians)
the vanilla processing versions are no longer available since ruby-processing-2.6.0
The Range class has been similary extended to provide the clip method
Usage val = (0...width).clip val
where val is the value you want to constrain, this function is used to implement the processing val = constrain(lower, upper, val)
functionality (since ruby-processing-2.6.3). Often it may be more convenient to use clip instead in ruby-processing.
-
map1d(val, range_in, range_out)
works like processingsmap(val, start_in, end_in, start_out, end_out)
it just uses ranges instead of discrete values. The processing version is still available, and should not get confused with rubymap
function.
NB: ruby Range is not just for numbers see this example.
load_library :vecmath
load_libraries :fastmath, :vecmath
The load_library
and load_libraries
are synonyms, it just looks nicer to use the appropriate form. They allow for the easy loading both java
and ruby
libraries. Libraries can be in the core ruby-processings library folder or the sketchbook/libraries
folder (or similar for Mac), or in an adjacent library folder. Since ruby-1.9.3 you can load local files with require_relative
which might be better than using a local library in some cases. You should prefer to use symbol for library as above but string form eg 'vecmath'
is also supported.