Skip to content

Commit 5f621b8

Browse files
committed
More handy examples
1 parent 11e2b1a commit 5f621b8

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
load_library :handy
2+
java_import org.gicentre.handy.HandyRenderer
3+
4+
# Displays 4 sketchy rectangles with different hachuring styles.
5+
# Version 2.0, 4th April, 2016
6+
# Author Jo Wood
7+
8+
attr_reader :handy
9+
10+
def settings
11+
size(300,200)
12+
end
13+
14+
def setup
15+
sketch_title 'Simple Hachure Styles'
16+
@handy = HandyRenderer.new(self)
17+
fill(206,76,52)
18+
handy.set_hachure_perturbation_angle(15)
19+
end
20+
21+
def draw
22+
background(247,230,197)
23+
handy.set_roughness(1)
24+
handy.set_fill_gap(0.5)
25+
handy.set_fill_weight(0.1)
26+
handy.rect(50, 30, 80, 50)
27+
handy.set_fill_gap(3)
28+
handy.set_fill_weight(2)
29+
handy.rect(170, 30, 80, 50)
30+
handy.set_fill_gap(5)
31+
handy.set_is_alternating(true)
32+
handy.rect(50, 120, 80, 50)
33+
handy.set_roughness(3)
34+
handy.set_fill_weight(1)
35+
handy.set_is_alternating(false)
36+
handy.rect(170, 120, 80, 50)
37+
no_loop # No need to redraw.
38+
end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Displays 4 sets of sketchy rectangles each with their own preset styles.
2+
# Version 2.0, 4th April, 2016
3+
# Author Jo Wood
4+
5+
load_libraries :ball, :handy
6+
java_import 'org.gicentre.handy.HandyPresets'
7+
8+
attr_reader :h1, :h2, :h3, :h4
9+
FIVE = 5
10+
11+
def settings
12+
size(610, 200)
13+
end
14+
15+
def setup
16+
sketch_title 'Simple Preset Styles'
17+
@h1 = HandyPresets.create_pencil(self)
18+
@h2 = HandyPresets.create_coloured_pencil(self)
19+
@h3 = HandyPresets.create_water_and_ink(self)
20+
@h4 = HandyPresets.create_marker(self)
21+
end
22+
23+
def draw
24+
background(247, 230, 197)
25+
fill(0, 255, 0)
26+
FIVE.times do
27+
fill(206 + rand(-30..30), 76 + rand(-30..30), 52 + rand(-30..30), 160)
28+
h1.rect(rand(10..200), rand(10..50), 80, 50)
29+
h2.rect(rand(310..520), rand(10..50), 80, 50)
30+
h3.rect(rand(10..200), rand(100..140), 80, 50)
31+
h4.rect(rand(310..520), rand(100..140), 80, 50)
32+
end
33+
no_loop
34+
end

0 commit comments

Comments
 (0)