Ruby-Processing
Out of context: Reply #1
- Started
- Last post
- 39 Responses
- stewdio0
QBN is going to destroy the pretty code indentation here, but the program will still work. Getting a spinning red cube is just another three steps away :
1. Copy and paste the code into a new *plain* text document and save it as "MyCubes.rb"
2. Open Terminal to the folder where your MyCubes.rb is located.
3. Paste this into Terminal and hit enter :
rp5 run MyCubes.rbThat's it. You should see a red cube spinning in black space. When you're done being mesmerized hit Command+Q to quit. Here's the code for it :
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
class MyCubes < Processing::App
load_library :opengldef setup
size 640, 360, OPENGL
frame_rate 30@x_degree = 45
@y_degree = 0
no_strokeend
def draw
background 0
lights
push_matrixtranslate width / 2, height / 2, 0
rotate_x radians( @x_degree )
rotate_y radians( @y_degree )fill 255, 0, 0, 240
box 100pop_matrix
@x_degree = ( @x_degree + 1 ).modulo 360
@y_degree = ( @y_degree + 2 ).modulo 360
endend
MyCubes.new :title => "My Cubes!"- Thanks!********
- Thanks for the ShellHere tip as well. Handy little app.ctcliff
- you could always just post the code on pastie.org or gist....(github)sublocked
- Thanks!