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

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

Closed jareddonovan closed 11 years ago

jareddonovan commented 12 years ago
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)?

monkstone commented 11 years ago

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

jareddonovan commented 11 years ago

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)
monkstone commented 11 years ago

@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?

monkstone commented 11 years ago

Not interesting