jashkenas / ruby-processing

Code as Art, Art as Code. Processing and Ruby are meant for each other.
http://github.com/jashkenas/ruby-processing/wikis
Other
1.28k stars 94 forks source link

abs() is missing from the API #14

Closed fjenett closed 14 years ago

fjenett commented 14 years ago

abs() is missing from App and Proxy. I know it's available thru -123.abs but i think since sin(), cos() and others are available it's confusing.

monkstone commented 14 years ago

Just use the ruby (you know it makes sense) or the penny might have dropped by now?

jashkenas commented 14 years ago

Yep -- the Ruby versions are preferred to the Java ones.

fjenett commented 14 years ago

true, although Processing's success is largly due to it's simplifications .. not only in terms of syntax but also in terms of being intuitive.

anyways for people missing the methods or if you change your mind:

class Processing::App

  ["abs","ceil","floor","round"].each do |meth|
    method = <<-EOS
        def #{meth}( obj )
          obj.#{meth} if obj.methods.include? "#{meth}"
        end
      EOS
      eval method  
  end

end