Module screen

screen

Functions

clear () clears the screen.
refresh () redraws the screen; reveals changes.
update () norns alias to redraw the screen; reveal changes.
move (x, y) move the current position.
move_rel (x, y) move the current position with relative coordinates.
color (r, g, b, a) sets screen color.
level (value) sets greyscale color/brightness.
pixel (x, y) draws a single pixel.
pixel_rel () draws a single pixel at the current coordinate.
line (bx, by) draws a line.
line_rel (bx, by) draws a line relative to the current coordinates.
curve (x1, y1, x2, y2, x3, y3) draws a (cubic) bezier curve.
rect (w, h) draws a rectangle.
rect_fill (w, h) draws a filled-in rectangle.
arc (radius, theta_1, theta_2) draws a circle arc centered at the current position.
circle (radius) draws a circle centered at the current position.
circle_fill (radius) draws a circle centered at the current position.
triangle (ax, ay, bx, by, cx, cy) draws a filled in triangle with the given coordinates.
quad (ax, ay, bx, by, cx, cy, dx, dy) draws a filled in quad with the given coordinates.
geometry (vertices, indices, texture) draws arbitrary vertex-defined geometry.
text (text) draws text to the screen.
text_center (text) draws text to the screen.
text_right (text) draws text to the screen.
get_text_size (text) gets size of text.
get_size () returns the size of the main window.
set_size (w, h, z) sets the size of the current window
set_fullscreen (is_fullscreen) sets the fullscreen state of the current window
set_position (x, y) sets the position of the current window on the display
key (char, modifiers, is_repeat, state) callback executed when the user types a key into the gui window.
mouse (x, y) callback executed when the user moves the mouse with the gui window focused.
click (x, y, state, button) callback executed when the user clicks the mouse on the gui window.
wheel (x, y) callback executed when the user scrolls with the mouse wheel on the gui window.
resized () callback executed when the user resizes a window

Texture:render (x, y, zoom) renders the texture object with top-left corner at (x,y)
screen.Texture.render_extended (x, y, theta, flip_h, flip_v, zoom) renders the texture object with top-left corner at (x,y)
new_texture (width, height) creates and returns a new texture object the texture data is a rectangle of dimensions (width,height) with top-left corner the current screen position call before calling screen.refresh.
new_texture_from_file (filename) creates and returns a new texture object from an image file


Functions

clear ()
clears the screen.
refresh ()
redraws the screen; reveals changes.
update ()
norns alias to redraw the screen; reveal changes.
move (x, y)
move the current position.

Parameters:

  • x integer target x-coordinate (1-based)
  • y integer target y-coordinate (1-based)
move_rel (x, y)
move the current position with relative coordinates.

Parameters:

  • x integer relative target x-coordinate
  • y integer relative target y-coordinate
color (r, g, b, a)
sets screen color.

Parameters:

  • r integer red value (0-255)
  • g integer green value (0-255)
  • b integer blue value (0-255)
  • a integer alpha value (0-255) (default 255)
level (value)
sets greyscale color/brightness.

Parameters:

  • value integer (0-15; 0=off, 15=white)
pixel (x, y)
draws a single pixel.

Parameters:

  • x integer x-coordinate (1-based)
  • y integer y-coordinate (1-based)
pixel_rel ()
draws a single pixel at the current coordinate.
line (bx, by)
draws a line.

Parameters:

  • bx integer target x-coordinate (1-based)
  • by integer target y-coordinate (1-based)
line_rel (bx, by)
draws a line relative to the current coordinates.

Parameters:

  • bx integer target relative x-coordinate
  • by integer target relative y-coordinate
curve (x1, y1, x2, y2, x3, y3)
draws a (cubic) bezier curve.

Parameters:

  • x1 number 1rst handle x
  • y1 number 1rst handle y
  • x2 number 2nd handle x
  • y2 number 2nd handle y
  • x3 number 3rd destination x
  • y3 number 3rd destination y
rect (w, h)
draws a rectangle.

Parameters:

  • w integer width in pixels
  • h integer height in pixels
rect_fill (w, h)
draws a filled-in rectangle.

Parameters:

  • w integer width in pixels
  • h integer height in pixels
arc (radius, theta_1, theta_2)
draws a circle arc centered at the current position. angles are measured in radians and proceed clockwise with 0 pointing to the right. We should have 0 <= theta_1 <= theta_2 <= 2 * pi

