Last active
May 18, 2020 13:49
-
-
Save nonkit/d2664e4195eda12fe27693181493d3a7 to your computer and use it in GitHub Desktop.
Small Basic Workarounds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub SB_LineWorkaround | |
' Small Basic | line rotate workaround for SBD | |
' param x, y - coordinate of the position of the line | |
' param x1, y1 - coordinate of the first point | |
' param x2, y2 - coordinate of the second point | |
' param pw - pen width | |
' param alpha - to rotate [degree] | |
' return x, y - workaround value for the coordinate | |
Stack.PushValue("local", x) | |
Stack.PushValue("local", y) | |
x = x1 - x2 | |
y = y1 - y2 | |
Math_CartesianToPolar() | |
y = Stack.PopValue("local") | |
x = Stack.PopValue("local") | |
_a = Math.GetRadians(a) | |
_alpha = Math.GetRadians(a - alpha) | |
Δx = pw / 4 * (Math.Sin(_alpha) - Math.Sin(_a)) | |
Δy = pw / 4 * (Math.Cos(_alpha) - Math.Cos(_a)) | |
x = x - Δx | |
y = y - Δy | |
EndSub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub SB_RotateWorkaround | |
' Small Basic | rotate workaround for Silverlight | |
' param shp - current shape | |
' param x, y - original coordinate | |
' param _alpha - angle [radian] | |
' returns x, y - workaround coordinate | |
If shp["func"] = "tri" Then | |
x1 = -Math.Floor(shp["x3"] / 2) | |
y1 = -Math.Floor(shp["y3"] / 2) | |
ElseIf shp["func"] = "line" Then | |
x1 = -Math.Floor(Math.Abs(shp["x1"] - shp["x2"]) / 2) | |
y1 = -Math.Floor(Math.Abs(shp["y1"] - shp["y2"]) / 2) | |
EndIf | |
ox = x - x1 | |
oy = y - y1 | |
x = x1 * Math.Cos(_alpha) - y1 * Math.Sin(_alpha) + ox | |
y = x1 * Math.Sin(_alpha) + y1 * Math.Cos(_alpha) + oy | |
EndSub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub SB_Workaround | |
' Small Basic | workaround for Silverlight / SBD | |
' return silverlight - "True" if in remote | |
' return sbd - "True" if Small Basic Desktop | |
color = GraphicsWindow.GetPixel(0, 0) | |
sbd = "False" | |
If Text.GetLength(color) > 7 Then | |
silverlight = "True" | |
msWait = 300 | |
Else | |
silverlight = "False" | |
_gw = GraphicsWindow.Width | |
_gh = GraphicsWindow.Height | |
If (_gw = 624) And (_gh = 441) Then | |
sbd = "True" | |
EndIf | |
EndIf | |
EndSub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Two subroutines are for Sliverlight. One will be added for Small Basic Desktop v1.0 and later.