-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstairs.agate
54 lines (40 loc) · 1.35 KB
/
stairs.agate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import "agraphics" for Antialias, Color, LinearGradientPattern, Path, Surface, vec2
import "parts/colors" for Colors
import "parts/objects" for Brick
def SIZE = 128.0
def STEP_W = 100.0
def STEP_H = 17.0
def RAILING_W = 20.0
def RAILING_H = 20.0
# def PADDING = 14.0
def random = Random.new(System.time)
def surface = Surface.new(vec2(SIZE, SIZE))
def step(percent) { Brick.new(random, vec2(STEP_W, STEP_H), 1.0, Color.darker(Colors.STONE, percent)) }
def railing = Brick.new(random, vec2(RAILING_W, RAILING_H), 1.0, Colors.STONE)
surface.draw {|ctx|
ctx.set_antialias(Antialias.BEST)
# steps
for (i in 1..6) {
ctx.draw(step(0.4 - 0.05 * i.to_f).at(vec2(14.0, 4.0 + STEP_H * i.to_f)))
}
# shadow
ctx.sub {|ctx|
def pattern = LinearGradientPattern.new(vec2(64.0, 14.0), vec2(64.0, 100.0))
pattern.add_color_stop(0.0, Color.new(0.0, 0.0, 0.0, 0.8))
pattern.add_color_stop(1.0, Color.new(0.7, 0.7, 0.7, 0.0))
ctx.rectangle(14.0, 14.0, 100.0, 86.0)
ctx.clip(Path.PRESERVE)
ctx.set_source_pattern(pattern)
ctx.fill()
}
# railings (left and right)
for (i in 0..5) {
ctx.draw(railing.at(vec2(4.0, 4.0 + 20.0 * i.to_f)))
ctx.draw(railing.at(vec2(4.0 + 100.0, 4.0 + 20.0 * i.to_f)))
}
# railings (top)
for (i in 1..4) {
ctx.draw(railing.at(vec2(4.0 + 20.0 * i.to_f, 4.0)))
}
}
surface.export("stairs.png")