Sha256: d132d693ea13922268040ccc0cb2a18a53d18abdc68788baa100758d23526c3d
Contents?: true
Size: 1005 Bytes
Versions: 10
Compression:
Stored size: 1005 Bytes
Contents
# Processings datatype conversion functions make no sense for Ruby as it does # not have primitive datatypes. Try these instead: # "to_s" (to String) # "to_i" (to Integer, thats a Fixnum or Bignum) # "to_f" (to Float, which would be "double" in Processing, not "float") # "to_a" (to Array, i.e. from a Range or Hash) def setup size 200, 200 # Ruby has no primitive datatypes, everything is an object! # See: [1, 2.0, 'a', "B", nil, false].each do |element| puts puts "#{element.inspect} ... is a #{element.class.name} object" end c = 'A' # String (!) as there is no char datatype in Ruby. # Single quotes are parsed without substitutions (i.e. "It is #{Time.now}.") f = c.ord.to_f # Sets f = 65.0 # was "[c].to_f" in Ruby 1.8 i = (f * 1.4).to_i # Sets i to 91 b = (c.ord.to_i / 2) # Integer or FixNum as there is no byte in Ruby background 51 no_stroke rect f, 0, 40, 66 fill 204 rect i, 67, 40, 66 fill 255 rect b, 134, 40, 66 end
Version data entries
10 entries across 10 versions & 1 rubygems