@edadma/logo 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +154 -132
- package/dist/main.js.map +3 -3
- package/package.json +1 -1
- package/src/main/scala/io/github/edadma/logo/LogoJS.scala +10 -3
package/package.json
CHANGED
|
@@ -7,6 +7,10 @@ import org.scalajs.dom.html
|
|
|
7
7
|
|
|
8
8
|
import scala.math.Pi
|
|
9
9
|
|
|
10
|
+
/** Singleton representing "no value" from commands like print, fd, etc. */
|
|
11
|
+
@JSExportTopLevel("LogoUnit")
|
|
12
|
+
object LogoUnitJS extends js.Object
|
|
13
|
+
|
|
10
14
|
@js.native
|
|
11
15
|
trait LogoDrawing extends js.Object:
|
|
12
16
|
val lines: js.Array[LineData] = js.native
|
|
@@ -69,10 +73,13 @@ class LogoJS(canvas: html.Canvas) extends js.Object:
|
|
|
69
73
|
logo.interp(program)
|
|
70
74
|
if !autoRender then render()
|
|
71
75
|
|
|
72
|
-
/** Execute a single command */
|
|
73
|
-
def execute(command: String):
|
|
74
|
-
logo.interp(command)
|
|
76
|
+
/** Execute a single command, returns result (undefined for commands with no output) */
|
|
77
|
+
def execute(command: String): js.UndefOr[String] =
|
|
78
|
+
val result = logo.interp(command)
|
|
75
79
|
if !autoRender then render()
|
|
80
|
+
result match
|
|
81
|
+
case LogoUnit => js.undefined
|
|
82
|
+
case v => v.toString
|
|
76
83
|
|
|
77
84
|
/** Clear the screen and reset turtle */
|
|
78
85
|
def clear(): Unit =
|