forked from dergachev/screengif
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraw_progressbar.rb
47 lines (43 loc) · 1.11 KB
/
draw_progressbar.rb
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
#!/usr/bin/env ruby
class DrawProgressbar
def self.draw(img,ratio)
wid = img.columns() - 3
ht = img.rows() - 3
rectWid = 60
rectHt = 20
progressbar = Draw.new
progressbar
.fill('white')
.stroke('black')
.draw(img)
.rectangle(wid-rectWid,ht-rectHt,wid,ht)
progressbar
.fill('black')
.pointsize(12)
.stroke('transparent')
.font_weight(BoldWeight)
.gravity(NorthWestGravity)
.text(wid-rectWid+4,ht-rectHt+5,"screengif")
progressbar
.fill('black')
.stroke('transparent')
.rectangle(wid-rectWid,ht-rectHt,wid-rectWid*(1-ratio),ht)
progressbar.draw(img)
maskedDraw = Draw.new
maskedDraw.define_clip_path('clip') {
maskedDraw
.rectangle(wid-rectWid,ht-rectHt,wid-rectWid*(1-ratio),ht)
}
maskedDraw.push
maskedDraw.clip_path('clip')
maskedDraw
.fill('white')
.pointsize(12)
.stroke('transparent')
.font_weight(BoldWeight)
.gravity(NorthWestGravity)
.text(wid-rectWid+4,ht-rectHt+5,"screengif")
maskedDraw.pop
maskedDraw.draw(img)
end
end