| OLD | NEW |
| 1 | 1 |
| 2 function make_paint(size, color) | 2 function make_paint(size, color) |
| 3 local paint = Sk.newPaint(); | 3 local paint = Sk.newPaint(); |
| 4 paint:setAntiAlias(true) | 4 paint:setAntiAlias(true) |
| 5 paint:setSubpixelText(true) | 5 paint:setSubpixelText(true) |
| 6 paint:setTextSize(size) | 6 paint:setTextSize(size) |
| 7 paint:setColor(color) | 7 paint:setColor(color) |
| 8 return paint | 8 return paint |
| 9 end | 9 end |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 else | 62 else |
| 63 rec.prevImage = next | 63 rec.prevImage = next |
| 64 rec.nextImage = prev | 64 rec.nextImage = prev |
| 65 rec.curr_x = -640 | 65 rec.curr_x = -640 |
| 66 rec.step_x = 15 | 66 rec.step_x = 15 |
| 67 rec.isDone = function (self) return self.curr_x >= 0 end | 67 rec.isDone = function (self) return self.curr_x >= 0 end |
| 68 end | 68 end |
| 69 return rec | 69 return rec |
| 70 end | 70 end |
| 71 | 71 |
| 72 function fade_slide_transition(prev, next, is_forward) |
| 73 local rec = { |
| 74 prevImage = prev, |
| 75 nextImage = next, |
| 76 proc = function(self, canvas, drawSlideProc) |
| 77 if self:isDone() then |
| 78 drawSlideProc(canvas) |
| 79 return nil |
| 80 end |
| 81 canvas:drawImage(self.prevImage, self.prev_x, 0, self.prev_a) |
| 82 canvas:drawImage(self.nextImage, self.next_x, 0, self.next_a) |
| 83 self:step() |
| 84 return self |
| 85 end |
| 86 } |
| 87 if is_forward then |
| 88 rec.prev_x = 0 |
| 89 rec.prev_a = 1 |
| 90 rec.next_x = 640 |
| 91 rec.next_a = 0 |
| 92 rec.isDone = function (self) return self.next_x <= 0 end |
| 93 rec.step = function (self) |
| 94 self.next_x = self.next_x - 20 |
| 95 self.next_a = (640 - self.next_x) / 640 |
| 96 self.prev_a = 1 - self.next_a |
| 97 end |
| 98 else |
| 99 rec.prev_x = 0 |
| 100 rec.prev_a = 1 |
| 101 rec.next_x = 0 |
| 102 rec.next_a = 0 |
| 103 rec.isDone = function (self) return self.prev_x >= 640 end |
| 104 rec.step = function (self) |
| 105 self.prev_x = self.prev_x + 20 |
| 106 self.prev_a = (640 - self.prev_x) / 640 |
| 107 self.next_a = 1 - self.prev_a |
| 108 end |
| 109 end |
| 110 return rec |
| 111 end |
| 112 |
| 72 --------------------------------------------------------------------------------
------ | 113 --------------------------------------------------------------------------------
------ |
| 73 | 114 |
| 74 gTemplate = { | 115 gTemplate = { |
| 75 title = { x = 10, y = 64, textSize = 64 }, | 116 title = { x = 10, y = 64, textSize = 64 }, |
| 76 child = { x = 40, y = 120, dy = 50, textSize = 40 }, | 117 child = { x = 40, y = 120, dy = 50, textSize = 40 }, |
| 77 } | 118 } |
| 78 | 119 |
| 79 gPaints = {} | 120 gPaints = {} |
| 80 gPaints.title = make_paint(gTemplate.title.textSize, { a=1, r=0, g=0, b=0 } ) | 121 gPaints.title = make_paint(gTemplate.title.textSize, { a=1, r=0, g=0, b=0 } ) |
| 81 gPaints.child = make_paint(gTemplate.child.textSize, { a=.75, r=0, g=0, b=0 } ) | 122 gPaints.child = make_paint(gTemplate.child.textSize, { a=.75, r=0, g=0, b=0 } ) |
| 82 | 123 |
| 83 gRedPaint = Sk.newPaint() | 124 gRedPaint = Sk.newPaint() |
| 84 gRedPaint:setAntiAlias(true) | 125 gRedPaint:setAntiAlias(true) |
| 85 gRedPaint:setColor{a=1, r=1, g=0, b=0 } | 126 gRedPaint:setColor{a=1, r=1, g=0, b=0 } |
| 86 | 127 |
| 87 gSlides = { | 128 gSlides = { |
| 88 { text = "Title1", style="title", color = { a=1, r=1, g=0, b=0 }, | 129 { text = "Title1", style="title", color = { a=1, r=1, g=0, b=0 }, |
| 89 children = { | 130 children = { |
| 90 { text = "bullet 1", style = "child" }, | 131 { text = "bullet 1", style = "child" }, |
| 91 { text = "bullet 2", style = "child" }, | 132 { text = "bullet 2", style = "child" }, |
| 92 { text = "bullet 3", style = "child" }, | 133 { text = "bullet 3", style = "child" }, |
| 93 { draw = function (canvas) | 134 { draw = function (canvas) |
| 94 canvas:drawOval({left=300, top=300, right=400, bottom=400},
gRedPaint) | 135 canvas:drawOval({left=300, top=300, right=400, bottom=400},
gRedPaint) |
| 95 end }, | 136 end }, |
| 96 }, | 137 }, |
| 97 transition = slide_transition | 138 transition = fade_slide_transition |
| 98 }, | 139 }, |
| 99 { text = "Title2", style="title", color = { a=1, r=0, g=1, b=0 }, | 140 { text = "Title2", style="title", color = { a=1, r=0, g=1, b=0 }, |
| 100 children = { | 141 children = { |
| 101 { text = "bullet uno", style = "child" }, | 142 { text = "bullet uno", style = "child" }, |
| 102 { text = "bullet 2", style = "child" }, | 143 { text = "bullet 2", style = "child" }, |
| 103 { text = "bullet tres", style = "child" }, | 144 { text = "bullet tres", style = "child" }, |
| 104 }, | 145 }, |
| 105 transition = fade_transition | 146 transition = slide_transition |
| 106 }, | 147 }, |
| 107 { text = "Title3", style="title", | 148 { text = "Title3", style="title", |
| 108 children = { | 149 children = { |
| 109 { text = "bullet 1", style = "child", }, | 150 { text = "bullet 1", style = "child", }, |
| 110 { text = "bullet 2", style = "child", color = { r=0, g=0, b=1 } }, | 151 { text = "bullet 2", style = "child", color = { r=0, g=0, b=1 } }, |
| 111 { text = "bullet 3", style = "child" }, | 152 { text = "bullet 3", style = "child" }, |
| 112 } | 153 } |
| 113 } | 154 } |
| 114 } | 155 } |
| 115 | 156 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 310 } |
| 270 | 311 |
| 271 function onCharHandler(uni) | 312 function onCharHandler(uni) |
| 272 local proc = keyProcs[uni] | 313 local proc = keyProcs[uni] |
| 273 if proc then | 314 if proc then |
| 274 proc() | 315 proc() |
| 275 return true | 316 return true |
| 276 end | 317 end |
| 277 return false | 318 return false |
| 278 end | 319 end |
| OLD | NEW |