propane 0.3.0.pre-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.gitignore +21 -0
 - data/.mvn/extensions.xml +8 -0
 - data/.mvn/wrapper/maven-wrapper.properties +1 -0
 - data/.travis.yml +9 -0
 - data/Gemfile +4 -0
 - data/LICENSE.txt +22 -0
 - data/README.md +69 -0
 - data/Rakefile +59 -0
 - data/VERSION.txt +4 -0
 - data/bin/propane +8 -0
 - data/examples/complete/Rakefile +32 -0
 - data/examples/complete/data/Texture01.jpg +0 -0
 - data/examples/complete/data/Texture02.jpg +0 -0
 - data/examples/complete/data/Univers45.vlw +0 -0
 - data/examples/complete/data/displaceFrag.glsl +8 -0
 - data/examples/complete/data/displaceVert.glsl +201 -0
 - data/examples/complete/glsl_heightmap_noise.rb +121 -0
 - data/examples/complete/kinetic_type.rb +79 -0
 - data/examples/regular/Rakefile +30 -0
 - data/examples/regular/arcball_box.rb +36 -0
 - data/examples/regular/creating_colors.rb +57 -0
 - data/examples/regular/elegant_ball.rb +159 -0
 - data/examples/regular/flight_patterns.rb +63 -0
 - data/examples/regular/grey_circles.rb +28 -0
 - data/examples/regular/jwishy.rb +100 -0
 - data/examples/regular/letters.rb +42 -0
 - data/examples/regular/lib/boundary.rb +38 -0
 - data/examples/regular/lib/particle.rb +77 -0
 - data/examples/regular/lib/particle_system.rb +111 -0
 - data/examples/regular/liquidy.rb +40 -0
 - data/examples/regular/mouse_button_demo.rb +34 -0
 - data/examples/regular/polyhedrons.rb +248 -0
 - data/examples/regular/ribbon_doodle.rb +89 -0
 - data/examples/regular/vector_math.rb +36 -0
 - data/examples/regular/words.rb +41 -0
 - data/lib/PROCESSING_LICENSE.txt +456 -0
 - data/lib/export.txt +10 -0
 - data/lib/propane.rb +12 -0
 - data/lib/propane/app.rb +197 -0
 - data/lib/propane/helper_methods.rb +177 -0
 - data/lib/propane/helpers/numeric.rb +9 -0
 - data/lib/propane/library_loader.rb +117 -0
 - data/lib/propane/runner.rb +88 -0
 - data/lib/propane/underscorer.rb +19 -0
 - data/lib/propane/version.rb +5 -0
 - data/library/boids/boids.rb +201 -0
 - data/library/control_panel/control_panel.rb +172 -0
 - data/pom.rb +113 -0
 - data/pom.xml +198 -0
 - data/propane.gemspec +28 -0
 - data/src/monkstone/ColorUtil.java +67 -0
 - data/src/monkstone/MathTool.java +195 -0
 - data/src/monkstone/PropaneLibrary.java +47 -0
 - data/src/monkstone/core/AbstractLibrary.java +102 -0
 - data/src/monkstone/fastmath/Deglut.java +115 -0
 - data/src/monkstone/vecmath/AppRender.java +87 -0
 - data/src/monkstone/vecmath/JRender.java +56 -0
 - data/src/monkstone/vecmath/ShapeRender.java +87 -0
 - data/src/monkstone/vecmath/vec2/Vec2.java +670 -0
 - data/src/monkstone/vecmath/vec3/Vec3.java +708 -0
 - data/test/respond_to_test.rb +208 -0
 - data/vendors/Rakefile +48 -0
 - metadata +130 -0
 
    
        data/pom.rb
    ADDED
    
    | 
         @@ -0,0 +1,113 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'fileutils'
         
     | 
| 
      
 2 
     | 
    
         
            +
            project 'rp5extras', 'https://github.com/monkstone/propane' do
         
     | 
| 
      
 3 
     | 
    
         
            +
              model_version '4.0.0'
         
     | 
| 
      
 4 
     | 
    
         
            +
              id 'propane:rp5extras', '0.3.0'
         
     | 
| 
      
 5 
     | 
    
         
            +
              packaging 'jar'
         
     | 
| 
      
 6 
     | 
    
         
            +
              description 'rp5extras for propane'
         
     | 
| 
      
 7 
     | 
    
         
            +
              organization 'ruby-processing', 'https://ruby-processing.github.io'
         
     | 
| 
      
 8 
     | 
    
         
            +
              { 'monkstone' => 'Martin Prout', 'filib' => 'Phillip Cunningham' }.each do |key, value|
         
     | 
| 
      
 9 
     | 
    
         
            +
                developer key do
         
     | 
| 
      
 10 
     | 
    
         
            +
                  name value
         
     | 
| 
      
 11 
     | 
    
         
            +
                  roles 'developer'
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
              license 'MIT', 'http://www.opensource.org/licenses/mit-license.php'
         
     | 
| 
      
 15 
     | 
    
         
            +
              license 'GPL 3', 'http://www.gnu.org/licenses/gpl-3.0-standalone.html'  
         
     | 
| 
      
 16 
     | 
    
         
            +
              issue_management 'https://github.com/monkstone/propane/issues', 'Github'
         
     | 
| 
      
 17 
     | 
    
         
            +
              
         
     | 
| 
      
 18 
     | 
    
         
            +
              source_control(
         
     | 
| 
      
 19 
     | 
    
         
            +
                url: 'https://github.com/monkstone/propane',
         
     | 
| 
      
 20 
     | 
    
         
            +
                connection: 'scm:git:git://github.com/monkstone/propane.git',
         
     | 
| 
      
 21 
     | 
    
         
            +
                developer_connection: 'scm:git:git@github.com/monkstone/propane.git'
         
     | 
| 
      
 22 
     | 
    
         
            +
                )
         
     | 
| 
      
 23 
     | 
    
         
            +
              
         
     | 
| 
      
 24 
     | 
    
         
            +
              properties('source.directory' => 'src',
         
     | 
| 
      
 25 
     | 
    
         
            +
                'propane.basedir' => '${project.basedir}',
         
     | 
| 
      
 26 
     | 
    
         
            +
                'polyglot.dump.pom' => 'pom.xml',
         
     | 
| 
      
 27 
     | 
    
         
            +
                'maven.compiler.source' => '1.7',
         
     | 
| 
      
 28 
     | 
    
         
            +
                'project.build.sourceEncoding' => 'utf-8',
         
     | 
| 
      
 29 
     | 
    
         
            +
                'maven.compiler.target' => '1.7',
         
     | 
| 
      
 30 
     | 
    
         
            +
                'jruby.api' => 'http://jruby.org/apidocs/',
         
     | 
| 
      
 31 
     | 
    
         
            +
                'processing.api' => 'http://processing.github.io/processing-javadocs/core/',
         
     | 
| 
      
 32 
     | 
    
         
            +
                'jruby.api' => 'http://jruby.org/apidocs/',
         
     | 
| 
      
 33 
     | 
    
         
            +
                'jogl.version' => '2.1.5-01'
         
     | 
| 
      
 34 
     | 
    
         
            +
                )
         
     | 
| 
      
 35 
     | 
    
         
            +
              
         
     | 
| 
      
 36 
     | 
    
         
            +
              pom('org.jruby:jruby:9.0.5.0')
         
     | 
| 
      
 37 
     | 
    
         
            +
              jar('org.processing:core:2.2.1')
         
     | 
| 
      
 38 
     | 
    
         
            +
              jar('org.jogamp.jogl:jogl-all:${jogl.version}')
         
     | 
