Skip to content

Commit 27f13e0

Browse files
committed
cleanup
1 parent 371e407 commit 27f13e0

File tree

3 files changed

+43
-38
lines changed

3 files changed

+43
-38
lines changed

contributed/full_screen.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@ def draw
1212
lights
1313
background 0
1414
fill 120, 160, 220
15-
(width/100).times do |x|
16-
(height/100).times do |y|
17-
new_x, new_y = x * 100, y * 100
18-
push_matrix
19-
translate new_x + 50, new_y + 50
20-
rotate_y(((mouse_x.to_f + new_x) / width) * PI)
21-
rotate_x(((mouse_y.to_f + new_y) / height) * PI)
22-
box 90
23-
pop_matrix
24-
end
15+
grid(width, height, 100, 100) do |x, y|
16+
push_matrix
17+
translate x + 50, y + 50
18+
rotate_y(((mouse_x.to_f + x) / width) * PI)
19+
rotate_x(((mouse_y.to_f + y) / height) * PI)
20+
box 90
21+
pop_matrix
2522
end
2623
end
2724

contributed/plain.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def draw
1717
background 0
1818
fill 120, 160, 220
1919
stroke 0
20-
grid(width / dim, height / dim, dim, dim) do |i, j|
20+
grid(width, height, dim, dim) do |i, j|
2121
rect i, j, dim, dim, rnd, rnd, rnd, rnd
2222
end
2323
no_loop

examples/WOVNS/stripes.rb

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
1+
#!/usr/bin/env jruby
2+
# frozen_string_literal: true
3+
require 'propane'
14
# Talma Quality, Spectrum 2 Palette
2-
PALETTE = %w(#D5C9D9 #B83D4E #95577E #A884A1).freeze
3-
COULEURS = %i(pink_pearl geranium orchid lilac).freeze
4-
STRPE = 500
5+
class Stripes < Propane::App
56

6-
def settings
7-
size(3984, 3000) # dimensions in pixels (corresponds to 46-48" x 36" at 84 DPI)
8-
no_smooth
9-
end
7+
PALETTE = %w(#D5C9D9 #B83D4E #95577E #A884A1).freeze
8+
COULEURS = %i(pink_pearl geranium orchid lilac).freeze
9+
STRPE = 500
10+
11+
def settings
12+
size(3984, 3000) # dimensions in pixels (corresponds to 46-48" x 36" at 84 DPI)
13+
no_smooth
14+
end
1015

11-
def setup
12-
sketch_title 'Horizontal Stripes'
13-
web = COULEURS.zip(web_to_color_array(PALETTE)).to_h
14-
background(web[:pink_pearl]) # draw the background
15-
no_stroke # don't draw outlines around shapes
16+
def setup
17+
sketch_title 'Horizontal Stripes'
18+
web = COULEURS.zip(web_to_color_array(PALETTE)).to_h
19+
background(web[:pink_pearl]) # draw the background
20+
no_stroke # don't draw outlines around shapes
1621

17-
# Draw stripes at y = 0, 500, 1000, 1500, 2000, and 2500.
18-
# Note that we're using the special variable "height", which is the height
19-
# of the canvas (3000 pixels as specified in the call to size() above).
20-
0.step(by: STRPE, to: height) do |y|
21-
# Draw the first stripe using the rect() function.
22-
# Note that we're using the special variable "width", the analogue of
23-
# "height". Its value is 3984.
24-
fill(web[:geranium]) # set the color of the first rectangle
25-
rect(0, y, width, 84) # corner at (0, y). full width, 84 pixels high.
26-
# Draw two shorter stripes.
27-
fill(web[:orchid])
28-
rect(0, y + 84 + 21, width, 10) # start 21 pixels (1/4") below the first stripe
29-
fill(web[:lilac])
30-
rect(0, y + 84 + 42, width, 10) # start 42 pixels (1/2") below the first stripe
22+
# Draw stripes at y = 0, 500, 1000, 1500, 2000, and 2500.
23+
# Note that we're using the special variable "height", which is the height
24+
# of the canvas (3000 pixels as specified in the call to size() above).
25+
0.step(by: STRPE, to: height) do |y|
26+
# Draw the first stripe using the rect() function.
27+
# Note that we're using the special variable "width", the analogue of
28+
# "height". Its value is 3984.
29+
fill(web[:geranium]) # set the color of the first rectangle
30+
rect(0, y, width, 84) # corner at (0, y). full width, 84 pixels high.
31+
# Draw two shorter stripes.
32+
fill(web[:orchid])
33+
rect(0, y + 84 + 21, width, 10) # start 21 pixels (1/4") below the first stripe
34+
fill(web[:lilac])
35+
rect(0, y + 84 + 42, width, 10) # start 42 pixels (1/2") below the first stripe
36+
end
37+
save(data_path('stripes.png')) # save the output to data folder
3138
end
32-
save(data_path('stripes.png')) # save the output to data folder
3339
end
40+
41+
Stripes.new

0 commit comments

Comments
 (0)