jashkenas / ruby-processing

Code as Art, Art as Code. Processing and Ruby are meant for each other.

Home Page:http://github.com/jashkenas/ruby-processing/wikis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

undefined method 'floor' for #<Processing::App:Sketch:>

awarua opened this issue · comments

y = floor 2.1 

...raises an error: undefined method 'floor' for #<Processing::App:Sketch:>

I guess :floor should be listed amongst the class methods to me made available to the instance (l:61 of app.rb)?

Yeh but is pretty trivial to use Math.floor instead.

Yeah fair point, but it's also pretty trivial to use Numeric.ceil rather than the Processing version. Yet ceil is included in the list of methods made available to the instance (app.rb@L61).

int f = floor(2.5);
int c = ceil(2.5);

Becomes:

f = 2.5.floor
c = ciel 2.5

Maybe I'm being pedantic, but this just seems wrooong :). Same goes for several of the other Processing functions (abs, sqrt, round).

Along similar lines, why not use ruby's ** operator rather than pow(). This is actually a more serious question because you get different results...

a = pow 3, -2    # a = 0.111111111938953 
b = 3 ** -2      # b = 1/9 (a Rational, which to_f == 0.1111111111111111)

@awarua In some ways it would be better to rely 100% on ruby (hence jruby), offering functions like println is probably a mistake, but so in my view are many processing convenience functions. Processing.py or pyprocessing may'be more what you are after?

Not interesting