Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2140)

Unified Diff: resources/slides.lua

Issue 698563004: update slide content (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | resources/slides_content2.lua » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: resources/slides.lua
diff --git a/resources/slides.lua b/resources/slides.lua
index f706a296590606450a92ba55c6e31a805e462d10..cf1a1a6229fedf3180a9aee368751ac22b307f2e 100644
--- a/resources/slides.lua
+++ b/resources/slides.lua
@@ -27,6 +27,32 @@ function make_paint(typefacename, stylebits, size, color)
return paint
end
+function center_rect(sw, sh, dst)
+ local dw = dst.right - dst.left
+ local dh = dst.bottom - dst.top
+
+ local rw, rh
+
+ if sw / sh > dw / dh then
+ rw = dw
+ rh = sh * dw / sw
+ else
+ rh = dh
+ rw = sw * dh / sh
+ end
+
+ local x = dst.left + ((sw - rw) / 2)
+ local y = dst.top + ((sh - rh) / 2)
+ return make_rect(x, y, x + rw, y + rh)
+end
+
+function draw_image_centered(canvas, image)
+ local sw = image:width()
+ local sh = image:height()
+ local dstR = center_rect(image:width(), image:height(), make_rect(20, 20, 620, 460))
+ canvas:drawImageRect(image, nil, dstR)
+end
+
function draw_bullet(canvas, x, y, paint, indent)
if 0 == indent then
return
@@ -46,7 +72,14 @@ function stroke_rect(canvas, rect, color)
end
function drawSlide(canvas, slide, master_template)
- template = master_template.slide -- need to sniff the slide to know if we're title or slide
+
+ if #slide == 1 then
+ template = master_template.title
+ canvas:drawText(slide[1].text, 320, 240, template[1])
+ return
+ end
+
+ template = master_template.slide
local x = template.margin_x
local y = template.margin_y
@@ -173,23 +206,19 @@ end
function next_slide()
local prev = gSlides[gSlideIndex]
- gSlideIndex = gSlideIndex + 1
- if gSlideIndex > #gSlides then
- gSlideIndex = 1
+ if gSlideIndex < #gSlides then
+ gSlideIndex = gSlideIndex + 1
+ spawn_transition(prev, gSlides[gSlideIndex], true)
end
-
- spawn_transition(prev, gSlides[gSlideIndex], true)
end
function prev_slide()
local prev = gSlides[gSlideIndex]
- gSlideIndex = gSlideIndex - 1
- if gSlideIndex < 1 then
- gSlideIndex = #gSlides
+ if gSlideIndex > 1 then
+ gSlideIndex = gSlideIndex - 1
+ spawn_transition(prev, gSlides[gSlideIndex], false)
end
-
- spawn_transition(prev, gSlides[gSlideIndex], false)
end
function convert_to_picture_drawable(slide)
@@ -204,7 +233,6 @@ function convert_to_image_drawable(slide)
return new_drawable_image(surf:newImageSnapshot())
end
--- gMakeDrawable = convert_to_picture_drawable
gMakeDrawable = new_drawable_slide
load_file("slides_transitions")
@@ -285,6 +313,7 @@ function draw_bg(canvas)
local grad = Sk.newLinearGradient( 0, 0, { a=1, r=0, g=0, b=.3 },
640, 480, { a=1, r=0, g=0, b=.8 })
bgPaint:setShader(grad)
+ bgPaint:setDither(true)
end
canvas:drawPaint(bgPaint)
« no previous file with comments | « no previous file | resources/slides_content2.lua » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698