From 21e376cc46d1d7b6b4a6b9f15a5ff3019cba1fc5 Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Fri, 6 Oct 2017 13:47:14 +0300 Subject: [PATCH] Pass fillRect through to canvas.js. --- samples/html5Canvas/src/canvas/js/canvas.js | 3 +++ samples/html5Canvas/src/canvas/kotlin/canvas.kt | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/samples/html5Canvas/src/canvas/js/canvas.js b/samples/html5Canvas/src/canvas/js/canvas.js index cc9daa99701..379b7b2241b 100644 --- a/samples/html5Canvas/src/canvas/js/canvas.js +++ b/samples/html5Canvas/src/canvas/js/canvas.js @@ -30,6 +30,9 @@ konan.libraries.push ({ // This one will be auto generated. knjs_fillRect: function(arena, obj, x1, y1, width, height) { kotlinObject(arena, obj).fillRect(x1, y1, width, height); }, + knjs_fillText: function(arena, obj, textPtr, textLength, x, y, maxWidth) { + kotlinObject(arena, obj).fillText(toUTF16String(textPtr, textLength), x, y, maxWidth); + }, knjs_fill: function(arena, obj) { kotlinObject(arena, obj).fill(); }, diff --git a/samples/html5Canvas/src/canvas/kotlin/canvas.kt b/samples/html5Canvas/src/canvas/kotlin/canvas.kt index 8d9ee020bf9..dbaaf66eedf 100644 --- a/samples/html5Canvas/src/canvas/kotlin/canvas.kt +++ b/samples/html5Canvas/src/canvas/kotlin/canvas.kt @@ -30,6 +30,8 @@ external public fun knjs_lineTo(arena: Int, obj: Int, x: Int, y: Int): Int; @SymbolName("knjs_fillRect") external public fun knjs_fillRect(arena: Int, obj: Int, x1: Int, y1: Int, width: Int, height: Int) +@SymbolName("knjs_fillText") +external public fun knjs_fillText(arena: Int, obj: Int, textPtr: Int, textWidth: Int, x: Int, y: Int, maxWidth: Int) @SymbolName("knjs_fill") external public fun knjs_fill(arena: Int, obj: Int) @@ -97,6 +99,9 @@ open class Context(arena: Int, index: Int): JsValue(arena, index) { fun fillRect(x: Int, y: Int, width: Int, height: Int) { knjs_fillRect(this.arena, this.index, x, y, width, height) } + fun fillText(text: String, x: Int, y: Int, maxWidth: Int) { + knjs_fillText(this.arena, this.index, stringPointer(text), stringLengthBytes(text), x, y, maxWidth) + } fun fill() { knjs_fill(this.arena, this.index) }