@edadma/logo 0.2.1 → 0.2.3
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 +1914 -1873
- package/dist/main.js.map +4 -4
- package/package.json +1 -1
- package/src/main/scala/io/github/edadma/logo/LogoJS.scala +16 -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 =
|
|
@@ -130,6 +137,12 @@ class LogoJS(canvas: html.Canvas) extends js.Object:
|
|
|
130
137
|
def clearEventHandler(): Unit =
|
|
131
138
|
eventHandler = None
|
|
132
139
|
|
|
140
|
+
/** Set a global variable */
|
|
141
|
+
def setVariable(name: String, value: Any): Unit = logo.setVariable(name, value)
|
|
142
|
+
|
|
143
|
+
/** Get a global variable */
|
|
144
|
+
def getVariable(name: String): Option[LogoValue] = logo.getVariable(name)
|
|
145
|
+
|
|
133
146
|
/** Force a render */
|
|
134
147
|
def render(): Unit =
|
|
135
148
|
val width = canvas.width
|