Now that we have project importing, it makes it easier to have a “library”. I’ve adapted my code so that just about anything that I think I might use again goes in a central library project. I’ve written some crude “import” code so that not everything gets imported every time.
Some of it is quite generic: UI, Touch handling (including gesture recognition), Colour manipulation, Font and textareas, Matrices, and more. So I thought I’d make it generally available. Some of it has been available from my website, but now that I can have it all in one project it is easier for me to keep in a version control system. You can get the code from:
http://www.math.ntnu.no/~stacey/code/CodeaLibrary
It is a bzr
repository (bzr branch <url> <local dir>
), but you can also just grab the code itself. Order isn’t important except that the Import.lua
file must come before everything other than Main.lua
(the relative placement of Main.lua
isn’t important). To use a file in your code, save this lot in a project, add it to the imported list, and then in your own projection write import.library("<library name>")
. It can also take a table of names, and there’s a import.all()
function as well. The code protects from double importing.
Here’s a quick summary of what’s in the files. All of my work is CC0 when I’m allowed to do that. Some code is derived from other sources and so keeps the original licence. A couple of files aren’t really mine but are due to others on this forum.
-
BinDecHex.lua
Based on some code I got off the internet - see header for details (and licence). Functions for manipulating and converting binary, octal, decimal, hexadecimal numbers. -
Colour.lua
Functions for manipulating colours such as blending, shading. Also includes a colour picker. CC0. -
ColourNames.lua
Define colours by name: eithersvg
orx11
. Derived from aLaTeX
package and so licensed under the LPPL. -
Complex.lua
Complex numbers class, including functions acting on such. Includes overloading some of themath.
functions so that they work on complex numbers. CC0 -
ComplexPlane.lua
Code for visualising complex numbers on the complex plane. CC0 -
Coordinates.lua
Defines some “anchors” around the screen. Idea being that these are more intuitive than writing the coordinates literally. CC0 -
DataSeries.lua
This one isn’t mine. I want to say that it’s by @Mark, but I can’t find where I got it from right now. It, together withFrame.lua
andTrendGraph.lua
draws nice graphs of stuff in real time. -
Debug.lua
Not really well developed. Idea was to have a textarea where classes could send their debugging information. CC0 -
EuclideanPlane.lua
For visualising the Euclidean plane and matrix actions thereon. CC0 -
Fireworks.lua
Originally from this discussion. Licence unknown. -
Font.lua
This started out before we had native text handling, but it still does useful stuff. Of main interest will probably be the textarea class. CC0 -
Frame.lua
SeeDataSeries.lua
-
Import.lua
This sets up the code for importing other stuff so that it’s optional. -
Keyboard.lua
Once upon a time, Codea didn’t have access to the iPad keyboard. I still think it’s useful to have a keyboard that’s more manipulable than the Real One. CC0 -
Keypad.lua
Simulates a phone keypad (or a computer numeric one). Again, originates from the pre-keyboard era but is still useful as it’s not so intrusive as the whole keyboard. CC0 -
Main.lua
Idea is that this will provide tests for all of the classes. At the moment, it demonstrates the UI/Menu system and does some tests for theComplex
andVector
classes. CC0 -
Matrix.lua
Matrix class for … matrices. Also includes code to display and change a matrix (for theEuclideanPlane
project). CC0 -
Menu.lua
This provides a menu system, whereby it is easy (!) for things to define and use menus. A one-item menu looks awfully like a button. CCO -
NumberSpinner.lua
A Number Spinner! For choosing numbers. CC0 -
Playlist.lua
This was written to make it easy (!) to write a demonstration of a program. Most of my programs are interactive, but for making videos then I often want more control than I can get by myself, and also want text on the screen to show what’s going on. This makes that easy (!) to do. CC0 -
Quaternion.lua
If you know what they are, you’ll know what this is for. If you don’t, be thankful. Written originally as quaternions are good for encoding rotations. CC0 -
Shape.lua
One of my earliest projects was a 3D shape explorer. This is the code for the overall shape class. CC0 -
ShapeElements.lua
A Shape needs lots of pieces: vertices, edges, and the like. CC0 -
Shapes.lua
Specific shapes. CC0 -
Slider.lua
On-screen version of the sliders in theOutput
pane, but with callbacks instead of merely setting parameters. CC0 -
Space.lua
This started out as part of the Shape system. It’s for interacting with a project as if it were 3D and manipulating the view via touch and moving the iPad. CC0 -
TestSuite.lua
This is so that other classes can define “testsuites” that can then be examined when this project is run by itself. CC0 -
Touch.lua
A general touch handler. It gathers all touches to itself, then analyses them, and hands them to other objects together with a fair amount of extra information to make it easier for objects to recognise different gestures. CC0 -
TrendGraph.lua
SeeDataSeries.lua
. -
UI.lua
User Interface class. Lots of the other classes are really only run via the UI class. For example, instead of invoking the keyboard directly, you would ask theUI
class to get a string and it would then invoke the keyboard. -
Utilities.lua
Some auxiliary functions that don’t fit elsewhere (such as a mesh-based rounded-rectangle). CC0 -
Vec3.lua
Believe it or not, thevec3
object used not to have any methods and this was to obviate that lack. CC0 -
Vector.lua
For arbitrary length vectors, including vectors of complex numbers. Standard methods, also now includes an implementation of the Fast Fourier Transform. CC0 -
utf8.lua
For manipulating utf8 strings. Lua can handle unicode, but some of the string manipulation functions work on bytes rather than characters. CC0 -
utf8Case.lua
Auxiliary file for theutf8
library which contains the unicode upper/lower case table. Derived from a file on the unicode website which has no licence.