Public Voice Network
- What are you listening to… 47024702
- Beeeees! 1212
- Minimum rate? 33
- Aging = Scary 88
- FACE EATER 1313
- alternatives to chrome?? 99
- blog 5626556265
- Chick of the Day 1538315383
- Outfit of the Day 33
- Coda 2 3636
- Show your latest Pics 32953295
- Vid of the Day 1203412034
- the gif animation thread 1283512835
- News of the day... 138138
- Battlefield 3 305305
- New York 88
- Pic of the Day 6330263302
- Music over 5.1 System 66
- Random Fascinations? 55
- What is THEIR work? 55
- Meme of the day 1414
- Letterpress process video 33
- Video Cameras Under $2000 77
- ATTN: Greedy Republicans 2323
Ruby-Processing 3939 Responses
Last post: 2 years, 2 months ago | Thread started: Mar 20, 10, 5:12 p.m.
Out of context: Response #1 [Mar 20, 10, 5:12 p.m.]
- stewdio
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!"

- View thread



