diff --git a/samples/html5Canvas/build.sh b/samples/html5Canvas/build.sh
index 230878509bf..6a761458639 100755
--- a/samples/html5Canvas/build.sh
+++ b/samples/html5Canvas/build.sh
@@ -24,7 +24,7 @@ konanc $DIR/src/jsinterop/kotlin \
-includeBinary $DIR/src/jsinterop/js/jsinterop.js \
-p library -o $DIR/build/klib/jsinterop -target wasm32 || exit 1
-konanc $DIR/src/jsinterop_tool/kotlin \
+konanc $DIR/src/stubGenerator/kotlin \
-e org.jetbrains.kotlin.konan.jsinterop.tool.main \
-o $DIR/build/bin/generator || exit 1
diff --git a/samples/html5Canvas/src/main/kotlin/main.kt b/samples/html5Canvas/src/main/kotlin/main.kt
index e77d366d8e2..e4e2a99f1cc 100644
--- a/samples/html5Canvas/src/main/kotlin/main.kt
+++ b/samples/html5Canvas/src/main/kotlin/main.kt
@@ -7,17 +7,18 @@ fun main(args: Array) {
val canvas = document.getElementById("myCanvas").asCanvas
val ctx = canvas.getContext("2d")
val rect = canvas.getBoundingClientRect()
- val rectLeft = rect.getInt("left")
- val rectTop = rect.getInt("top")
+ val rectLeft = rect.left
+ val rectTop = rect.top
var mouseX: Int = 0
var mouseY: Int = 0
var draw: Boolean = false
document.setter("onmousemove") { args: ArrayList ->
- val event = args[0]
+ val event = MouseEvent(args[0])
mouseX = event.getInt("clientX") - rectLeft
mouseY = event.getInt("clientY") - rectTop
+
if (mouseX < 0) mouseX = 0
if (mouseX > 639) mouseX = 639
if (mouseY < 0) mouseY = 0
@@ -34,7 +35,7 @@ fun main(args: Array) {
setInterval(10) {
if (draw) {
- ctx.setter("strokeStyle", "#222222")
+ ctx.strokeStyle = "#222222"
ctx.lineTo(mouseX, mouseY)
ctx.stroke()
} else {
diff --git a/samples/html5Canvas/src/jsinterop_tool/kotlin/idl.kt b/samples/html5Canvas/src/stubGenerator/kotlin/idl.kt
similarity index 77%
rename from samples/html5Canvas/src/jsinterop_tool/kotlin/idl.kt
rename to samples/html5Canvas/src/stubGenerator/kotlin/idl.kt
index 2e0d8df0c6c..dfa9b17bc53 100644
--- a/samples/html5Canvas/src/jsinterop_tool/kotlin/idl.kt
+++ b/samples/html5Canvas/src/stubGenerator/kotlin/idl.kt
@@ -7,6 +7,8 @@ val all = listOf(
Interface("Context",
Attribute("lineWidth", Integer, hasSetter = true),
Attribute("fillStyle", idlString, hasSetter = true),
+ Attribute("strokeStyle", idlString, hasSetter = true),
+
Operation("lineTo", Void, Arg("x", Integer), Arg("y", Integer)),
Operation("moveTo", Void, Arg("x", Integer), Arg("y", Integer)),
Operation("beginPath", Void),
@@ -16,7 +18,12 @@ val all = listOf(
Operation("fill", Void),
Operation("closePath", Void)
),
- Interface("DOMRect"),
+ Interface("DOMRect",
+ Attribute("left", Integer, hasGetter = true),
+ Attribute("right", Integer, hasGetter = true),
+ Attribute("top", Integer, hasGetter = true),
+ Attribute("bottom", Integer, hasGetter = true)
+ ),
Interface("Canvas",
Operation("getContext", InterfaceRef("Context"), Arg("context", idlString)),
Operation("getBoundingClientRect", InterfaceRef("DOMRect"))
@@ -24,6 +31,10 @@ val all = listOf(
Interface("Document",
Operation("getElementById", Object, Arg("id", idlString))
),
+ Interface("MouseEvent",
+ Attribute("clientX", Integer, hasGetter = true),
+ Attribute("clientY", Integer, hasGetter = true)
+ ),
Interface("Response",
Operation("json", Object)
),
@@ -32,6 +43,7 @@ val all = listOf(
),
Interface("__Global",
Attribute("document", InterfaceRef("Document"), hasGetter = true),
+
Operation("fetch", InterfaceRef("Promise"), Arg("url", idlString)),
Operation("setInterval", Void, Arg("lambda", Function), Arg("interval", Integer))
)
diff --git a/samples/html5Canvas/src/jsinterop_tool/kotlin/stubGenerator.kt b/samples/html5Canvas/src/stubGenerator/kotlin/stubGenerator.kt
similarity index 100%
rename from samples/html5Canvas/src/jsinterop_tool/kotlin/stubGenerator.kt
rename to samples/html5Canvas/src/stubGenerator/kotlin/stubGenerator.kt