OLD | NEW |
1 gShowBounds = false | 1 gShowBounds = false |
2 | 2 |
3 gPath = "/skia/trunk/resources/" | 3 gPath = "/skia/trunk/resources/" |
4 | 4 |
5 function load_file(file) | 5 function load_file(file) |
6 local prev_path = package.path | 6 local prev_path = package.path |
7 package.path = package.path .. ";" .. gPath .. file .. ".lua" | 7 package.path = package.path .. ";" .. gPath .. file .. ".lua" |
8 require(file) | 8 require(file) |
9 package.path = prev_path | 9 package.path = prev_path |
10 end | 10 end |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 local node = slide[i] | 103 local node = slide[i] |
104 local paint = template[node.indent + 1].paint | 104 local paint = template[node.indent + 1].paint |
105 local extra_dy = template[node.indent + 1].extra_dy | 105 local extra_dy = template[node.indent + 1].extra_dy |
106 local fm = paint:getFontMetrics() | 106 local fm = paint:getFontMetrics() |
107 local x_offset = -fm.ascent * node.indent * 1.25 | 107 local x_offset = -fm.ascent * node.indent * 1.25 |
108 | 108 |
109 local bounds = make_rect(x + x_offset, y, 620, 640) | 109 local bounds = make_rect(x + x_offset, y, 620, 640) |
110 local blob, newBottom = Sk.newTextBlob(node.text, bounds, paint) | 110 local blob, newBottom = Sk.newTextBlob(node.text, bounds, paint) |
111 draw_bullet(canvas, x + x_offset, y - fm.ascent, paint, node.indent) | 111 draw_bullet(canvas, x + x_offset, y - fm.ascent, paint, node.indent) |
112 canvas:drawTextBlob(blob, 0, 0, paint) | 112 canvas:drawTextBlob(blob, 0, 0, paint) |
113 y = newBottom + paint:getTextSize() * .5 | 113 y = newBottom + paint:getTextSize() * .5 + extra_dy |
114 | 114 |
115 if gShowBounds then | 115 if gShowBounds then |
116 bounds.bottom = newBottom | 116 bounds.bottom = newBottom |
117 stroke_rect(canvas, bounds, {a=1,r=0,g=1,b=0}) | 117 stroke_rect(canvas, bounds, {a=1,r=0,g=1,b=0}) |
118 stroke_rect(canvas, blob:bounds(), {a=1,r=1,g=0,b=0}) | 118 stroke_rect(canvas, blob:bounds(), {a=1,r=1,g=0,b=0}) |
119 end | 119 end |
120 | 120 |
121 end | 121 end |
122 end | 122 end |
123 | 123 |
(...skipping 10 matching lines...) Expand all Loading... |
134 title[1] = make_paint("Arial", 1, 45, { a=1, r=1, g=1, b=1 }) | 134 title[1] = make_paint("Arial", 1, 45, { a=1, r=1, g=1, b=1 }) |
135 title[1]:setTextAlign("center") | 135 title[1]:setTextAlign("center") |
136 title[2] = make_paint("Arial", 1, 25, { a=1, r=.75, g=.75, b=.75 }) | 136 title[2] = make_paint("Arial", 1, 25, { a=1, r=.75, g=.75, b=.75 }) |
137 title[2]:setTextAlign("center") | 137 title[2]:setTextAlign("center") |
138 | 138 |
139 local slide = { | 139 local slide = { |
140 margin_x = 20, | 140 margin_x = 20, |
141 margin_y = 25, | 141 margin_y = 25, |
142 } | 142 } |
143 slide[1] = make_tmpl(make_paint("Arial", 1, 35, { a=1, r=1, g=1, b=1 }), 18) | 143 slide[1] = make_tmpl(make_paint("Arial", 1, 35, { a=1, r=1, g=1, b=1 }), 18) |
144 slide[2] = make_tmpl(make_paint("Arial", 0, 25, { a=1, r=1, g=1, b=1 }), 0) | 144 slide[2] = make_tmpl(make_paint("Arial", 0, 25, { a=1, r=1, g=1, b=1 }), 10) |
145 slide[3] = make_tmpl(make_paint("Arial", 0, 20, { a=1, r=.9, g=.9, b=.9 }),
0) | 145 slide[3] = make_tmpl(make_paint("Arial", 0, 20, { a=1, r=.9, g=.9, b=.9 }),
5) |
146 | 146 |
147 return { | 147 return { |
148 title = title, | 148 title = title, |
149 slide = slide, | 149 slide = slide, |
150 codePaint = make_paint("Courier", 0, 20, { a=1, r=.9, g=.9, b=.9 }), | 150 codePaint = make_paint("Courier", 0, 20, { a=1, r=.9, g=.9, b=.9 }), |
151 } | 151 } |
152 end | 152 end |
153 | 153 |
154 gTemplate = SkiaPoint_make_template() | 154 gTemplate = SkiaPoint_make_template() |
155 | 155 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 } | 355 } |
356 | 356 |
357 function onCharHandler(uni) | 357 function onCharHandler(uni) |
358 local proc = keyProcs[uni] | 358 local proc = keyProcs[uni] |
359 if proc then | 359 if proc then |
360 proc() | 360 proc() |
361 return true | 361 return true |
362 end | 362 end |
363 return false | 363 return false |
364 end | 364 end |
OLD | NEW |