XAddon (a robust library)

Monkey Forums/User Modules/XAddon (a robust library)

Goodlookinguy(Posted 2016) [#1]
XAddon is a robust, jack-of-all-trades, library I've been developing for over 4 years (3-years publicly). While I plan to toss out a lot of it because it's old (and sometimes bad) code, the one part of it that's stayed after all of this time is my xaddon.basic module.

The XAddon.basic module provides a lot of the missing functionality from Monkey and can be used without mojo. This means that the library is also perfect to use for command line tools.

The license is LGPL, even if I didn't put it on the repo pages. That basically means you're free to use it and if you make fixes, you just have to make them public.
Update: Since people care about licenses here more than the usual places, screw it. This is now under the WTF public license (WTFPL). I honestly don't care. I wouldn't be sharing it if I didn't want as many people to use it as possible.


Download: https://bitbucket.org/Goodlookinguy/xaddon/downloads
Import xaddon.basic


The benefits of using xaddon.basic are presented here (enjoy)...

strfuncs
* Set/Unset Flags (this was actually supposed to be in the stdfuncs file...)
* Rot5, Rot13, Rot18, and Rot47
* PadLeft and PadRight
* Highly efficient RepeatStr
* CountSubStr
* ArrayToString and ArrayToStringF

stdmath
* Barycentric, BinomialCoefficient, Factorial
* Hermite
* InvSqrt
* Lerp, InvLerp, and LerpAngle
* Interpolate function with an absurd number of built-in timing functions
* Bezier function (untested)
* Rounding Functions (Round, RoundExact)
* Radian/Degrees Conversion
* Powers of 2 functions (NextPowerOfTwo, PrevPowerOfTwo, NearestPowerOfTwo)

stdfuncs
* ClampPercent
* ReversePercent
* HertzToFrames
* Ror, Rol, Xor (boolean)
* RGBToInt (now updated for Mojo2 usage, r & b were flipped)
* RGB2ToInt (percentage based)
* IntToA, IntToB, IntToG, IntToR and IntToAlpha, IntToB2, IntToG2, IntToR2
* DataBufferToHex and HexToDataBuffer
* The most efficient ByteToHex, HexToByte, DecToHex, DecToHexBE, DecToHexLE, HexToDec, HexBEToDec, and HexLEToDec you will ever touch. These were tested to beat the rest.
* BinToDec and BaseConvert (2-36)
* BoolToString
* Floating point PositiveInfinity, NegativeInfinity, and NaN values

externalfuncs
* Lsr
* MilliSeconds (returns real milliseconds)
* FloatBitsToInt and IntBitsToFloat (to be updated soon with faster replacement)

dyndatabuffer
The DynDataBuffer is just a DataBuffer wrapper that automatically allocates space as needed.

cryptofuncs
* TextEncode and TextDecode using simple xor crypto
* Base64Encode and Base64Decode
* CRC32 (table is pre-allocated instead of calculated lazily)

cmpfuncs
* ApproximatelyEqual (an extremely useful function for comparing floats)
* IsEven, IsOdd, IsPowerOfTwo
* Inclusive, Exclusive, and InIndexRange

arrays
Array1D<T>
* Clone
* Copy
* Merge
* Clear
* ShiftLeft, ShiftRight
Array1DAB<A,B>
* CastArray (from type A to type B)
Local strArray := Array1DAB<Int,String>.CastArray(intArray)


xaddon.basic.collections
Ignore everything in that folder but these...
* HashMap
* LinkedHashMap
* Primary Types Hashers and Comparators
Local example := New StringHashMap<Int>()


xaddon.basic.sorting
Contains a few different choices for sorting arrays...
* BubbleSort
* HeapSort
* InsertionSort
* MergeSort and MergeSortNoCS
* QuickSort and QuickSortRandom
* ShellSort
Example...
Local sorter := New ArrayMergeSortNoCS<Int>()
sorter.Sort(arrayGoesHere, IntComparator.Instance())


xaddon.basic.spatial
Aside from what I write here, do not use anything else as it was put up on the chopping block or is going to be refactored.
* Vector2 - The most robust Vector2 class you will ever touch in Monkey (believe me)
* Grid - Solves grids, useful for resizable GUIs.
* funcs - SnapToGrid useful for snapping to grids
Grid Example Found Here: https://bitbucket.org/Goodlookinguy/xaddon/src/f5524fb2ef1bba12deaaec774b5ea6cb0a6e6dfd/examples/grid_test.monkey?at=default&fileviewer=file-view-default

If you have any questions on either how to use the code or if something is broken, by all means ask. I'll try to respond when I can.


Danilo(Posted 2016) [#2]
> The license is LGPL, even if I didn't put it on the repo pages.
> That basically means you're free to use it and if you make fixes, you have to make them public.

If you want to allow use of your stuff in closed-source software, the MIT license would be better.


Goodlookinguy(Posted 2016) [#3]
LGPL is compatible with closed-source software. The only stipulation is making fixes and changes open. To be honest, I don't even expect anyone to do that even if they do see the license, so in the end it's not a big deal. I think most people will do what they do regardless of licenses, so meh.


Danilo(Posted 2016) [#4]
> LGPL is compatible with closed-source software.

Only limited. The end-user of my product has the right and freedom to modify the LGPL-part of the software.

So, if your lib is a DLL that I use with my product (EXE), the end-user (my customer) can make changes
to the LGPL-lib (the DLL), and my EXE then uses his modified version.

But with included files (if your LGPL-code is inside my EXE), I cannot give this freedom and right
to my customer without releasing my source code as well. But, I have to give him this right and freedom,
according to the license.

https://en.m.wikipedia.org/wiki/GNU_Lesser_General_Public_License
The license only requires software under the LGPL be modifiable by end users via source code availability.
For proprietary software, code under the LGPL is usually used in the form of a shared library such as a DLL,
so that there is a clear separation between the proprietary and LGPL components.


Just saying, because I think it would be sad that such a great library can only be used
for open-source software.


DruggedBunny(Posted 2016) [#5]
Yeah, Danilo's right -- this code would effectively be statically-linked into 'my' executable (as module; or copied directly into my source), so I would have to release my source under the LGPL/GPL. The only way to avoid this with LPGL is to supply 'your' code as a DLL alongside 'mine', ie. to dynamically link to your code.

Best to use one of the ironically 'less-free' licenses if you intend to allow this, as in BSD, MIT, zlib, Apache, etc.

See http://choosealicense.com/ -- and http://choosealicense.com/licenses/ for more.

MIT's probably the simplest and closest to your intentions. (Unless you actually do intend to 'force' any changes to be made open.)


Goodlookinguy(Posted 2016) [#6]
I changed the license to WTFPL because I honestly don't care about licenses. I'd like people to share fixes, but I'm not going to force it since it turns into bureaucratic nonsense. Enjoy.


CopperCircle(Posted 2016) [#7]
Some great functions there, thanks.


Goodlookinguy(Posted 2016) [#8]
Is it just me or does it feel like I'm missing something in the library? Maybe I just need more functions. Looking at it like this, it seems rather empty even though I know it has plenty of things. Maybe I just need to categorize better.

I'll look into copying some .NET categorization tactics, although not as intensely as them. I really want a large library of just everything under the sun minus game specific things.


Amon(Posted 2016) [#9]
Thank you! There's some cool stuff there.


Nobuyuki(Posted 2016) [#10]
I noticed the second "GPL" anything gets slapped on code then people here seem to see it as a hostile affront, and practically no one here will use it regardless of the codepath exceptions made. Don't sweat it GLG; just license it how you want it since chances are like you said there aren't going to be too many contributors and a lot of 'critics' are simply looking to maximize the free stuff with the least amount of personal inconvenience (that's just how they tend to get along most likely). Community spirit -- if enough of it exists -- will either manifest itself as contributions to your code, or someone else's alternative implementation with licensing better for them.