WebDemoCanvas test files synched with actual version in WD

This commit is contained in:
pTalanov
2012-06-05 16:46:52 +04:00
parent c5ebfdcea7
commit d11b0a617c
3 changed files with 12 additions and 4 deletions
@@ -42,7 +42,7 @@ public final class WebDemoCanvasExamplesTest extends SingleFileTranslationTest {
} }
public void testFancyLines() throws Exception { public void testFancyLines() throws Exception {
doTest("Fancy lines.kt", "window"); doTest("Fancy lines.kt", "$");
} }
public void testTrafficLight() throws Exception { public void testTrafficLight() throws Exception {
@@ -8,9 +8,10 @@ package fancylines
import js.dom.html5.* import js.dom.html5.*
import js.dom.html.window import js.dom.html.window
import js.jquery.*
fun main(args: Array<String>) { fun main(args: Array<String>) {
window.onload = { jq {
FancyLines().run() FancyLines().run()
} }
} }
@@ -63,4 +64,4 @@ class FancyLines() {
window.setInterval({line()}, 40); window.setInterval({line()}, 40);
window.setInterval({blank()}, 100); window.setInterval({blank()}, 100);
} }
} }
@@ -28,9 +28,15 @@ val context: CanvasContext
val PATH_TO_IMAGES = "http://kotlin-demo.jetbrains.com/static/images/canvas/" val PATH_TO_IMAGES = "http://kotlin-demo.jetbrains.com/static/images/canvas/"
var _state: CanvasState? = null
val state: CanvasState val state: CanvasState
get() { get() {
return CanvasState(canvas) if (_state == null) {
_state = CanvasState(canvas)
}
return _state!!
} }
val colors: Colors val colors: Colors
@@ -430,6 +436,7 @@ class CanvasState(val canvas: HTMLCanvasElement) {
} }
return Vector(e.pageX, e.pageY) - offset return Vector(e.pageX, e.pageY) - offset
} }
fun draw() { fun draw() {
clear() clear()
for (shape in shapes) { for (shape in shapes) {