Parameters:

  • radius integer in pixels
  • theta_1 number initial angle in radians.
  • theta_2 number terminal angle in radians.
circle (radius)
draws a circle centered at the current position.

Parameters:

  • radius integer in pixels
circle_fill (radius)
draws a circle centered at the current position.

Parameters:

  • radius integer in pixels
triangle (ax, ay, bx, by, cx, cy)
draws a filled in triangle with the given coordinates.

Parameters:

  • ax number x-coordinate in pixels
  • ay number y-coordinate in pixels
  • bx number x-coordinate in pixels
  • by number y-coordinate in pixels
  • cx number x-coordinate in pixels
  • cy number y-coordinate in pixels
quad (ax, ay, bx, by, cx, cy, dx, dy)
draws a filled in quad with the given coordinates.

Parameters:

  • ax number x-coordinate in pixels
  • ay number y-coordinate in pixels
  • bx number x-coordinate in pixels
  • by number y-coordinate in pixels
  • cx number x-coordinate in pixels
  • cy number y-coordinate in pixels
  • dx number x-coordinate in pixels
  • dy nubmer y-coordinate in pixels
geometry (vertices, indices, texture)
draws arbitrary vertex-defined geometry.

Parameters:

  • vertices a list of lists of the form {{x, y}, {r, g, b, a?}, {tx, ty}?}, where x, y, tx, and ty represent pixel coordinates and r, g, b, a represents a color.
  • indices (optional) a list of indices into the vertices list
  • texture (optional) a texture created by screen.new_texture
text (text)
draws text to the screen.

Parameters:

text_center (text)
draws text to the screen.

Parameters:

text_right (text)
draws text to the screen.

Parameters:

get_text_size (text)
gets size of text.

Parameters:

Returns:

  1. integer w width in pixels
  2. integer h height in pixels
get_size ()
returns the size of the main window.

Returns:

  1. integer w width in pixels
  2. integer h height in pixels
set_size (w, h, z)
sets the size of the current window

Parameters:

  • w integer width in pixels
  • h integer height in pixels
  • z integer zoom factor
set_fullscreen (is_fullscreen)
sets the fullscreen state of the current window

Parameters:

  • is_fullscreen bool
set_position (x, y)
sets the position of the current window on the display

Parameters:

  • x integer x-position of upper left corner
  • y integer y-position of upper left corner
key (char, modifiers, is_repeat, state)
callback executed when the user types a key into the gui window.

Parameters:

  • char string or table either the character or a table of the form {name = "name"}
  • modifiers table a table with the names of modifier keys pressed down
  • is_repeat bool true if the key is a repeat event
  • state integer 1 for a press, 0 for release
mouse (x, y)
callback executed when the user moves the mouse with the gui window focused.

Parameters:

  • x number x-coordinate
  • y number y-coordinate
click (x, y, state, button)
callback executed when the user clicks the mouse on the gui window.

Parameters:

  • x number x-coordinate
  • y number y-coordinate
  • state integer 1 for a press, 0 for release
  • button integer bitmask for which button was pressed
wheel (x, y)
callback executed when the user scrolls with the mouse wheel on the gui window.

Parameters:

  • x number amount moved in the x-direction (right positive)
  • y number amount moved in the y-direction (away from you positive)
resized ()
callback executed when the user resizes a window

Texture:render (x, y, zoom)
renders the texture object with top-left corner at (x,y)

Parameters:

  • x integer x-coordinate
  • y integer y-coordinate
  • zoom number scale at which to draw, defaults to 1
screen.Texture.render_extended (x, y, theta, flip_h, flip_v, zoom)
renders the texture object with top-left corner at (x,y)

Parameters:

  • x integer x-coordinate
  • y integer y-coordinate
  • theta number angle in radians to rotate the texture about its center
  • flip_h bool flip horizontally if true
  • flip_v bool flip vertically if true
  • zoom number scale at which to draw, defaults to 1
new_texture (width, height)
creates and returns a new texture object the texture data is a rectangle of dimensions (width,height) with top-left corner the current screen position call before calling screen.refresh. this operation is slower than most screen calls; try not to call it in a clock, for instance.

Parameters:

  • width integer width in pixels
  • height integer height in pixels
new_texture_from_file (filename)
creates and returns a new texture object from an image file

Parameters:

  • filename string absolute path to file
generated by LDoc 1.5.0 Last updated 2024-01-13 13:12:10