dynamic_images 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,36 @@
1
+ # Module keeps all source factories creating sources for drawing.
2
+ module DynamicImageSources
3
+ # Main source factory provides interface for source classes.
4
+ #
5
+ # It can also parse any supported source by parsing with all classes inherited from it.
6
+ class SourceFactory
7
+ private_class_method :new
8
+
9
+ private
10
+ def self.inherited(subclass)
11
+ @@factories ||= []
12
+ @@factories << subclass
13
+ end
14
+
15
+ public
16
+ # Returns source object by parsing with all classes inherited from SourceFactory or nil if there is no factory to parse it.
17
+ def self.parse(source)
18
+ raise Exception.new "not implemented in #{self}, but should be" unless self == SourceFactory
19
+ return source if source.is_a? SourceFactory
20
+ source = source.is_a?(Array) ? source.flatten.map(&:to_s).map(&:downcase) : source.to_s.downcase.split(/\s+/)
21
+ @@factories.each do |factory|
22
+ obj = factory.parse source
23
+ return obj if obj
24
+ end
25
+ nil
26
+ end
27
+
28
+ # Interface method for sources to sets them as source.
29
+ def set_source(context, x, y, w, h)
30
+ raise Exception.new "not implemented in #{self.class}, but should be"
31
+ end
32
+ end
33
+ end
34
+
35
+ require File.dirname(__FILE__) + '/color_source.rb'
36
+ require File.dirname(__FILE__) + '/gradient_source.rb'
@@ -0,0 +1,54 @@
1
+ require 'rubygems'
2
+ require 'gtk2'
3
+ require File.dirname(__FILE__) + '/../init.rb'
4
+
5
+ # An array to store created files for removing it at the end
6
+ created_files = ["asym.png"]
7
+
8
+ def time_diff_milli(start, finish)
9
+ (finish - start) * 1000.0
10
+ end
11
+
12
+ # Run test for n = {1, 2, ...} for x times to get AVG
13
+ N = 1..10
14
+ x = 10
15
+ N.to_a.each do |n|
16
+ t1 = Time.now
17
+ x.times do
18
+ DynamicImage.new :w => 588, :h => 412*n, :antialias => :subpixel do
19
+ n.times do |nn|
20
+ block :w => 588, :h => 412, :position => :absolute, :y => 412*nn do
21
+ table :w => 588-173-4, :h => 258, :cols => 1, :margin => [-2, 0, 0, 173] do
22
+ cell do
23
+ text "Men in Black III", :auto_dir => false, :font => "Arial Narrow bold 30", :crop_to => [2, :lines], :crop_suffix => "..."
24
+ end
25
+ cell :h => 26
26
+ cell :h => "0%" do
27
+ text "Director: Barry Sonnenfeld\nCast: Will Smith, Tommy Lee Jones, Jemaine Clement, Josh Brolin, Lady Gaga, Emma Thompson, Alice Eve, Kevin Covais, Rip Torn, Nicole Scherzinger, Mike Pyle, Justin Bieber, Tim Burton",
28
+ :font => "Arial Narrow 13", :to_fix => :crop, :crop_suffix => " ..."
29
+ end
30
+ cell do
31
+ text " \nPrice: $3.99", :font => "Arial Narrow bold 13"
32
+ end
33
+ end
34
+ block :w => "100%", :h => 588-258 do
35
+ text "An alien criminal kills the young Agent K in 1969, altering the timeline, changing the Agency and placing the Earth in danger. Veteran Agent J (Will Smith) must travel back in time to 1969 to before the murder and work with the young Agent K (Josh Brolin) to save him, the Agency, the Earth and humanity itself.",
36
+ :justify => true, :to_fit => :crop, :crop_suffix => " ...", :font => "Arial Narrow 13"
37
+ end
38
+ end
39
+ end
40
+ save! File.dirname(__FILE__) + "/asym.png"
41
+ end
42
+ end
43
+ t2 = Time.now
44
+ t = time_diff_milli t1, t2
45
+ puts "N = #{n}".ljust(8) + "#{t/x} ms"
46
+ end
47
+
48
+ # Removing created files
49
+ unless ARGV.include? "-d"
50
+ created_files.each do |file|
51
+ file = File.join(File.dirname(__FILE__), file)
52
+ File.delete file if File.exists? file
53
+ end
54
+ end
@@ -0,0 +1,86 @@
1
+ no_lib do
2
+ surface = Cairo::ImageSurface.new 588, 412
3
+ cr = Cairo::Context.new(surface)
4
+ cr.set_antialias Cairo::ANTIALIAS_SUBPIXEL
5
+ cr.set_source_rgba [0, 0, 0, 1]
6
+
7
+ pangoLayout = cr.create_pango_layout
8
+ pangoLayout.auto_dir = false
9
+ cr.move_to 173, -2
10
+ pangoLayout.set_width 415*Pango::SCALE
11
+ title = "Men in Black III"
12
+ pangoLayout.set_text title
13
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow bold 30")
14
+ title += " ..."
15
+ loop do
16
+ break if pangoLayout.line_count <= 2
17
+ title = title.sub(/\S+\s+\S+$/, '') + '...'
18
+ pangoLayout.set_text title
19
+ end
20
+ cr.show_pango_layout pangoLayout
21
+ shift = pangoLayout.line_count == 1 ? 0 : 45;
22
+
23
+ normal_font = Pango::FontDescription.new("Arial Narrow 13")
24
+
25
+ cr.move_to 173, 81+shift
26
+ pangoLayout.set_width 415*Pango::SCALE
27
+ dir_casts = "Director: Barry Sonnenfeld\nCast: Will Smith, Tommy Lee Jones, Jemaine Clement, Josh Brolin, Lady Gaga, Emma Thompson, Alice Eve, Kevin Covais, Rip Torn, Nicole Scherzinger, Mike Pyle, Justin Bieber, Tim Burton"
28
+ pangoLayout.set_text dir_casts
29
+ pangoLayout.set_font_description normal_font
30
+ dir_casts += ", ..."
31
+ loop do
32
+ break if pangoLayout.line_count <= (shift.zero? ? 5 : 3)
33
+ dir_casts = dir_casts.scan(/([\s\S]*,).*,/)[0][0] + ' ...'
34
+ pangoLayout.set_text dir_casts
35
+ end
36
+ cr.show_pango_layout pangoLayout
37
+
38
+ cr.move_to 173, 201
39
+ pangoLayout.set_text "\nPrice: $3.99"
40
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow bold 13")
41
+ cr.show_pango_layout pangoLayout
42
+
43
+ cr.move_to 0, 258
44
+ pangoLayout.set_width 588*Pango::SCALE
45
+ pangoLayout.justify = true
46
+ description = "An alien criminal kills the young Agent K in 1969, altering the timeline, changing the Agency and placing the Earth in danger. Veteran Agent J (Will Smith) must travel back in time to 1969 to before the murder and work with the young Agent K (Josh Brolin) to save him, the Agency, the Earth and humanity itself."
47
+ pangoLayout.set_text description
48
+ pangoLayout.set_font_description normal_font
49
+ description += " ..."
50
+ loop do
51
+ break if pangoLayout.line_count <= 7
52
+ description = description.sub(/\S+\s+\S+$/, '') + '...'
53
+ pangoLayout.set_text description
54
+ end
55
+ cr.show_pango_layout pangoLayout
56
+
57
+ file = File.join(File.dirname(__FILE__) + "/performance.1.png")
58
+ cr.target.write_to_png file
59
+
60
+ pangoLayout = nil
61
+ cr.destroy
62
+ surface.destroy
63
+ end
64
+
65
+ with_lib do
66
+ DynamicImage.new :w => 588, :h => 412, :antialias => :subpixel do
67
+ table :w => 588-173-4, :h => 258, :cols => 1, :margin => [-2, 0, 0, 173] do
68
+ cell do
69
+ text "Men in Black III", :auto_dir => false, :font => "Arial Narrow bold 30", :crop_to => [2, :lines], :crop_suffix => "..."
70
+ end
71
+ cell :h => 26
72
+ cell :h => "0%" do
73
+ text "Director: Barry Sonnenfeld\nCast: Will Smith, Tommy Lee Jones, Jemaine Clement, Josh Brolin, Lady Gaga, Emma Thompson, Alice Eve, Kevin Covais, Rip Torn, Nicole Scherzinger, Mike Pyle, Justin Bieber, Tim Burton",
74
+ :font => "Arial Narrow 13", :to_fix => :crop, :crop_suffix => " ..."
75
+ end
76
+ cell do
77
+ text " \nPrice: $3.99", :font => "Arial Narrow bold 13"
78
+ end
79
+ end
80
+ block :w => "100%", :h => 588-258 do
81
+ text "An alien criminal kills the young Agent K in 1969, altering the timeline, changing the Agency and placing the Earth in danger. Veteran Agent J (Will Smith) must travel back in time to 1969 to before the murder and work with the young Agent K (Josh Brolin) to save him, the Agency, the Earth and humanity itself.",
82
+ :justify => true, :to_fit => :crop, :crop_suffix => " ...", :font => "Arial Narrow 13"
83
+ end
84
+ save! File.dirname(__FILE__) + "/performance.2.png"
85
+ end
86
+ end
@@ -0,0 +1,159 @@
1
+ no_lib do
2
+ channel_name = [31.0/255, 31.0/255, 31.0/255, 1]
3
+ channel_num_top = [227.0/255, 227.0/255, 227.0/255, 1]
4
+ channel_num_bottom = [156.0/255, 156.0/255, 156.0/255, 1]
5
+ epg_now = [230.0/255, 230.0/255, 230.0/255, 1]
6
+ epg_next = [129.0/255, 129.0/255, 129.0/255, 1]
7
+
8
+ surface = Cairo::ImageSurface.new 1239, 168
9
+ cr = Cairo::Context.new surface
10
+ cr.set_antialias Cairo::ANTIALIAS_SUBPIXEL
11
+ pangoLayout = cr.create_pango_layout
12
+ pangoLayout.auto_dir = false
13
+
14
+ #channel name
15
+ cr.move_to 28, 13
16
+ pangoLayout.set_width 1183*Pango::SCALE
17
+ cr.set_source_rgba channel_name
18
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow bold 13")
19
+ pangoLayout.set_text "Channel 1"
20
+ cr.show_pango_layout pangoLayout
21
+
22
+ #channel number
23
+ g = Cairo::LinearPattern.new(21,87,21,87+17)
24
+ g.set_extend(Cairo::EXTEND_REFLECT)
25
+ g.add_color_stop_rgba(0.0,channel_num_top)
26
+ g.add_color_stop_rgba(1.0,channel_num_bottom)
27
+
28
+ pangoLayout.set_width 52*Pango::SCALE
29
+ pangoLayout.set_alignment Pango::ALIGN_CENTER
30
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow 17")
31
+
32
+ cr.move_to 21, 87
33
+ pangoLayout.set_text "1"
34
+ cr.set_source(g)
35
+ cr.fill_preserve
36
+ cr.show_pango_layout pangoLayout
37
+
38
+ #channel logo
39
+ cr.save
40
+ cr.set_source [0, 1, 1]
41
+ cr.rectangle 84, 50, 132, 99
42
+ cr.clip
43
+ cr.paint
44
+ cr.restore
45
+
46
+ #epg now title
47
+ pangoLayout.set_alignment Pango::ALIGN_LEFT
48
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow 23")
49
+
50
+ cr.move_to 258, 52
51
+ cr.set_source epg_now
52
+ pangoLayout.set_width 430*Pango::SCALE
53
+ title = "Special News Edition"
54
+ pangoLayout.set_text title
55
+ title += " ..."
56
+ loop do
57
+ break if pangoLayout.line_count <= 1
58
+ title = title.sub(/\S+\s+\S+$/, '') + '...'
59
+ pangoLayout.set_text title
60
+ end
61
+ cr.show_pango_layout pangoLayout
62
+ (font = pangoLayout.font_description).set_style Pango::STYLE_NORMAL
63
+ pangoLayout.set_font_description font
64
+
65
+ pangoLayout.set_width 100*Pango::SCALE
66
+ #epg now start time
67
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow 13")
68
+ cr.move_to 700, 63
69
+ pangoLayout.set_text "23:45"
70
+ cr.set_source epg_now
71
+ cr.show_pango_layout pangoLayout
72
+
73
+ #epg now end time
74
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow 13")
75
+ cr.move_to 1026, 63
76
+ pangoLayout.set_text "00:00"
77
+ cr.set_source epg_now
78
+ cr.show_pango_layout pangoLayout
79
+
80
+ #epg now progress bar background
81
+ cr.save
82
+ cr.set_source [0, 0, 0, 0.5]
83
+ cr.rectangle 752, 64, 259, 20
84
+ cr.clip
85
+ cr.paint
86
+ cr.restore
87
+
88
+ #epg next title
89
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow 23")
90
+ cr.move_to 258, 112
91
+ cr.set_source epg_next
92
+ pangoLayout.set_width 430*Pango::SCALE
93
+ title = "Loop Broadcasts"
94
+ pangoLayout.set_text title
95
+ title += " ..."
96
+ loop do
97
+ break if pangoLayout.line_count <= 1
98
+ title = title.sub(/\S+\s+\S+$/, '') + '...'
99
+ pangoLayout.set_text title
100
+ end
101
+ cr.show_pango_layout pangoLayout
102
+ (font = pangoLayout.font_description).set_style Pango::STYLE_NORMAL
103
+ pangoLayout.set_font_description font
104
+
105
+ #epg next times
106
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow 13")
107
+ pangoLayout.set_width 200*Pango::SCALE
108
+ cr.move_to 700, 122
109
+ pangoLayout.set_text "00:00 - 03:00"
110
+ cr.set_source epg_next
111
+ cr.show_pango_layout pangoLayout
112
+
113
+ file = File.join(File.dirname(__FILE__) + "/performance.1.png")
114
+ cr.target.write_to_png file
115
+
116
+ pangoLayout = nil
117
+ cr.destroy
118
+ surface.destroy
119
+ end
120
+
121
+ with_lib do
122
+ channel_name = [31.0/255, 31.0/255, 31.0/255, 1.0]
123
+ channel_num_top = [227.0/255, 227.0/255, 227.0/255, 1.0]
124
+ channel_num_bottom = [156.0/255, 156.0/255, 156.0/255, 1.0]
125
+ epg_now = [230.0/255, 230.0/255, 230.0/255, 1.0]
126
+ epg_next = [129.0/255, 129.0/255, 129.0/255, 1.0]
127
+
128
+ DynamicImage.new :w => 1239-56, :h => 168-26, :padding => [13, 28], :antialias => :subpixel do
129
+ text "Channel 1", :color => channel_name, :font => "Arial Narrow bold 13"
130
+ table :position => :absolute, :y => 37, :h => 99 do
131
+ cell :width => 38, :padding_right => 18, :padding_top => 37 do
132
+ text "1", :color => [:gradient_reflect, 0, 0, 0, 17, "0%", channel_num_top, "100%", channel_num_bottom], :font => "Arial Narrow 17", :align => :center
133
+ end
134
+ cell :w => 132, :bg => :aqua
135
+ cell :padding_left => 42 do
136
+ block :w => 430, :position => :absolute, :y => 2 do
137
+ text "Special News Edition", :font => "Arial Narrow 23", :to_fit => :crop, :crop_suffix => " ...", :color => epg_now
138
+ end
139
+ block :w => 430, :position => :absolute, :y => 62 do
140
+ text "Loop Broadcasts", :font => "Arial Narrow 23", :to_fit => :crop, :crop_suffix => " ...", :color => epg_next
141
+ end
142
+ end
143
+ cell :padding_left => 12 do
144
+ table :w => 361, :position => :absolute, :y => 13 do
145
+ cell :w => 52 do
146
+ text "23:45", :font => "Arial Narrow 13", :color => epg_now
147
+ end
148
+ cell :bg => [0, 0, 0, 0.5] do
149
+ end
150
+ cell :w => 50, :padding_left => 16 do
151
+ text "00:00", :font => "Arial Narrow 13", :color => epg_now
152
+ end
153
+ end
154
+ text "00:00 - 03:00", :font => "Arial Narrow 13", :color => epg_next, :position => :absolute, :y => 72
155
+ end
156
+ end
157
+ save! File.join(File.dirname(__FILE__) + "/performance.2.png")
158
+ end
159
+ end
@@ -0,0 +1,236 @@
1
+ no_lib do
2
+ channel_name = [31.0/255, 31.0/255, 31.0/255, 1.0]
3
+ channel_num_top = [227.0/255, 227.0/255, 227.0/255, 1.0]
4
+ channel_num_bottom = [156.0/255, 156.0/255, 156.0/255, 1.0]
5
+ epg_now = [230.0/255, 230.0/255, 230.0/255, 1.0]
6
+ epg_next = [129.0/255, 129.0/255, 129.0/255, 1.0]
7
+
8
+ surface = Cairo::ImageSurface.new 1239, 412
9
+ cr = Cairo::Context.new(surface)
10
+ cr.set_antialias Cairo::ANTIALIAS_SUBPIXEL
11
+ cr.set_source_rgba [0, 0, 0, 1]
12
+
13
+ pangoLayout = cr.create_pango_layout
14
+ pangoLayout.auto_dir = false
15
+ cr.move_to 173, -2
16
+ pangoLayout.set_width 415*Pango::SCALE
17
+ title = "Men in Black III"
18
+ pangoLayout.set_text title
19
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow bold 30")
20
+ title += " ..."
21
+ loop do
22
+ break if pangoLayout.line_count <= 2
23
+ title = title.sub(/\S+\s+\S+$/, '') + '...'
24
+ pangoLayout.set_text title
25
+ end
26
+ cr.show_pango_layout pangoLayout
27
+ shift = pangoLayout.line_count == 1 ? 0 : 45;
28
+
29
+ normal_font = Pango::FontDescription.new("Arial Narrow 13")
30
+
31
+ cr.move_to 173, 81+shift
32
+ pangoLayout.set_width 415*Pango::SCALE
33
+ dir_casts = "Director: Barry Sonnenfeld\nCast: Will Smith, Tommy Lee Jones, Jemaine Clement, Josh Brolin, Lady Gaga, Emma Thompson, Alice Eve, Kevin Covais, Rip Torn, Nicole Scherzinger, Mike Pyle, Justin Bieber, Tim Burton"
34
+ pangoLayout.set_text dir_casts
35
+ pangoLayout.set_font_description normal_font
36
+ dir_casts += ", ..."
37
+ loop do
38
+ break if pangoLayout.line_count <= (shift.zero? ? 5 : 3)
39
+ dir_casts = dir_casts.scan(/([\s\S]*,).*,/)[0][0] + ' ...'
40
+ pangoLayout.set_text dir_casts
41
+ end
42
+ cr.show_pango_layout pangoLayout
43
+
44
+ cr.move_to 173, 201
45
+ pangoLayout.set_text "\nPrice: $3.99"
46
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow bold 13")
47
+ cr.show_pango_layout pangoLayout
48
+
49
+ cr.move_to 0, 258
50
+ pangoLayout.set_width 588*Pango::SCALE
51
+ pangoLayout.justify = true
52
+ description = "An alien criminal kills the young Agent K in 1969, altering the timeline, changing the Agency and placing the Earth in danger. Veteran Agent J (Will Smith) must travel back in time to 1969 to before the murder and work with the young Agent K (Josh Brolin) to save him, the Agency, the Earth and humanity itself."
53
+ pangoLayout.set_text description
54
+ pangoLayout.set_font_description normal_font
55
+ description += " ..."
56
+ loop do
57
+ break if pangoLayout.line_count <= 7
58
+ description = description.sub(/\S+\s+\S+$/, '') + '...'
59
+ pangoLayout.set_text description
60
+ end
61
+ cr.show_pango_layout pangoLayout
62
+
63
+
64
+ pangoLayout = cr.create_pango_layout
65
+ pangoLayout.auto_dir = false
66
+
67
+ #channel name
68
+ cr.move_to 28, 13
69
+ pangoLayout.set_width 1183*Pango::SCALE
70
+ cr.set_source_rgba channel_name
71
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow bold 13")
72
+ pangoLayout.set_text "Channel 1"
73
+ cr.show_pango_layout pangoLayout
74
+
75
+ #channel number
76
+ g = Cairo::LinearPattern.new(21,87,21,87+17)
77
+ g.set_extend(Cairo::EXTEND_REFLECT)
78
+ g.add_color_stop_rgba(0.0,channel_num_top)
79
+ g.add_color_stop_rgba(1.0,channel_num_bottom)
80
+
81
+ pangoLayout.set_width 52*Pango::SCALE
82
+ pangoLayout.set_alignment Pango::ALIGN_CENTER
83
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow 17")
84
+
85
+ cr.move_to 21, 87
86
+ pangoLayout.set_text "1"
87
+ cr.set_source(g)
88
+ cr.fill_preserve
89
+ cr.show_pango_layout pangoLayout
90
+
91
+ #channel logo
92
+ cr.save
93
+ cr.set_source [0, 1, 1]
94
+ cr.rectangle 84, 50, 132, 99
95
+ cr.clip
96
+ cr.paint
97
+ cr.restore
98
+
99
+ #epg now title
100
+ pangoLayout.set_alignment Pango::ALIGN_LEFT
101
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow 23")
102
+
103
+ cr.move_to 258, 52
104
+ cr.set_source epg_now
105
+ pangoLayout.set_width 430*Pango::SCALE
106
+ title = "Special News Edition"
107
+ pangoLayout.set_text title
108
+ title += " ..."
109
+ loop do
110
+ break if pangoLayout.line_count <= 1
111
+ title = title.sub(/\S+\s+\S+$/, '') + '...'
112
+ pangoLayout.set_text title
113
+ end
114
+ cr.show_pango_layout pangoLayout
115
+ (font = pangoLayout.font_description).set_style Pango::STYLE_NORMAL
116
+ pangoLayout.set_font_description font
117
+
118
+ pangoLayout.set_width 100*Pango::SCALE
119
+ #epg now start time
120
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow 13")
121
+ cr.move_to 700, 63
122
+ pangoLayout.set_text "23:45"
123
+ cr.set_source epg_now
124
+ cr.show_pango_layout pangoLayout
125
+
126
+ #epg now end time
127
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow 13")
128
+ cr.move_to 1026, 63
129
+ pangoLayout.set_text "00:00"
130
+ cr.set_source epg_now
131
+ cr.show_pango_layout pangoLayout
132
+
133
+ #epg now progress bar background
134
+ cr.save
135
+ cr.set_source [0, 0, 0, 0.5]
136
+ cr.rectangle 752, 64, 259, 20
137
+ cr.clip
138
+ cr.paint
139
+ cr.restore
140
+
141
+ #epg next title
142
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow 23")
143
+ cr.move_to 258, 112
144
+ cr.set_source epg_next
145
+ pangoLayout.set_width 430*Pango::SCALE
146
+ title = "Loop Broadcasts"
147
+ pangoLayout.set_text title
148
+ title += " ..."
149
+ loop do
150
+ break if pangoLayout.line_count <= 1
151
+ title = title.sub(/\S+\s+\S+$/, '') + '...'
152
+ pangoLayout.set_text title
153
+ end
154
+ cr.show_pango_layout pangoLayout
155
+ (font = pangoLayout.font_description).set_style Pango::STYLE_NORMAL
156
+ pangoLayout.set_font_description font
157
+
158
+ #epg next times
159
+ pangoLayout.set_font_description Pango::FontDescription.new("Arial Narrow 13")
160
+ pangoLayout.set_width 200*Pango::SCALE
161
+ cr.move_to 700, 122
162
+ pangoLayout.set_text "00:00 - 03:00"
163
+ cr.set_source epg_next
164
+ cr.show_pango_layout pangoLayout
165
+
166
+
167
+
168
+
169
+ file = File.join(File.dirname(__FILE__) + "/performance.1.png")
170
+ cr.target.write_to_png file
171
+
172
+ pangoLayout = nil
173
+ cr.destroy
174
+ surface.destroy
175
+ end
176
+
177
+ with_lib do
178
+ channel_name = [31.0/255, 31.0/255, 31.0/255, 1.0]
179
+ channel_num_top = [227.0/255, 227.0/255, 227.0/255, 1.0]
180
+ channel_num_bottom = [156.0/255, 156.0/255, 156.0/255, 1.0]
181
+ epg_now = [230.0/255, 230.0/255, 230.0/255, 1.0]
182
+ epg_next = [129.0/255, 129.0/255, 129.0/255, 1.0]
183
+
184
+ DynamicImage.new :w => 1239, :h => 412, :antialias => :subpixel do
185
+ table :w => 588-173-4, :h => 258, :cols => 1, :margin => [-2, 0, 0, 173] do
186
+ cell do
187
+ text "Men in Black III", :auto_dir => false, :font => "Arial Narrow bold 30", :crop_to => [2, :lines], :crop_suffix => "..."
188
+ end
189
+ cell :h => 26
190
+ cell :h => "0%" do
191
+ text "Director: Barry Sonnenfeld\nCast: Will Smith, Tommy Lee Jones, Jemaine Clement, Josh Brolin, Lady Gaga, Emma Thompson, Alice Eve, Kevin Covais, Rip Torn, Nicole Scherzinger, Mike Pyle, Justin Bieber, Tim Burton",
192
+ :font => "Arial Narrow 13", :to_fix => :crop, :crop_suffix => " ..."
193
+ end
194
+ cell do
195
+ text " \nPrice: $3.99", :font => "Arial Narrow bold 13"
196
+ end
197
+ end
198
+ block :w => 588, :h => 588-258 do
199
+ text "An alien criminal kills the young Agent K in 1969, altering the timeline, changing the Agency and placing the Earth in danger. Veteran Agent J (Will Smith) must travel back in time to 1969 to before the murder and work with the young Agent K (Josh Brolin) to save him, the Agency, the Earth and humanity itself.",
200
+ :justify => true, :to_fit => :crop, :crop_suffix => " ...", :font => "Arial Narrow 13"
201
+ end
202
+
203
+ block :w => 1239-56, :h => 168-26, :padding => [13, 28], :position => :absolute, :x => 0, :y => 0 do
204
+ text "Channel 1", :color => channel_name, :font => "Arial Narrow bold 13"
205
+ table :position => :absolute, :y => 37, :h => 99 do
206
+ cell :width => 38, :padding_right => 18, :padding_top => 37 do
207
+ text "1", :color => [:gradient_reflect, 0, 0, 0, 17, "0%", channel_num_top, "100%", channel_num_bottom], :font => "Arial Narrow 17", :align => :center
208
+ end
209
+ cell :w => 132, :bg => :aqua
210
+ cell :padding_left => 42 do
211
+ block :w => 430, :position => :absolute, :y => 2 do
212
+ text "Special News Edition", :font => "Arial Narrow 23", :to_fit => :crop, :crop_suffix => " ...", :color => epg_now
213
+ end
214
+ block :w => 430, :position => :absolute, :y => 62 do
215
+ text "Loop Broadcasts", :font => "Arial Narrow 23", :to_fit => :crop, :crop_suffix => " ...", :color => epg_next
216
+ end
217
+ end
218
+ cell :padding_left => 12 do
219
+ table :w => 361, :position => :absolute, :y => 13 do
220
+ cell :w => 52 do
221
+ text "23:45", :font => "Arial Narrow 13", :color => epg_now
222
+ end
223
+ cell :bg => [0, 0, 0, 0.5] do
224
+ end
225
+ cell :w => 50, :padding_left => 16 do
226
+ text "00:00", :font => "Arial Narrow 13", :color => epg_now
227
+ end
228
+ end
229
+ text "00:00 - 03:00", :font => "Arial Narrow 13", :color => epg_next, :position => :absolute, :y => 72
230
+ end
231
+ end
232
+ end
233
+
234
+ save! File.dirname(__FILE__) + "/performance.2.png"
235
+ end
236
+ end