Skip to content

Instantly share code, notes, and snippets.

View nonkit's full-sized avatar
🙂
created a new repository StickerAid

Nonki Takahashi nonkit

🙂
created a new repository StickerAid
View GitHub Profile
@nonkit
nonkit / GW_DrawGrid.sb
Last active September 12, 2022 09:50
Small Basic Pseudo GraphicsWindow Object
Sub GW_DrawGrid
' GraphicsWindow | draw grid
_gw = GraphicsWindow.Width
_gh = GraphicsWindow.Height
_c100 = "#66000000"
_c10 = "#33000000"
For _x = 0 To _gw Step 10
If Math.Remainder(_x / 10, 10) = 0 Then
GraphicsWindow.PenColor = _c100
Else
@nonkit
nonkit / FileHelper_ShowError.sb
Last active April 1, 2020 07:21
Small Basic Pseudo File Object
Sub FileHelper_ShowError
' File Helper | show last errer
' param op - oparation name
' param indent - indent space if needed
TextWindow.ForegroundColor = "Yellow"
TextWindow.WriteLine(indent + op + ":FAILED")
TextWindow.WriteLine(indent + "LastError:" + File.LastError)
TextWindow.ForegroundColor = "Gray"
EndSub
@nonkit
nonkit / Sprite_Add.sb
Last active July 27, 2020 09:55
Small Basic Pseudo Sprite Object
Sub Sprite_Add
' Sprite | add shapes to a sprite
' param name - sprite name
' param shX, shY - origin of shape array
' param scale - to resize
' param shape[] - shape array
' param nSprite - number of sprite
' return nSprite - updated number of sprite
' return sprite[] - sprite array
Stack.PushValue("local", i)
@nonkit
nonkit / GetShapes.bas
Created May 19, 2019 10:01
PowerPoint VBA Get Shapes Array for Small Basic
Sub GetShapes()
' Get shapes array from PowerPoint VBA
' Version 0.4
' Copyright (c) 2015-2016 Nonki Takahashi. The MIT License.
' Last update 2016-01-08
'
Dim index As Long
Dim myDocument As Slide
Dim x(300) As Integer, y(300) As Integer
Dim xmin As Integer, ymin As Integer
@nonkit
nonkit / Shapes_CalcRotateZoomPos.sb
Last active May 18, 2020 08:44
Small Basic Pseudo Shapes Object
Sub Shapes_CalcRotateZoomPos
' Shapes | calculate position for rotated and zoomed shape
' param["x"], param["y"] - position of a shape
' param["width"], param["height"] - size of a shape
' param ["cx"], param["cy"] - center of rotation
' param ["angle"] - rotate angle
' param ["scale"] - zoom scale
' return x, y - rotated position of a shape
_cx = param["x"] + param["width"] / 2
_cy = param["y"] + param["height"] / 2
@nonkit
nonkit / SB_LineWorkaround.sb
Last active May 18, 2020 13:49
Small Basic Workarounds
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)
@nonkit
nonkit / Clock_DateToJD.sb
Last active April 1, 2020 06:27
Small Basic Pseudo Clock Object
Sub Clock_DateToJD
' Clock | convert date to Julian Day
' param date - date formatted as YYYY/MM/DD
' return jd - Julian Day [day]
s1 = Text.GetIndexOf(date, "/")
year = Text.ConvertToUpperCase(Text.GetSubText(date, 1, s1 - 1))
bc = Text.GetIndexOf(year, "BC")
If 0 < bc Then
year = Text.GetSubText(year, 1, bc - 1) + Text.GetSubTextToEnd(year, bc + 2)
year = -(year - 1)
@nonkit
nonkit / Text_Compare.sb
Last active September 12, 2022 08:50
Small Basic Pseudo Text Object
Sub Text_Compare
' Text | compare texts with case sensitive option
' param["text1"], param["text2"] - to compare
' param["caseSensitive"] - "True" if case sensitive
' return eq = "True" if text1 = text2
' return gt = "True" if text1 > text2
' return lt = "True" if text1 < text2
If param["caseSensitive"] Then
text1 = param["text1"]
text2 = param["text2"]
@nonkit
nonkit / Math_CartesianToPolar.sb
Last active April 14, 2020 08:39
Small Basic Pseudo Math Object
Sub Math_CartesianToPolar
' Math | convert Cartesian coodinate to polar coordinate
' param x, y - Cartesian coordinate
' return r, a - polar coordinate (0<=a<360)
r = Math.SquareRoot(x * x + y * y)
If x = 0 And y > 0 Then
a = 90 ' [degree]
ElseIf x = 0 And y < 0 Then
a = -90
ElseIf x = 0 And y = 0 Then
@nonkit
nonkit / Color_Blacken.sb
Last active April 26, 2020 06:42
Small Basic Pseudo Color Object
Sub Color_Blacken
' Color | Blacken given color
' param c - given color
' param rate - 0..1
' return c - color blackened
Color_NameToColor()
Color_ColorToRGB()
r = Math.Floor(r * (1 - rate))
g = Math.Floor(g * (1 - rate))
b = Math.Floor(b * (1 - rate))