| 
      
 39 
     | 
    
         
            +
              jar('org.jogamp.gluegen:gluegen-rt-main:${jogl.version}')
         
     | 
| 
      
 40 
     | 
    
         
            +
              
         
     | 
| 
      
 41 
     | 
    
         
            +
              overrides do
         
     | 
| 
      
 42 
     | 
    
         
            +
                plugin :resources, '2.6'
         
     | 
| 
      
 43 
     | 
    
         
            +
                plugin :dependency, '2.10' do
         
     | 
| 
      
 44 
     | 
    
         
            +
                  execute_goals( id: 'default-cli',
         
     | 
| 
      
 45 
     | 
    
         
            +
                    artifactItems: [ { groupId:  'org.processing',
         
     | 
| 
      
 46 
     | 
    
         
            +
                      artifactId:  'core',
         
     | 
| 
      
 47 
     | 
    
         
            +
                      version:  '2.2.1',         
         
     | 
| 
      
 48 
     | 
    
         
            +
                      type:  'jar',
         
     | 
| 
      
 49 
     | 
    
         
            +
                      outputDirectory: '${propane.basedir}/lib'
         
     | 
| 
      
 50 
     | 
    
         
            +
                    },
         
     | 
| 
      
 51 
     | 
    
         
            +
                    { groupId:  'org.jogamp.jogl',
         
     | 
| 
      
 52 
     | 
    
         
            +
                      artifactId:  'jogl-all',
         
     | 
| 
      
 53 
     | 
    
         
            +
                      version:  '${jogl.version}',
         
     | 
| 
      
 54 
     | 
    
         
            +
                      type:  'jar',
         
     | 
| 
      
 55 
     | 
    
         
            +
                      outputDirectory: '${propane.basedir}/lib'
         
     | 
| 
      
 56 
     | 
    
         
            +
                    },
         
     | 
| 
      
 57 
     | 
    
         
            +
                    { groupId:  'org.jogamp.gluegen',
         
     | 
| 
      
 58 
     | 
    
         
            +
                      artifactId:  'gluegen-rt',
         
     | 
| 
      
 59 
     | 
    
         
            +
                      version:  '${jogl.version}',
         
     | 
| 
      
 60 
     | 
    
         
            +
                      type:  'jar',
         
     | 
| 
      
 61 
     | 
    
         
            +
                      outputDirectory: '${propane.basedir}/lib'
         
     | 
| 
      
 62 
     | 
    
         
            +
                    },
         
     | 
| 
      
 63 
     | 
    
         
            +
                    { groupId:  'org.jogamp.jogl',
         
     | 
| 
      
 64 
     | 
    
         
            +
                      artifactId:  'jogl-all',
         
     | 
| 
      
 65 
     | 
    
         
            +
                      version:  '${jogl.version}',
         
     | 
| 
      
 66 
     | 
    
         
            +
                      classifier: 'natives-linux-amd64',
         
     | 
| 
      
 67 
     | 
    
         
            +
                      type:  'jar',
         
     | 
| 
      
 68 
     | 
    
         
            +
                      outputDirectory: '${propane.basedir}/lib'
         
     | 
| 
      
 69 
     | 
    
         
            +
                    },
         
     | 
| 
      
 70 
     | 
    
         
            +
                    { groupId:  'org.jogamp.gluegen',
         
     | 
| 
      
 71 
     | 
    
         
            +
                      artifactId:  'gluegen-rt',
         
     | 
| 
      
 72 
     | 
    
         
            +
                      version:  '${jogl.version}',
         
     | 
| 
      
 73 
     | 
    
         
            +
                      type:  'jar',
         
     | 
| 
      
 74 
     | 
    
         
            +
                      classifier: 'natives-linux-amd64',
         
     | 
| 
      
 75 
     | 
    
         
            +
                      outputDirectory: '${propane.basedir}/lib'
         
     | 
| 
      
 76 
     | 
    
         
            +
                    },
         
     | 
| 
      
 77 
     | 
    
         
            +
                    { groupId:  'org.jogamp.jogl',
         
     | 
| 
      
 78 
     | 
    
         
            +
                      artifactId:  'jogl-all',
         
     | 
| 
      
 79 
     | 
    
         
            +
                      version:  '${jogl.version}',
         
     | 
| 
      
 80 
     | 
    
         
            +
                      classifier: 'natives-macosx-universal',
         
     | 
| 
      
 81 
     | 
    
         
            +
                      type:  'jar',
         
     | 
| 
      
 82 
     | 
    
         
            +
                      outputDirectory: '${propane.basedir}/lib'
         
     | 
| 
      
 83 
     | 
    
         
            +
                    },
         
     | 
| 
      
 84 
     | 
    
         
            +
                    { groupId:  'org.jogamp.gluegen',
         
     | 
| 
      
 85 
     | 
    
         
            +
                      artifactId:  'gluegen-rt',
         
     | 
| 
      
 86 
     | 
    
         
            +
                      version:  '${jogl.version}',
         
     | 
| 
      
 87 
     | 
    
         
            +
                      type:  'jar',
         
     | 
| 
      
 88 
     | 
    
         
            +
                      classifier: 'natives-macosx-universal',
         
     | 
| 
      
 89 
     | 
    
         
            +
                      outputDirectory: '${propane.basedir}/lib'
         
     | 
| 
      
 90 
     | 
    
         
            +
                    }
         
     | 
| 
      
 91 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 92 
     | 
    
         
            +
                  )
         
     | 
| 
      
 93 
     | 
    
         
            +
                end
         
     | 
| 
      
 94 
     | 
    
         
            +
                  
         
     | 
| 
      
 95 
     | 
    
         
            +
                plugin( :compiler, '3.3',
         
     | 
| 
      
 96 
     | 
    
         
            +
                  source: '${maven.compiler.source}',
         
     | 
| 
      
 97 
     | 
    
         
            +
                  target: '${maven.compiler.target}'
         
     | 
| 
      
 98 
     | 
    
         
            +
                )
         
     | 
| 
      
 99 
     | 
    
         
            +
                plugin( :javadoc, '2.10.3',
         
     | 
| 
      
 100 
     | 
    
         
            +
                  detect_offline_links:  'false',
         
     | 
| 
      
 101 
     | 
    
         
            +
                  links: ['${jruby.api}', '${processing.api}']
         
     | 
| 
      
 102 
     | 
    
         
            +
                )
         
     | 
| 
      
 103 
     | 
    
         
            +
                plugin( :jar, '2.6',
         
     | 
| 
      
 104 
     | 
    
         
            +
                  archive: { manifestFile: 'MANIFEST.MF' }
         
     | 
| 
      
 105 
     | 
    
         
            +
                )
         
     | 
| 
      
 106 
     | 
    
         
            +
              end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
              build do
         
     | 
| 
      
 109 
     | 
    
         
            +
                default_goal 'package'
         
     | 
| 
      
 110 
     | 
    
         
            +
                source_directory 'src'
         
     | 
| 
      
 111 
     | 
    
         
            +
                final_name 'rpextras'
         
     | 
| 
      
 112 
     | 
    
         
            +
              end
         
     | 
| 
      
 113 
     | 
    
         
            +
            end
         
     | 
    
        data/pom.xml
    ADDED
    
    | 
         @@ -0,0 +1,198 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <?xml version="1.0" encoding="UTF-8"?>
         
     | 
| 
      
 2 
     | 
    
         
            +
            <!--
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            DO NOT MODIFIY - GENERATED CODE
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            -->
         
     | 
| 
      
 9 
     | 
    
         
            +
            <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
         
     | 
| 
      
 10 
     | 
    
         
            +
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         
     | 
| 
      
 11 
     | 
    
         
            +
              <modelVersion>4.0.0</modelVersion>
         
     | 
| 
      
 12 
     | 
    
         
            +
              <groupId>propane</groupId>
         
     | 
| 
      
 13 
     | 
    
         
            +
              <artifactId>rp5extras</artifactId>
         
     | 
| 
      
 14 
     | 
    
         
            +
              <version>0.3.0</version>
         
     | 
| 
      
 15 
     | 
    
         
            +
              <name>rp5extras</name>
         
     | 
| 
      
 16 
     | 
    
         
            +
              <description>rp5extras for propane</description>
         
     | 
| 
      
 17 
     | 
    
         
            +
              <url>https://github.com/monkstone/propane</url>
         
     | 
| 
      
 18 
     | 
    
         
            +
              <organization>
         
     | 
| 
      
 19 
     | 
    
         
            +
                <name>ruby-processing</name>
         
     | 
| 
      
 20 
     | 
    
         
            +
                <url>https://ruby-processing.github.io</url>
         
     | 
| 
      
 21 
     | 
    
         
            +
              </organization>
         
     | 
| 
      
 22 
     | 
    
         
            +
              <licenses>
         
     | 
| 
      
 23 
     | 
    
         
            +
                <license>
         
     | 
| 
      
 24 
     | 
    
         
            +
                  <name>MIT</name>
         
     | 
| 
      
 25 
     | 
    
         
            +
                  <url>http://www.opensource.org/licenses/mit-license.php</url>
         
     | 
| 
      
 26 
     | 
    
         
            +
                </license>
         
     | 
| 
      
 27 
     | 
    
         
            +
                <license>
         
     | 
| 
      
 28 
     | 
    
         
            +
                  <name>GPL 3</name>
         
     | 
| 
      
 29 
     | 
    
         
            +
                  <url>http://www.gnu.org/licenses/gpl-3.0-standalone.html</url>
         
     | 
| 
      
 30 
     | 
    
         
            +
                </license>
         
     | 
| 
      
 31 
     | 
    
         
            +
              </licenses>
         
     | 
| 
      
 32 
     | 
    
         
            +
              <developers>
         
     | 
| 
      
 33 
     | 
    
         
            +
                <developer>
         
     | 
| 
      
 34 
     | 
    
         
            +
                  <id>monkstone</id>
         
     | 
| 
      
 35 
     | 
    
         
            +
                  <name>Martin Prout</name>
         
     | 
| 
      
 36 
     | 
    
         
            +
                  <roles>
         
     | 
| 
      
 37 
     | 
    
         
            +
                    <role>developer</role>
         
     | 
| 
      
 38 
     | 
    
         
            +
                  </roles>
         
     | 
| 
      
 39 
     | 
    
         
            +
                </developer>
         
     | 
| 
      
 40 
     | 
    
         
            +
                <developer>
         
     | 
| 
      
 41 
     | 
    
         
            +
                  <id>filib</id>
         
     | 
| 
      
 42 
     | 
    
         
            +
                  <name>Phillip Cunningham</name>
         
     | 
| 
      
 43 
     | 
    
         
            +
                  <roles>
         
     | 
| 
      
 44 
     | 
    
         
            +
                    <role>developer</role>
         
     | 
| 
      
 45 
     | 
    
         
            +
                  </roles>
         
     | 
| 
      
 46 
     | 
    
         
            +
                </developer>
         
     | 
| 
      
 47 
     | 
    
         
            +
              </developers>
         
     | 
| 
      
 48 
     | 
    
         
            +
              <scm>
         
     | 
| 
      
 49 
     | 
    
         
            +
                <connection>scm:git:git://github.com/monkstone/propane.git</connection>
         
     | 
| 
      
 50 
     | 
    
         
            +
                <developerConnection>scm:git:git@github.com/monkstone/propane.git</developerConnection>
         
     | 
| 
      
 51 
     | 
    
         
            +
                <url>https://github.com/monkstone/propane</url>
         
     | 
| 
      
 52 
     | 
    
         
            +
              </scm>
         
     | 
| 
      
 53 
     | 
    
         
            +
              <issueManagement>
         
     | 
| 
      
 54 
     | 
    
         
            +
                <system>Github</system>
         
     | 
| 
      
 55 
     | 
    
         
            +
                <url>https://github.com/monkstone/propane/issues</url>
         
     | 
| 
      
 56 
     | 
    
         
            +
              </issueManagement>
         
     | 
| 
      
 57 
     | 
    
         
            +
              <properties>
         
     | 
| 
      
 58 
     | 
    
         
            +
                <jogl.version>2.1.5-01</jogl.version>
         
     | 
| 
      
 59 
     | 
    
         
            +
                <jruby.api>http://jruby.org/apidocs/</jruby.api>
         
     | 
| 
      
 60 
     | 
    
         
            +
                <source.directory>src</source.directory>
         
     | 
| 
      
 61 
     | 
    
         
            +
                <maven.compiler.target>1.7</maven.compiler.target>
         
     | 
| 
      
 62 
     | 
    
         
            +
                <processing.api>http://processing.github.io/processing-javadocs/core/</processing.api>
         
     | 
| 
      
 63 
     | 
    
         
            +
                <propane.basedir>${project.basedir}</propane.basedir>
         
     | 
| 
      
 64 
     | 
    
         
            +
                <project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
         
     | 
| 
      
 65 
     | 
    
         
            +
                <polyglot.dump.pom>pom.xml</polyglot.dump.pom>
         
     | 
| 
      
 66 
     | 
    
         
            +
                <maven.compiler.source>1.7</maven.compiler.source>
         
     | 
| 
      
 67 
     | 
    
         
            +
              </properties>
         
     | 
| 
      
 68 
     | 
    
         
            +
              <dependencies>
         
     | 
| 
      
 69 
     | 
    
         
            +
                <dependency>
         
     | 
| 
      
 70 
     | 
    
         
            +
                  <groupId>org.jruby</groupId>
         
     | 
| 
      
 71 
     | 
    
         
            +
                  <artifactId>jruby</artifactId>
         
     | 
| 
      
 72 
     | 
    
         
            +
                  <version>9.0.5.0</version>
         
     | 
| 
      
 73 
     | 
    
         
            +
                  <type>pom</type>
         
     | 
| 
      
 74 
     | 
    
         
            +
                </dependency>
         
     | 
| 
      
 75 
     | 
    
         
            +
                <dependency>
         
     | 
| 
      
 76 
     | 
    
         
            +
                  <groupId>org.processing</groupId>
         
     | 
| 
      
 77 
     | 
    
         
            +
                  <artifactId>core</artifactId>
         
     | 
| 
      
 78 
     | 
    
         
            +
                  <version>2.2.1</version>
         
     | 
| 
      
 79 
     | 
    
         
            +
                </dependency>
         
     | 
| 
      
 80 
     | 
    
         
            +
                <dependency>
         
     | 
| 
      
 81 
     | 
    
         
            +
                  <groupId>org.jogamp.jogl</groupId>
         
     | 
| 
      
 82 
     | 
    
         
            +
                  <artifactId>jogl-all</artifactId>
         
     | 
| 
      
 83 
     | 
    
         
            +
                  <version>${jogl.version}</version>
         
     | 
| 
      
 84 
     | 
    
         
            +
                </dependency>
         
     | 
| 
      
 85 
     | 
    
         
            +
                <dependency>
         
     | 
| 
      
 86 
     | 
    
         
            +
                  <groupId>org.jogamp.gluegen</groupId>
         
     | 
| 
      
 87 
     | 
    
         
            +
                  <artifactId>gluegen-rt-main</artifactId>
         
     | 
| 
      
 88 
     | 
    
         
            +
                  <version>${jogl.version}</version>
         
     | 
| 
      
 89 
     | 
    
         
            +
                </dependency>
         
     | 
| 
      
 90 
     | 
    
         
            +
              </dependencies>
         
     | 
| 
      
 91 
     | 
    
         
            +
              <build>
         
     | 
| 
      
 92 
     | 
    
         
            +
                <sourceDirectory>src</sourceDirectory>
         
     | 
| 
      
 93 
     | 
    
         
            +
                <defaultGoal>package</defaultGoal>
         
     | 
| 
      
 94 
     | 
    
         
            +
                <finalName>rpextras</finalName>
         
     | 
| 
      
 95 
     | 
    
         
            +
                <pluginManagement>
         
     | 
| 
      
 96 
     | 
    
         
            +
                  <plugins>
         
     | 
| 
      
 97 
     | 
    
         
            +
                    <plugin>
         
     | 
| 
      
 98 
     | 
    
         
            +
                      <artifactId>maven-resources-plugin</artifactId>
         
     | 
| 
      
 99 
     | 
    
         
            +
                      <version>2.6</version>
         
     | 
| 
      
 100 
     | 
    
         
            +
                    </plugin>
         
     | 
| 
      
 101 
     | 
    
         
            +
                    <plugin>
         
     | 
| 
      
 102 
     | 
    
         
            +
                      <artifactId>maven-dependency-plugin</artifactId>
         
     | 
| 
      
 103 
     | 
    
         
            +
                      <version>2.10</version>
         
     | 
| 
      
 104 
     | 
    
         
            +
                      <executions>
         
     | 
| 
      
 105 
     | 
    
         
            +
                        <execution>
         
     | 
| 
      
 106 
     | 
    
         
            +
                          <id>default-cli</id>
         
     | 
| 
      
 107 
     | 
    
         
            +
                          <configuration>
         
     | 
| 
      
 108 
     | 
    
         
            +
                            <artifactItems>
         
     | 
| 
      
 109 
     | 
    
         
            +
                              <artifactItem>
         
     | 
| 
      
 110 
     | 
    
         
            +
                                <groupId>org.processing</groupId>
         
     | 
| 
      
 111 
     | 
    
         
            +
                                <artifactId>core</artifactId>
         
     | 
| 
      
 112 
     | 
    
         
            +
                                <version>2.2.1</version>
         
     | 
| 
      
 113 
     | 
    
         
            +
                                <type>jar</type>
         
     | 
| 
      
 114 
     | 
    
         
            +
                                <outputDirectory>${propane.basedir}/lib</outputDirectory>
         
     | 
| 
      
 115 
     | 
    
         
            +
                              </artifactItem>
         
     | 
| 
      
 116 
     | 
    
         
            +
                              <artifactItem>
         
     | 
| 
      
 117 
     | 
    
         
            +
                                <groupId>org.jogamp.jogl</groupId>
         
     | 
| 
      
 118 
     | 
    
         
            +
                                <artifactId>jogl-all</artifactId>
         
     | 
| 
      
 119 
     | 
    
         
            +
                                <version>${jogl.version}</version>
         
     | 
| 
      
 120 
     | 
    
         
            +
                                <type>jar</type>
         
     | 
| 
      
 121 
     | 
    
         
            +
                                <outputDirectory>${propane.basedir}/lib</outputDirectory>
         
     | 
| 
      
 122 
     | 
    
         
            +
                              </artifactItem>
         
     | 
| 
      
 123 
     | 
    
         
            +
                              <artifactItem>
         
     | 
| 
      
 124 
     | 
    
         
            +
                                <groupId>org.jogamp.gluegen</groupId>
         
     | 
| 
      
 125 
     | 
    
         
            +
                                <artifactId>gluegen-rt</artifactId>
         
     | 
| 
      
 126 
     | 
    
         
            +
                                <version>${jogl.version}</version>
         
     | 
| 
      
 127 
     | 
    
         
            +
                                <type>jar</type>
         
     | 
| 
      
 128 
     | 
    
         
            +
                                <outputDirectory>${propane.basedir}/lib</outputDirectory>
         
     | 
| 
      
 129 
     | 
    
         
            +
                              </artifactItem>
         
     | 
| 
      
 130 
     | 
    
         
            +
                              <artifactItem>
         
     | 
| 
      
 131 
     | 
    
         
            +
                                <groupId>org.jogamp.jogl</groupId>
         
     | 
| 
      
 132 
     | 
    
         
            +
                                <artifactId>jogl-all</artifactId>
         
     | 
| 
      
 133 
     | 
    
         
            +
                                <version>${jogl.version}</version>
         
     | 
| 
      
 134 
     | 
    
         
            +
                                <classifier>natives-linux-amd64</classifier>
         
     | 
| 
      
 135 
     | 
    
         
            +
                                <type>jar</type>
         
     | 
| 
      
 136 
     | 
    
         
            +
                                <outputDirectory>${propane.basedir}/lib</outputDirectory>
         
     | 
| 
      
 137 
     | 
    
         
            +
                              </artifactItem>
         
     | 
| 
      
 138 
     | 
    
         
            +
                              <artifactItem>
         
     | 
| 
      
 139 
     | 
    
         
            +
                                <groupId>org.jogamp.gluegen</groupId>
         
     | 
| 
      
 140 
     | 
    
         
            +
                                <artifactId>gluegen-rt</artifactId>
         
     | 
| 
      
 141 
     | 
    
         
            +
                                <version>${jogl.version}</version>
         
     | 
| 
      
 142 
     | 
    
         
            +
                                <type>jar</type>
         
     | 
| 
      
 143 
     | 
    
         
            +
                                <classifier>natives-linux-amd64</classifier>
         
     | 
| 
      
 144 
     | 
    
         
            +
                                <outputDirectory>${propane.basedir}/lib</outputDirectory>
         
     | 
| 
      
 145 
     | 
    
         
            +
                              </artifactItem>
         
     | 
| 
      
 146 
     | 
    
         
            +
                              <artifactItem>
         
     | 
| 
      
 147 
     | 
    
         
            +
                                <groupId>org.jogamp.jogl</groupId>
         
     | 
| 
      
 148 
     | 
    
         
            +
                                <artifactId>jogl-all</artifactId>
         
     | 
| 
      
 149 
     | 
    
         
            +
                                <version>${jogl.version}</version>
         
     | 
| 
      
 150 
     | 
    
         
            +
                                <classifier>natives-macosx-universal</classifier>
         
     | 
| 
      
 151 
     | 
    
         
            +
                                <type>jar</type>
         
     | 
| 
      
 152 
     | 
    
         
            +
                                <outputDirectory>${propane.basedir}/lib</outputDirectory>
         
     | 
| 
      
 153 
     | 
    
         
            +
                              </artifactItem>
         
     | 
| 
      
 154 
     | 
    
         
            +
                              <artifactItem>
         
     | 
| 
      
 155 
     | 
    
         
            +
                                <groupId>org.jogamp.gluegen</groupId>
         
     | 
| 
      
 156 
     | 
    
         
            +
                                <artifactId>gluegen-rt</artifactId>
         
     | 
| 
      
 157 
     | 
    
         
            +
                                <version>${jogl.version}</version>
         
     | 
| 
      
 158 
     | 
    
         
            +
                                <type>jar</type>
         
     | 
| 
      
 159 
     | 
    
         
            +
                                <classifier>natives-macosx-universal</classifier>
         
     | 
| 
      
 160 
     | 
    
         
            +
                                <outputDirectory>${propane.basedir}/lib</outputDirectory>
         
     | 
| 
      
 161 
     | 
    
         
            +
                              </artifactItem>
         
     | 
| 
      
 162 
     | 
    
         
            +
                            </artifactItems>
         
     | 
| 
      
 163 
     | 
    
         
            +
                          </configuration>
         
     | 
| 
      
 164 
     | 
    
         
            +
                        </execution>
         
     | 
| 
      
 165 
     | 
    
         
            +
                      </executions>
         
     | 
| 
      
 166 
     | 
    
         
            +
                    </plugin>
         
     | 
| 
      
 167 
     | 
    
         
            +
                    <plugin>
         
     | 
| 
      
 168 
     | 
    
         
            +
                      <artifactId>maven-compiler-plugin</artifactId>
         
     | 
| 
      
 169 
     | 
    
         
            +
                      <version>3.3</version>
         
     | 
| 
      
 170 
     | 
    
         
            +
                      <configuration>
         
     | 
| 
      
 171 
     | 
    
         
            +
                        <source>${maven.compiler.source}</source>
         
     | 
| 
      
 172 
     | 
    
         
            +
                        <target>${maven.compiler.target}</target>
         
     | 
| 
      
 173 
     | 
    
         
            +
                      </configuration>
         
     | 
| 
      
 174 
     | 
    
         
            +
                    </plugin>
         
     | 
| 
      
 175 
     | 
    
         
            +
                    <plugin>
         
     | 
| 
      
 176 
     | 
    
         
            +
                      <artifactId>maven-javadoc-plugin</artifactId>
         
     | 
| 
      
 177 
     | 
    
         
            +
                      <version>2.10.3</version>
         
     | 
| 
      
 178 
     | 
    
         
            +
                      <configuration>
         
     | 
| 
      
 179 
     | 
    
         
            +
                        <detect_offline_links>false</detect_offline_links>
         
     | 
| 
      
 180 
     | 
    
         
            +
                        <links>
         
     | 
| 
      
 181 
     | 
    
         
            +
                          <link>${jruby.api}</link>
         
     | 
| 
      
 182 
     | 
    
         
            +
                          <link>${processing.api}</link>
         
     | 
| 
      
 183 
     | 
    
         
            +
                        </links>
         
     | 
| 
      
 184 
     | 
    
         
            +
                      </configuration>
         
     | 
| 
      
 185 
     | 
    
         
            +
                    </plugin>
         
     | 
| 
      
 186 
     | 
    
         
            +
                    <plugin>
         
     | 
| 
      
 187 
     | 
    
         
            +
                      <artifactId>maven-jar-plugin</artifactId>
         
     | 
| 
      
 188 
     | 
    
         
            +
                      <version>2.6</version>
         
     | 
| 
      
 189 
     | 
    
         
            +
                      <configuration>
         
     | 
| 
      
 190 
     | 
    
         
            +
                        <archive>
         
     | 
| 
      
 191 
     | 
    
         
            +
                          <manifestFile>MANIFEST.MF</manifestFile>
         
     | 
| 
      
 192 
     | 
    
         
            +
                        </archive>
         
     | 
| 
      
 193 
     | 
    
         
            +
                      </configuration>
         
     | 
| 
      
 194 
     | 
    
         
            +
                    </plugin>
         
     | 
| 
      
 195 
     | 
    
         
            +
                  </plugins>
         
     | 
| 
      
 196 
     | 
    
         
            +
                </pluginManagement>
         
     | 
| 
      
 197 
     | 
    
         
            +
              </build>
         
     | 
| 
      
 198 
     | 
    
         
            +
            </project>
         
     | 
    
        data/propane.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'propane/version'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |gem|
         
     | 
| 
      
 7 
     | 
    
         
            +
              gem.name          = 'propane'
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem.version       = Propane::VERSION
         
     | 
| 
      
 9 
     | 
    
         
            +
              gem.authors       = ['filib', 'monkstone']
         
     | 
| 
      
 10 
     | 
    
         
            +
              gem.email         = ['martin_p@lineone.net']
         
     | 
| 
      
 11 
     | 
    
         
            +
              gem.license       = 'MIT'
         
     | 
| 
      
 12 
     | 
    
         
            +
              gem.description   = %q{A Standalone Ruby Processing implementation} 
         
     | 
| 
      
 13 
     | 
    
         
            +
              gem.summary       = %q{A really slim layer between Ruby and Processing-2.2.1.}
         
     | 
| 
      
 14 
     | 
    
         
            +
              gem.homepage      = 'https://github.com/monkstone/propane'
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem.files         = `git ls-files`.split($/)
         
     | 
| 
      
 16 
     | 
    
         
            +
              gem.files << 'lib/rpextras.jar'
         
     | 
| 
      
 17 
     | 
    
         
            +
              gem.files << 'lib/core-2.2.1.jar'
         
     | 
| 
      
 18 
     | 
    
         
            +
              gem.files << 'lib/gluegen-rt-2.1.5-01.jar'
         
     | 
| 
      
 19 
     | 
    
         
            +
              gem.files << 'lib/gluegen-rt-2.1.5-01-natives-linux-amd64.jar'
         
     | 
| 
      
 20 
     | 
    
         
            +
              gem.files << 'lib/gluegen-rt-2.1.5-01-natives-macosx-universal.jar'
         
     | 
| 
      
 21 
     | 
    
         
            +
              gem.files << 'lib/jogl-all-2.1.5-01-natives-linux-amd64.jar'
         
     | 
| 
      
 22 
     | 
    
         
            +
              gem.files << 'lib/jogl-all-2.1.5-01-natives-macosx-universal.jar'
         
     | 
| 
      
 23 
     | 
    
         
            +
              gem.executables   = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
         
     | 
| 
      
 24 
     | 
    
         
            +
              gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
      
 25 
     | 
    
         
            +
              gem.add_runtime_dependency 'arcball', '~> 0.0.1'  
         
     | 
| 
      
 26 
     | 
    
         
            +
              gem.require_paths = ['lib']
         
     | 
| 
      
 27 
     | 
    
         
            +
              gem.platform      = 'java'
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,67 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            /**
         
     | 
| 
      
 2 
     | 
    
         
            +
             * The purpose of this utility is to allow ruby-processing users to use an alternative 
         
     | 
| 
      
 3 
     | 
    
         
            +
             * to processing.org color their sketches (to cope with ruby FixNumber vs java int)
         
     | 
| 
      
 4 
     | 
    
         
            +
             * Copyright (C) 2015-16 Martin Prout. This tool is free software; you can 
         
     | 
| 
      
 5 
     | 
    
         
            +
             * redistribute it and/or modify it under the terms of the GNU Lesser General 
         
     | 
| 
      
 6 
     | 
    
         
            +
             * Public License as published by the Free Software Foundation; either version
         
     | 
| 
      
 7 
     | 
    
         
            +
             * 2.1 of the License, or (at your option) any later version.
         
     | 
| 
      
 8 
     | 
    
         
            +
             * 
         
     | 
| 
      
 9 
     | 
    
         
            +
             * Obtain a copy of the license at http://www.gnu.org/licenses/lgpl-2.1.html
         
     | 
| 
      
 10 
     | 
    
         
            +
             */
         
     | 
| 
      
 11 
     | 
    
         
            +
            package monkstone;
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            /**
         
     | 
| 
      
 14 
     | 
    
         
            +
             *
         
     | 
| 
      
 15 
     | 
    
         
            +
             * @author Martin Prout
         
     | 
| 
      
 16 
     | 
    
         
            +
             */
         
     | 
| 
      
 17 
     | 
    
         
            +
            public class ColorUtil {
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
               /**
         
     | 
| 
      
 20 
     | 
    
         
            +
                 * Returns hex long as a positive int unless greater than Integer.MAX_VALUE
         
     | 
| 
      
 21 
     | 
    
         
            +
                 * else return the complement as a negative integer or something like that
         
     | 
| 
      
 22 
     | 
    
         
            +
                 */
         
     | 
| 
      
 23 
     | 
    
         
            +
                static final int hexLong(long hexlong) {
         
     | 
| 
      
 24 
     | 
    
         
            +
                    long SPLIT = Integer.MAX_VALUE + 1;
         
     | 
| 
      
 25 
     | 
    
         
            +
                    if (hexlong < SPLIT) {
         
     | 
| 
      
 26 
     | 
    
         
            +
                        return (int) hexlong;
         
     | 
| 
      
 27 
     | 
    
         
            +
                    } else {
         
     | 
| 
      
 28 
     | 
    
         
            +
                        return (int) (hexlong - SPLIT * 2L);
         
     | 
| 
      
 29 
     | 
    
         
            +
                    }
         
     | 
| 
      
 30 
     | 
    
         
            +
                }
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                /**
         
     | 
| 
      
 33 
     | 
    
         
            +
                 *
         
     | 
| 
      
 34 
     | 
    
         
            +
                 * @param hexstring
         
     | 
| 
      
 35 
     | 
    
         
            +
                 * @return
         
     | 
| 
      
 36 
     | 
    
         
            +
                 */
         
     | 
| 
      
 37 
     | 
    
         
            +
                static public int colorString(String hexstring) {
         
     | 
| 
      
 38 
     | 
    
         
            +
                    return java.awt.Color.decode(hexstring).getRGB();
         
     | 
| 
      
 39 
     | 
    
         
            +
                }
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                /**
         
     | 
| 
      
 42 
     | 
    
         
            +
                 *
         
     | 
| 
      
 43 
     | 
    
         
            +
                 * @param hex
         
     | 
| 
      
 44 
     | 
    
         
            +
                 * @return
         
     | 
| 
      
 45 
     | 
    
         
            +
                 */
         
     | 
| 
      
 46 
     | 
    
         
            +
                static public float colorLong(double hex) {
         
     | 
| 
      
 47 
     | 
    
         
            +
                    return (float) hex;
         
     | 
| 
      
 48 
     | 
    
         
            +
                }
         
     | 
| 
      
 49 
     | 
    
         
            +
                
         
     | 
| 
      
 50 
     | 
    
         
            +
                /**
         
     | 
| 
      
 51 
     | 
    
         
            +
                 *
         
     | 
| 
      
 52 
     | 
    
         
            +
                 * @param hexlong
         
     | 
| 
      
 53 
     | 
    
         
            +
                 * @return
         
     | 
| 
      
 54 
     | 
    
         
            +
                 */
         
     | 
| 
      
 55 
     | 
    
         
            +
                static public int colorLong(long hexlong){
         
     | 
| 
      
 56 
     | 
    
         
            +
                   return hexLong(hexlong);
         
     | 
| 
      
 57 
     | 
    
         
            +
                }
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                /**
         
     | 
| 
      
 60 
     | 
    
         
            +
                 *
         
     | 
| 
      
 61 
     | 
    
         
            +
                 * @param hex
         
     | 
| 
      
 62 
     | 
    
         
            +
                 * @return
         
     | 
| 
      
 63 
     | 
    
         
            +
                 */
         
     | 
| 
      
 64 
     | 
    
         
            +
                static public float colorDouble(double hex){
         
     | 
| 
      
 65 
     | 
    
         
            +
                   return (float)hex;
         
     | 
| 
      
 66 
     | 
    
         
            +
                }
         
     | 
| 
      
 67 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,195 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            /**
         
     | 
| 
      
 2 
     | 
    
         
            +
             * The purpose of this tool is to allow ruby-processing users to use an alternative 
         
     | 
| 
      
 3 
     | 
    
         
            +
             * to processing.org map, lerp and norm methods in their sketches
         
     | 
| 
      
 4 
     | 
    
         
            +
             * Copyright (C) 2015-16 Martin Prout. This tool is free software; you can 
         
     | 
| 
      
 5 
     | 
    
         
            +
             * redistribute it and/or modify it under the terms of the GNU Lesser General 
         
     | 
| 
      
 6 
     | 
    
         
            +
             * Public License as published by the Free Software Foundation; either version
         
     | 
| 
      
 7 
     | 
    
         
            +
             * 2.1 of the License, or (at your option) any later version.
         
     | 
| 
      
 8 
     | 
    
         
            +
             * 
         
     | 
| 
      
 9 
     | 
    
         
            +
             * Obtain a copy of the license at http://www.gnu.org/licenses/lgpl-2.1.html
         
     | 
| 
      
 10 
     | 
    
         
            +
             */
         
     | 
| 
      
 11 
     | 
    
         
            +
            package monkstone;
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            import org.jruby.Ruby;
         
     | 
| 
      
 14 
     | 
    
         
            +
            import org.jruby.RubyClass;
         
     | 
| 
      
 15 
     | 
    
         
            +
            import org.jruby.RubyFloat;
         
     | 
| 
      
 16 
     | 
    
         
            +
            import org.jruby.RubyModule;
         
     | 
| 
      
 17 
     | 
    
         
            +
            import org.jruby.RubyObject;
         
     | 
| 
      
 18 
     | 
    
         
            +
            import org.jruby.RubyRange;
         
     | 
| 
      
 19 
     | 
    
         
            +
            import org.jruby.anno.JRubyMethod;
         
     | 
| 
      
 20 
     | 
    
         
            +
            import org.jruby.runtime.ThreadContext;
         
     | 
| 
      
 21 
     | 
    
         
            +
            import org.jruby.runtime.builtin.IRubyObject;
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            /**
         
     | 
| 
      
 24 
     | 
    
         
            +
             *
         
     | 
| 
      
 25 
     | 
    
         
            +
             * @author MartinProut
         
     | 
| 
      
 26 
     | 
    
         
            +
             */
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            public class MathTool extends RubyObject {
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                private static final long serialVersionUID = 4427564758225746633L;
         
     | 
| 
      
 31 
     | 
    
         
            +
                /**
         
     | 
| 
      
 32 
     | 
    
         
            +
                 *
         
     | 
| 
      
 33 
     | 
    
         
            +
                 * @param runtime
         
     | 
| 
      
 34 
     | 
    
         
            +
                 */
         
     | 
| 
      
 35 
     | 
    
         
            +
                public static void createMathTool(Ruby runtime) {
         
     | 
| 
      
 36 
     | 
    
         
            +
                    RubyModule processing = runtime.defineModule("Processing");
         
     | 
| 
      
 37 
     | 
    
         
            +
                    RubyModule module = processing.defineModuleUnder("MathTool");
         
     | 
| 
      
 38 
     | 
    
         
            +
                    module.defineAnnotatedMethods(MathTool.class);
         
     | 
| 
      
 39 
     | 
    
         
            +
                }
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                /**
         
     | 
| 
      
 42 
     | 
    
         
            +
                 *
         
     | 
| 
      
 43 
     | 
    
         
            +
                 * @param context JRuby runtime
         
     | 
| 
      
 44 
     | 
    
         
            +
                 * @param recv self
         
     | 
| 
      
 45 
     | 
    
         
            +
                 * @param args array of RubyRange (must be be numeric)
         
     | 
| 
      
 46 
     | 
    
         
            +
                 * @return RubyFloat
         
     | 
| 
      
 47 
     | 
    
         
            +
                 */
         
     | 
| 
      
 48 
     | 
    
         
            +
                @JRubyMethod(name = "map1d", rest = true, module = true)
         
     | 
| 
      
 49 
     | 
    
         
            +
                public static IRubyObject mapOneD(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
         
     | 
| 
      
 50 
     | 
    
         
            +
                    double value = (Double) args[0].toJava(Double.class);
         
     | 
| 
      
 51 
     | 
    
         
            +
                    RubyRange r1 = (RubyRange) args[1];
         
     | 
| 
      
 52 
     | 
    
         
            +
                    RubyRange r2 = (RubyRange) args[2];
         
     | 
| 
      
 53 
     | 
    
         
            +
                    double first1 = (Double) r1.first(context).toJava(Double.class);
         
     | 
| 
      
 54 
     | 
    
         
            +
                    double first2 = (Double) r2.first(context).toJava(Double.class);
         
     | 
| 
      
 55 
     | 
    
         
            +
                    double last1 = (Double) r1.last(context).toJava(Double.class);
         
     | 
| 
      
 56 
     | 
    
         
            +
                    double last2 = (Double) r2.last(context).toJava(Double.class);
         
     | 
| 
      
 57 
     | 
    
         
            +
                    return mapMt(context, value, first1, last1, first2, last2);
         
     | 
| 
      
 58 
     | 
    
         
            +
                }
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                /**
         
     | 
| 
      
 61 
     | 
    
         
            +
                 *
         
     | 
| 
      
 62 
     | 
    
         
            +
                 * @param context JRuby runtime
         
     | 
| 
      
 63 
     | 
    
         
            +
                 * @param recv self
         
     | 
| 
      
 64 
     | 
    
         
            +
                 * @param args array of RubyRange (must be be numeric)
         
     | 
| 
      
 65 
     | 
    
         
            +
                 * @return RubyFloat
         
     | 
| 
      
 66 
     | 
    
         
            +
                 */
         
     | 
| 
      
 67 
     | 
    
         
            +
                @JRubyMethod(name = "constrained_map", rest = true, module = true)
         
     | 
| 
      
 68 
     | 
    
         
            +
                public static IRubyObject constrainedMap(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
         
     | 
| 
      
 69 
     | 
    
         
            +
                    double value = (Double) args[0].toJava(Double.class);
         
     | 
| 
      
 70 
     | 
    
         
            +
                    RubyRange r1 = (RubyRange) args[1];
         
     | 
| 
      
 71 
     | 
    
         
            +
                    RubyRange r2 = (RubyRange) args[2];
         
     | 
| 
      
 72 
     | 
    
         
            +
                    double first1 = (Double) r1.first(context).toJava(Double.class);
         
     | 
| 
      
 73 
     | 
    
         
            +
                    double first2 = (Double) r2.first(context).toJava(Double.class);
         
     | 
| 
      
 74 
     | 
    
         
            +
                    double last1 = (Double) r1.last(context).toJava(Double.class);
         
     | 
| 
      
 75 
     | 
    
         
            +
                    double last2 = (Double) r2.last(context).toJava(Double.class);
         
     | 
| 
      
 76 
     | 
    
         
            +
                    double max = Math.max(first1, last1);
         
     | 
| 
      
 77 
     | 
    
         
            +
                    double min = Math.min(first1, last1);
         
     | 
| 
      
 78 
     | 
    
         
            +
                    if (value < min) {
         
     | 
| 
      
 79 
     | 
    
         
            +
                        value = min;
         
     | 
| 
      
 80 
     | 
    
         
            +
                    }
         
     | 
| 
      
 81 
     | 
    
         
            +
                    if (value > max) {
         
     | 
| 
      
 82 
     | 
    
         
            +
                        value = max;
         
     | 
| 
      
 83 
     | 
    
         
            +
                    }
         
     | 
| 
      
 84 
     | 
    
         
            +
                   return mapMt(context, value, first1, last1, first2, last2);
         
     | 
| 
      
 85 
     | 
    
         
            +
                }    
         
     | 
| 
      
 86 
     | 
    
         
            +
                
         
     | 
| 
      
 87 
     | 
    
         
            +
                /**
         
     | 
| 
      
 88 
     | 
    
         
            +
                 *
         
     | 
| 
      
 89 
     | 
    
         
            +
                 * @param context JRuby runtime
         
     | 
| 
      
 90 
     | 
    
         
            +
                 * @param recv self
         
     | 
| 
      
 91 
     | 
    
         
            +
                 * @param args floats as in processing map function
         
     | 
| 
      
 92 
     | 
    
         
            +
                 * @return RubyFloat
         
     | 
| 
      
 93 
     | 
    
         
            +
                 */
         
     | 
| 
      
 94 
     | 
    
         
            +
                @JRubyMethod(name = {"p5map", "map"}, rest = true, module = true)
         
     | 
| 
      
 95 
     | 
    
         
            +
                public static IRubyObject mapProcessing(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
         
     | 
| 
      
 96 
     | 
    
         
            +
                    double value = (Double) args[0].toJava(Double.class);
         
     | 
| 
      
 97 
     | 
    
         
            +
                    double first1 = (Double) args[1].toJava(Double.class);
         
     | 
| 
      
 98 
     | 
    
         
            +
                    double first2 = (Double) args[3].toJava(Double.class);
         
     | 
| 
      
 99 
     | 
    
         
            +
                    double last1 = (Double) args[2].toJava(Double.class);
         
     | 
| 
      
 100 
     | 
    
         
            +
                    double last2 = (Double) args[4].toJava(Double.class);
         
     | 
| 
      
 101 
     | 
    
         
            +
                    return mapMt(context, value, first1, last1, first2, last2);
         
     | 
| 
      
 102 
     | 
    
         
            +
                }   
         
     | 
| 
      
 103 
     | 
    
         
            +
              
         
     | 
| 
      
 104 
     | 
    
         
            +
                /**
         
     | 
| 
      
 105 
     | 
    
         
            +
                 * A more correct version than processing.org version
         
     | 
| 
      
 106 
     | 
    
         
            +
                 * @param context
         
     | 
| 
      
 107 
     | 
    
         
            +
                 * @param recv
         
     | 
| 
      
 108 
     | 
    
         
            +
                 * @param args args[2] should be between 0 and 1.0 if not returns start or stop
         
     | 
| 
      
 109 
     | 
    
         
            +
                 * @return lerp value
         
     | 
| 
      
 110 
     | 
    
         
            +
                 */
         
     | 
| 
      
 111 
     | 
    
         
            +
                @JRubyMethod(name = "lerp", rest = true, module = true)
         
     | 
| 
      
 112 
     | 
    
         
            +
                public static IRubyObject lerpP(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
         
     | 
| 
      
 113 
     | 
    
         
            +
                    double start = (Double) args[0].toJava(Double.class);
         
     | 
| 
      
 114 
     | 
    
         
            +
                    double stop = (Double) args[1].toJava(Double.class);
         
     | 
| 
      
 115 
     | 
    
         
            +
                    double amount = (Double) args[2].toJava(Double.class);
         
     | 
| 
      
 116 
     | 
    
         
            +
                    if (amount <= 0) return args[0];
         
     | 
| 
      
 117 
     | 
    
         
            +
                    if (amount >= 1.0) return args[1];
         
     | 
| 
      
 118 
     | 
    
         
            +
                    return context.getRuntime().newFloat((1 - amount) * start + (stop * amount));
         
     | 
| 
      
 119 
     | 
    
         
            +
                }   
         
     | 
| 
      
 120 
     | 
    
         
            +
                
         
     | 
| 
      
 121 
     | 
    
         
            +
                /**
         
     | 
| 
      
 122 
     | 
    
         
            +
                 * Identical to p5map(value, low, high, 0, 1).
         
     | 
| 
      
 123 
     | 
    
         
            +
                 * Numbers outside of the range are not clamped to 0 and 1, 
         
     | 
| 
      
 124 
     | 
    
         
            +
                 * because out-of-range values are often intentional and useful. 
         
     | 
| 
      
 125 
     | 
    
         
            +
                 * @param context
         
     | 
| 
      
 126 
     | 
    
         
            +
                 * @param recv
         
     | 
| 
      
 127 
     | 
    
         
            +
                 * @param args
         
     | 
| 
      
 128 
     | 
    
         
            +
                 * @return norm value
         
     | 
| 
      
 129 
     | 
    
         
            +
                 */
         
     | 
| 
      
 130 
     | 
    
         
            +
                @JRubyMethod(name = "norm", rest = true, module = true)
         
     | 
| 
      
 131 
     | 
    
         
            +
                public static IRubyObject normP(ThreadContext context, IRubyObject recv, IRubyObject[] args) { 
         
     | 
| 
      
 132 
     | 
    
         
            +
                    double value = (Double) args[0].toJava(Double.class);
         
     | 
| 
      
 133 
     | 
    
         
            +
                    double start = (Double) args[1].toJava(Double.class);
         
     | 
| 
      
 134 
     | 
    
         
            +
                    double stop = (Double) args[2].toJava(Double.class);         
         
     | 
| 
      
 135 
     | 
    
         
            +
                    return mapMt(context, value, start, stop, 0, 1.0);
         
     | 
| 
      
 136 
     | 
    
         
            +
                }
         
     | 
| 
      
 137 
     | 
    
         
            +
                
         
     | 
| 
      
 138 
     | 
    
         
            +
                /**
         
     | 
| 
      
 139 
     | 
    
         
            +
                 * Identical to p5map(value, low, high, 0, 1) but 'clamped'.
         
     | 
| 
      
 140 
     | 
    
         
            +
                 * Numbers outside of the range are clamped to 0 and 1, 
         
     | 
| 
      
 141 
     | 
    
         
            +
                 * @param context
         
     | 
| 
      
 142 
     | 
    
         
            +
                 * @param recv
         
     | 
| 
      
 143 
     | 
    
         
            +
                 * @param args
         
     | 
| 
      
 144 
     | 
    
         
            +
                 * @return strict normalized value ie 0..1.0
         
     | 
| 
      
 145 
     | 
    
         
            +
                 */
         
     | 
| 
      
 146 
     | 
    
         
            +
                @JRubyMethod(name = "norm_strict", rest = true, module = true)
         
     | 
| 
      
 147 
     | 
    
         
            +
                public static IRubyObject norm_strict(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
         
     | 
| 
      
 148 
     | 
    
         
            +
                    Ruby ruby = context.runtime;
         
     | 
| 
      
 149 
     | 
    
         
            +
                    double value = (Double) args[0].toJava(Double.class);
         
     | 
| 
      
 150 
     | 
    
         
            +
                    double start = (Double) args[1].toJava(Double.class);
         
     | 
| 
      
 151 
     | 
    
         
            +
                    double stop = (Double) args[2].toJava(Double.class);
         
     | 
| 
      
 152 
     | 
    
         
            +
                    if (value <= start) {
         
     | 
| 
      
 153 
     | 
    
         
            +
                        return new RubyFloat(ruby, 0);
         
     | 
| 
      
 154 
     | 
    
         
            +
                    } else if (value >= stop) {
         
     | 
| 
      
 155 
     | 
    
         
            +
                        return new RubyFloat(ruby, 1.0);
         
     | 
| 
      
 156 
     | 
    
         
            +
                    } else {
         
     | 
| 
      
 157 
     | 
    
         
            +
                        return mapMt(context, value, start, stop, 0, 1.0);
         
     | 
| 
      
 158 
     | 
    
         
            +
                    }
         
     | 
| 
      
 159 
     | 
    
         
            +
                }    
         
     | 
| 
      
 160 
     | 
    
         
            +
                
         
     | 
| 
      
 161 
     | 
    
         
            +
                static final RubyFloat mapMt(ThreadContext context, double value, double first1, double last1, double first2, double last2) {   
         
     | 
| 
      
 162 
     | 
    
         
            +
                    double result = first2 + (last2 - first2) * ((value - first1) / (last1 - first1));
         
     | 
| 
      
 163 
     | 
    
         
            +
                    return context.getRuntime().newFloat(result);
         
     | 
| 
      
 164 
     | 
    
         
            +
                }
         
     | 
| 
      
 165 
     | 
    
         
            +
                
         
     | 
| 
      
 166 
     | 
    
         
            +
                /**
         
     | 
| 
      
 167 
     | 
    
         
            +
                 * Provides processing constrain method as a ruby module method
         
     | 
| 
      
 168 
     | 
    
         
            +
                 * @param context
         
     | 
| 
      
 169 
     | 
    
         
            +
                 * @param recv
         
     | 
| 
      
 170 
     | 
    
         
            +
                 * @param args
         
     | 
| 
      
 171 
     | 
    
         
            +
                 * @return original or limit values
         
     | 
| 
      
 172 
     | 
    
         
            +
                 */
         
     | 
| 
      
 173 
     | 
    
         
            +
                @JRubyMethod(name = "constrain", rest = true, module = true)
         
     | 
| 
      
 174 
     | 
    
         
            +
                public static IRubyObject constrainValue(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
         
     | 
| 
      
 175 
     | 
    
         
            +
                    RubyFloat value = args[0].convertToFloat();
         
     | 
| 
      
 176 
     | 
    
         
            +
                    RubyFloat start = args[1].convertToFloat();
         
     | 
| 
      
 177 
     | 
    
         
            +
                    RubyFloat stop = args[2].convertToFloat();
         
     | 
| 
      
 178 
     | 
    
         
            +
                    if (value.op_ge(context, start).isTrue() && value.op_le(context, stop).isTrue()) {
         
     | 
| 
      
 179 
     | 
    
         
            +
                        return args[0];
         
     | 
| 
      
 180 
     | 
    
         
            +
                    } else if (value.op_ge(context, start).isTrue()) {
         
     | 
| 
      
 181 
     | 
    
         
            +
                        return args[2];
         
     | 
| 
      
 182 
     | 
    
         
            +
                    } else {
         
     | 
| 
      
 183 
     | 
    
         
            +
                        return args[1];
         
     | 
| 
      
 184 
     | 
    
         
            +
                    }
         
     | 
| 
      
 185 
     | 
    
         
            +
                }
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
                /**
         
     | 
| 
      
 188 
     | 
    
         
            +
                 *
         
     | 
| 
      
 189 
     | 
    
         
            +
                 * @param runtime
         
     | 
| 
      
 190 
     | 
    
         
            +
                 * @param metaClass
         
     | 
| 
      
 191 
     | 
    
         
            +
                 */
         
     | 
| 
      
 192 
     | 
    
         
            +
                public MathTool(Ruby runtime, RubyClass metaClass) {
         
     | 
| 
      
 193 
     | 
    
         
            +
                    super(runtime, metaClass);
         
     | 
| 
      
 194 
     | 
    
         
            +
                }
         
     | 
| 
      
 195 
     | 
    
         
            +
            }
         
     |