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

Unified Diff: resources/slides.lua

Issue 646613004: add fade_slide transition to lua slides (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months 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 | samplecode/SampleLua.cpp » ('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 bfc4ab4b8350386917f27532f14ad45b81603280..6123ba8e67f5da29512034a30dd49891afe5e2a9 100644
--- a/resources/slides.lua
+++ b/resources/slides.lua
@@ -69,6 +69,47 @@ function slide_transition(prev, next, is_forward)
return rec
end
+function fade_slide_transition(prev, next, is_forward)
+ local rec = {
+ prevImage = prev,
+ nextImage = next,
+ proc = function(self, canvas, drawSlideProc)
+ if self:isDone() then
+ drawSlideProc(canvas)
+ return nil
+ end
+ canvas:drawImage(self.prevImage, self.prev_x, 0, self.prev_a)
+ canvas:drawImage(self.nextImage, self.next_x, 0, self.next_a)
+ self:step()
+ return self
+ end
+ }
+ if is_forward then
+ rec.prev_x = 0
+ rec.prev_a = 1
+ rec.next_x = 640
+ rec.next_a = 0
+ rec.isDone = function (self) return self.next_x <= 0 end
+ rec.step = function (self)
+ self.next_x = self.next_x - 20
+ self.next_a = (640 - self.next_x) / 640
+ self.prev_a = 1 - self.next_a
+ end
+ else
+ rec.prev_x = 0
+ rec.prev_a = 1
+ rec.next_x = 0
+ rec.next_a = 0
+ rec.isDone = function (self) return self.prev_x >= 640 end
+ rec.step = function (self)
+ self.prev_x = self.prev_x + 20
+ self.prev_a = (640 - self.prev_x) / 640
+ self.next_a = 1 - self.prev_a
+ end
+ end
+ return rec
+end
+
--------------------------------------------------------------------------------------
gTemplate = {
@@ -94,7 +135,7 @@ gSlides = {
canvas:drawOval({left=300, top=300, right=400, bottom=400}, gRedPaint)
end },
},
- transition = slide_transition
+ transition = fade_slide_transition
},
{ text = "Title2", style="title", color = { a=1, r=0, g=1, b=0 },
children = {
@@ -102,7 +143,7 @@ gSlides = {
{ text = "bullet 2", style = "child" },
{ text = "bullet tres", style = "child" },
},
- transition = fade_transition
+ transition = slide_transition
},
{ text = "Title3", style="title",
children = {
« no previous file with comments | « no previous file | samplecode/SampleLua.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698