From 0741413c93351fd98828cc1c8d753151ec76d561 Mon Sep 17 00:00:00 2001 From: visionmercer <62051836+visionmercer@users.noreply.github.com> Date: Fri, 18 Mar 2022 18:33:58 +0100 Subject: [PATCH] a start --- bool.bi | 2 ++ consolecolor.bm | 8 ++++++++ grayscale.bm | 19 +++++++++++++++++++ lerp.bm | 3 +++ loadhexpalette.bm | 25 +++++++++++++++++++++++++ max.bm | 3 +++ min.bm | 3 +++ negative.bm | 25 +++++++++++++++++++++++++ noframe.bi | 28 ++++++++++++++++++++++++++++ solarize.bm | 25 +++++++++++++++++++++++++ truncate.bm | 3 +++ 11 files changed, 144 insertions(+) create mode 100644 bool.bi create mode 100644 consolecolor.bm create mode 100644 grayscale.bm create mode 100644 lerp.bm create mode 100644 loadhexpalette.bm create mode 100644 max.bm create mode 100644 min.bm create mode 100644 negative.bm create mode 100644 noframe.bi create mode 100644 solarize.bm create mode 100644 truncate.bm diff --git a/bool.bi b/bool.bi new file mode 100644 index 0000000..024be56 --- /dev/null +++ b/bool.bi @@ -0,0 +1,2 @@ +Const False = 0 +Const True = Not False \ No newline at end of file diff --git a/consolecolor.bm b/consolecolor.bm new file mode 100644 index 0000000..c069d71 --- /dev/null +++ b/consolecolor.bm @@ -0,0 +1,8 @@ +Sub ConsoleColor (Colour As _Unsigned Long) + Select Case Colour + Case 0 TO 255 + Print Chr$(27) + "[38;5;" + _Trim$(Str$(Colour)) + "m"; + Case Is > 255 + Print Chr$(27) + "[38;2;" + _Trim$(Str$(_Red32(Colour))) + ";" + _Trim$(Str$(_Green32(Colour))) + ";" + _Trim$(Str$(_Blue32(Colour))) + "m"; + End Select +End Sub \ No newline at end of file diff --git a/grayscale.bm b/grayscale.bm new file mode 100644 index 0000000..23fed5a --- /dev/null +++ b/grayscale.bm @@ -0,0 +1,19 @@ +Sub grayscale (image As Long) + Dim mimg As _MEM + Dim As _Offset start, length + Dim As _Unsigned _Byte inputRed, inputGreen, inputBlue, nc + mimg = _MemImage(image) + start = mimg.OFFSET + length = start + _Width(image) * _Height(image) * 4 + Do + inputBlue = _MemGet(mimg, start, _Unsigned _Byte) + inputGreen = _MemGet(mimg, start + 1, _Unsigned _Byte) + inputRed = _MemGet(mimg, start + 2, _Unsigned _Byte) + nc = (inputRed * 0.21) + (inputGreen * 0.72) + (inputBlue * 0.07) + _MemPut mimg, start, nc As _Unsigned _Byte + _MemPut mimg, start + 1, nc As _Unsigned _Byte + _MemPut mimg, start + 2, nc As _Unsigned _Byte + start = start + 4 + Loop Until start = length + _MemFree mimg +End Sub \ No newline at end of file diff --git a/lerp.bm b/lerp.bm new file mode 100644 index 0000000..3b96f7c --- /dev/null +++ b/lerp.bm @@ -0,0 +1,3 @@ +Function Lerp (v0, v1, t) + Lerp = (1 - t) * v0 + t * v1 +End Function \ No newline at end of file diff --git a/loadhexpalette.bm b/loadhexpalette.bm new file mode 100644 index 0000000..3069a17 --- /dev/null +++ b/loadhexpalette.bm @@ -0,0 +1,25 @@ +SUB LoadHexPalette (Filename$, palettearray() AS _UNSIGNED LONG) + DIM i AS INTEGER + DIM ff AS INTEGER + DIM r AS _UNSIGNED _BYTE + DIM g AS _UNSIGNED _BYTE + DIM b AS _UNSIGNED _BYTE + DIM Colorload AS STRING + i = LBOUND(palettearray) - 1 + ff = FREEFILE + IF _FILEEXISTS(Filename$) THEN + OPEN Filename$ FOR INPUT AS ff + DO UNTIL EOF(ff) + LINE INPUT #ff, Colorload + r = VAL("&H" + MID$(Colorload, 1, 2)) + g = VAL("&H" + MID$(Colorload, 3, 2)) + b = VAL("&H" + MID$(Colorload, 5, 2)) + i = i + 1 + IF i > UBOUND(palettearray) THEN + REDIM _PRESERVE palettearray(i) AS _UNSIGNED LONG + END IF + palettearray(i) = _RGB32(r, g, b) + LOOP + CLOSE ff + END IF +END SUB \ No newline at end of file diff --git a/max.bm b/max.bm new file mode 100644 index 0000000..2eaf1ec --- /dev/null +++ b/max.bm @@ -0,0 +1,3 @@ +FUNCTION Max (num1, num2) + Max = ((num1 > num2) * -num1) + ((num2 >= num1) * -num2) +END FUNCTION \ No newline at end of file diff --git a/min.bm b/min.bm new file mode 100644 index 0000000..334a9b2 --- /dev/null +++ b/min.bm @@ -0,0 +1,3 @@ +FUNCTION Min (num1, num2) + Min = ((num1 < num2) * -num1) + ((num2 <= num1) * -num2) +END FUNCTION \ No newline at end of file diff --git a/negative.bm b/negative.bm new file mode 100644 index 0000000..1d150ab --- /dev/null +++ b/negative.bm @@ -0,0 +1,25 @@ +Sub negative (__image As Long) + Dim __dest As Long + Dim __source As Long + Dim __y As Long + Dim __x As Long + Dim __orgc As _Unsigned Long + Dim __r As Integer + Dim __g As Integer + Dim __b As Integer + __dest = _Dest + __source = _Source + _Dest __image + _Source __image + For __y = 0 To _Height(__image) - 1 + For __x = 0 To _Width(__image) - 1 + __orgc = Point(__x, __y) + __r = 255 - _Red(__orgc) + __g = 255 - _Green(__orgc) + __b = 255 - _Blue(__orgc) + PSet (__x, __y), _RGB32(__r, __g, __b) + Next + Next + _Dest __dest + _Source __source +End Sub \ No newline at end of file diff --git a/noframe.bi b/noframe.bi new file mode 100644 index 0000000..4bb9ac2 --- /dev/null +++ b/noframe.bi @@ -0,0 +1,28 @@ + +Declare CustomType Library + Function FindWindow& (ByVal ClassName As _Offset, WindowName$) +End Declare + +Declare Dynamic Library "User32" + Function GetWindowLongA& (ByVal hWnd As _Offset, Byval nIndex As Long) + Function SetWindowLongA& (ByVal hWnd As _Offset, Byval nIndex As Long, Byval dwNewLong As Long) + Function SetWindowPos& (ByVal hWnd As _Offset, Byval hWndInsertAfter As Long, Byval x As Long, Byval y As Long, Byval cx As Long, Byval cy As Long, Byval wFlags As Long) +End Declare + +Const GWL_STYLE = -16 +Const WS_BORDER = &H800000 +Const WS_CAPTION = &H00C00000 +Const WS_THICKFRAME = &H00040000 +Const WS_MINIMIZEBOX = &H00020000 +Const WS_MAXIMIZEBOX = &H00010000 +Const WS_SYSMENU = &H00080000 + +Do: Loop Until _ScreenExists + +Dim hwnd As _Offset +Dim As Long winstyle, Style, a + +hwnd = _WindowHandle +winstyle = GetWindowLongA(hwnd, GWL_STYLE) +Style = (WS_CAPTION Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX Or WS_SYSMENU) +a = SetWindowLongA&(hwnd, GWL_STYLE, winstyle And Not Style) \ No newline at end of file diff --git a/solarize.bm b/solarize.bm new file mode 100644 index 0000000..f231eb9 --- /dev/null +++ b/solarize.bm @@ -0,0 +1,25 @@ +Sub Solarize (__image As Long, __threshold) + Dim __Dest As Long + Dim __Source As Long + Dim __y As Long + Dim __x As Long + Dim __orgc As _Unsigned Long + Dim __r As Integer + Dim __g As Integer + Dim __b As Integer + __Dest = _Dest + __Source = _Source + _Dest __image + _Source __image + For __y = 0 To _Height(__image) - 1 + For __x = 0 To _Width(__image) - 1 + __orgc = Point(__x, __y) + If _Red(__orgc) > __threshold Then __r = 255 - _Red(__orgc) Else __r = _Red(__orgc) + If _Green(__orgc) > __threshold Then __g = 255 - _Green(__orgc) Else __g = _Green(__orgc) + If _Blue(__orgc) > __threshold Then __b = 255 - _Blue(__orgc) Else __b = _Blue(__orgc) + PSet (__x, __y), _RGB32(__r, __g, __b) + Next + Next + _Dest __Dest + _Source __Source +End Sub \ No newline at end of file diff --git a/truncate.bm b/truncate.bm new file mode 100644 index 0000000..6f08dea --- /dev/null +++ b/truncate.bm @@ -0,0 +1,3 @@ +FUNCTION Truncate (value) + Truncate = (value > 0) * (((value < 256) * value) + ((value > 255) * 255)) +END FUNCTION \ No newline at end of file