General functions
- scrupp.init(title, width, height, bit_depth, fullscreen, [resizable])
- Creates a window with the chosen title, a size in pixel
chosen by width and height and the chosen
bit_depth. The fullscreen parameter toggles
between fullscreen (true) or window mode
(false). If window mode is selected, the optional
boolean parameter resizable enables or disables the resizing
of the window.
- scrupp.getWindowWidth()
- Has to be called after scrupp.init().
Returns the window width in pixels.
- scrupp.getWindowHeight()
- Has to be called after scrupp.init().
Returns the window height in pixels.
- scrupp.getWindowSize()
- Has to be called after scrupp.init().
Returns the window width and height in pixels.
- scrupp.getTicks()
- Has to be called after scrupp.init().
Returns the number of milliseconds since the start of the
application.
- scrupp.setDelta(delta)
- Sets the minimum delta in milliseconds between two
frames. If delta equals 0, Scrupp runs as
fast as possible.
- scrupp.showCursor([show])
- If called without argument, returns the current state of the cursor
as boolean. Otherwise the state of the cursor is changed depending on
the boolean argument show.
- scrupp.exit()
- A call to this function immediately exits the application.
- scrupp.addFile(filename)
- Runs the Lua file with the chosen filename.
Returns all values returned by the script.
- scrupp.draw(table)
- This function can draw points, lines and polygons. The array part of
the table contains the list of x,y coordinate pairs of the
points. The interpretation of those points depends on several settings
made by the following key-value pairs. All of them are optional.
- color [= {255, 255, 255, 255}]
- This table sets the color of the point(s), line(s) or polygon(s)
to the given value. The first three elements are the red, green and
blue components of the color. The optional fourth value is the alpha
component. All four elements have to be in the range from 0 to 255.
The default color is opaque white.
- size [= 1]
- Sets the pixel size or line width to the chosen number. The
default value is 1.
- centerX [= 0] and centerY [= 0]
- These are the coordinates of the center of scaling and rotation.
- scaleX [= 1] and scaleY [= 0]
- Define the scale factor of the x- and y-axis.
- rotate [= 0]
- The angle in degrees to rotate the graphic.
- relative [= false]
- If this boolean value is true, the first point in the array defines
where the graphic should be moved to. All other points in the array are
relative to the first one.
- connect [= false]
- If this boolean value is true and if there are more than two
points a line will be drawn between the first and the second,
the second and the third and so on. The default value is false.
- fill [= false]
- If this boolean value is true the created shape will be filled
with the chosen color. The default value is false.
- antialiasing [= false]
- This boolean value activates or deactivates the anti-aliasing.
If it is true, pixels with a size greater one will become
circles and lines will blend nicely with the background.
The default value is false.
- pixellist [= false]
- If the boolean value pixellist is true, a point
will be drawn at each location given by the coordinate pairs. If it
is false and there is more than one point, the points will be interpreted
as one or more line(s) or as a polygon depending on the other options.
The default value is false.
Example
scrupp.init("Draw Test - Click to test!", 600, 400, 32, false)
-- prepare one table for big white pixels
local pixels = { antialiasing = false, size = 20, pixellist = true }
-- prepare one table for red connected lines
local lines = { color = {255,0,0}, antialiasing = true, connect = true }
main = {
render = function(dt)
scrupp.draw(lines)
scrupp.draw(pixels)
end,
mousepressed = function(x, y, button)
-- add the point where the mouse was pressed to the list of pixels
pixels[#pixels+1] = x
pixels[#pixels+1] = y
-- add the point to the list of lines, too
lines[#lines+1] = x
lines[#lines+1] = y
end
}