iris
Transform
Transform module
Transformations
Transform~Up constant
Literal value
¯1ℂ
Transform~Down constant
Literal value
1ℂ
Transform~Left constant
Literal value
¯i
Transform~Right constant
Literal value
i
Transform~Coords function
Convert an array from complex coordinates to vector cooridinates
Returns an array with the shape of the orignal, and and an additional 2-long trailing axis.
The first component is the X
, and the second is the Y
.
The imaginary part of a complex number corresponds to X
and the real part to Y
.
°Coords
takes vector coordinates and gives the complex equivalent.
Source code
Coords ← ⌅(⍥CImpl=3⊸type ⊸CoordError|⍥°CImpl=0⊸type ⊸CoordError)
Transform~Grid function
Source code
Grid ← ˜ℂ⊢₂°⍉°⊡
Collide
Collide module
Collide~Rects function
Check if two rectangles collide ? Size₁ Position₁ Size₂ Position₂
Source code
Rects ← /×/⊂> ⇌ ˜∩(⊟≡₀⊙∘) ∩˜(⟜+∩°⍉∩T~Coords)
Collide~Circles function
Check if two circles collide ? Radius₁ Center₁ Radius₂ Center₂
Source code
Circles ← <⊓(+|⌵-∩°T~Coords)⊙:
Collide~CirclePoint function
Check if a point is inside a circle
Source code
CirclePoint ← ≤⊙(⌵-∩°T~Coords)
Collide~RectPoint function
Check if a point is inside a rectangle
Source code
RectPoint ← ×××∩°ℂ⊓⌟≥≤ °⊟\+°⍉ ∩°T~Coords
Collide~RectCircle function
Check if a rectangle and a circle collide
Source code
RectCircle ← > ⌵- ⊸(↥⊙↧) °⊟\+°⍉°T~Coords ⊙:
Color
Color module
Color~Clear constant
Literal value
[0 0 0 0]
A color with an opacity of zero
Color~Rgb function
Convert a color from 8-bit rgb to Uiua colors
Uiua color channels are represented by values 0-1
, while standard graphics uses integers from 0-255
.
Colors are rounded to four decimal places so that they display nicely (this will not affect their 8-bit value.)
°Rgb
converts a Uiua color back to an 8-bit color.
Both Rgb
and °Rgb
clamp the values to be within the correct ranges.
Source code
Rgb ← ⌅(↥0↧1⁅₃) ÷255 °⌅(↥0↧255⁅)
Color~Hex function
Convert a hexadecimal string into a color
Expects a string in the form #RRGGBB
where all the letters are hexadecimal digits corresponding to color channels.
The leading #
can be omitted, and and alpha channel can also be specified at the end.
This function is pervasive, and will convert an array of strings, or an array of box strings into an array of colors.
The output will always be non-box, so if a single string has an alpha channel, all of the output will.
°Hex
converts a color back into a hexidecimal string, always including the #
.
Source code
Hex ← (⌅( ⨬(⬚1≡₀◇^0|≡₁^0)=1⊸type ¯⌵ | ⨬(⬚@f≡₀◇°^0|≡₁°^0)=0⊸type))!( ⌅(⍣⌝⊂◌@#|⊂@#) ⌅(⍤"Hex string must be characters"=1⊸type ⍤"Hex string must have 6 or 8 characters"∊[6]_[8]⊸△) ⌅(⍤"Hex string has invalid characters"¬⊸˜∊∞) ⬚∞˜⊗HexDigits Rgb ⌝⊥16°⌅≡⬚0↙₂ ≡⇌ ⌅(↯∞_2|♭) °⌅(⍤"Color must be numbers"=0⊸type ⍤"Color must be 3 or 4 digits"∊[3]_[4]⊸△) )
Color~Alpha function
Get the alpha channel (transparency) of an image
If Alpha
is called on an image without an alpha channel, a fully opaque one will be added.
⍜Alpha
edits the alpha channel, and °⊸Alpha
can be used to set it.
For either inverse if a scalar is provided the entire alpha channel will be set to it.
0
is fully transparent and 1
is fully opaque.
Source code
Alpha ← ⊣°⍉ ⌅(⨬(⍉˜⊂1|⍜°⍉⬚1↙₄|∘|∘)⊸ColorFormat)
Color~Rosewater constant
Literal value
[0.961 0.878 0.863]
Color~Flamingo constant
Literal value
[0.949 0.804 0.804]
Color~Pink constant
Literal value
[0.961 0.761 0.906]
Color~Mauve constant
Literal value
[0.796 0.651 0.969]
Color~Red constant
Literal value
[0.953 0.545 0.659]
Color~Maroon constant
Literal value
[0.922 0.627 0.675]
Color~Peach constant
Literal value
[0.98 0.702 0.529]
Color~Yellow constant
Literal value
[0.976 0.886 0.686]
Color~Green constant
Literal value
[0.651 0.89 0.631]
Color~Teal constant
Literal value
[0.58 0.886 0.835]
Color~Sky constant
Literal value
[0.537 0.863 0.922]
Color~Sapphire constant
Literal value
[0.455 0.78 0.925]
Color~Blue constant
Literal value
[0.537 0.706 0.98]
Color~Lavender constant
Literal value
[0.706 0.745 0.996]
Color~Text constant
Literal value
[0.804 0.839 0.957]
Color~Subtext function
Source code
Subtext ← ˜⊏Hex "#a6adc8"_"#bac2de"
Color~Overlay function
Source code
Overlay ← ˜⊏Hex "#6c7086"_"#7f849c"_"#9399b2"
Color~Surface function
Source code
Surface ← ˜⊏Hex "#313244"_"#45475a"_"#585b70"
Color~Base constant
Literal value
[0.118 0.118 0.18]
Color~Mantle constant
Literal value
[0.094 0.094 0.145]
Color~Crust constant
Literal value
[0.067 0.067 0.106]
Window
Window module
Window~Full function
Check if the window is fullscreen
Full
returns a boolean to tell if the window is in fullscreen mode.
°Full
can be passed a boolean to set the state of fullscreen mode.
A common pattern to toggle fullscreen is ⍜Full¬
.
Source code
Full ← ⌅( Rayua~IsWindowFullscreen | ⍥⊸(˜⍤$"Fullscreen state must be a boolean, but it is _"F)¬≍1⊸∊0_1 ⍥Rayua~ToggleFullscreen≠Rayua~IsWindowFullscreen)
Window~Size function
The size of the window
The dimensions returned are in pixels.
°Size
sets the size of the window.
If the window is in fullscreen mode when °Size
is called, fullscreen mode with be turned off.
Neither dimension of the window can be zero.
If a single number is given as the dimensions, it will be used as both the width and the height.
Source code
Size ← (°T~Coords ⌅( Os‼macos÷₂ ⊟Rayua~GetRenderWidth Rayua~GetRenderHeight | ⍥⊸(˜⍤0$"Window size must be greater than zero, but it is _"F) ¬×⊸⊃(≍1/×>0|≍[2]△) ⌈ ⍥(↯2)≍[]⊸△ °Full 0 Rayua~SetWindowSize °⊟))
Window~FullSize function
Get the size of the window when it is fullscreen
Source code
FullSize ← (°T~Coords⊟ Rayua!⊃GetMonitorWidth GetMonitorHeight Rayua~GetCurrentMonitor)
Window~FPS function
The active FPS (framerate)
FPS
returns the actual framerate, which varies based on how long your device takes to run a frame.
°FPS
sets the maximum FPS. By default, the FPS is unbounded, and frames will be run as fast as possible.
FPS
can take ∞
to have the fastest possible framerate (the default behavior.)
Source code
FPS ← ⌅( Rayua~GetFPS | ⍥⊸(˜⍤0$"FPS must be greater than zero, but it is _"F)¬×⊸⊃(>0|≍[]△) ⌈ Rayua~SetTargetFPS)
Sound
Sound module
Sound~Data data boxed
Sound~Unload function
Unload a sound, freeing it's memory
Source code
Unload ← ≡₁(Rayua~UnloadSound ⍤"Cannot free an active sound, only a source sound." Data!⊃Clone Buffer)
Sound~Play function
Source code
Play ← Data⊙1 ⊸Rayua~PlaySound Rayua~LoadSoundAlias Data~Buffer
Sound~Start function
Source code
Start ← ⍜Data~Buffer⊸Rayua~PlaySound
Texture
Texture module
Texture~Data data boxed
Texture~Unload function
Unload a texture, freeing it's memory
Once a texture is unloaded, attempting to draw it will result in an all-black texture. Calling this function multiple times on a texture will not doing anything.
Source code
Unload ← Rayua~UnloadTexture Data~Buffer
Texture~Size function
Get the dimensions of a texture
Source code
Size ← ℂ≡₁(Rayua~Texture!⊃Width Height Data~Buffer)
Texture~LoadFile function
Load a texture from a filepath
The file must contain an image, and have the proper extension for the image format.
The color format of a texture created this way is always color with an alpha channel.
⍜LoadFile
will load the texture, and then free the memory when the function is over.
[NOTE] You cannot load a texture before Open
is called, it will cause a segfault.
Source code
LoadFile ← (⌅(^0|.^0|^1))!(Data ⊙3 Rayua~LoadTexture|Unload)
Texture~Image function
Get the image in a texture without unloading the texture
Image
remembers the color format of the image you made the texture with. If you provided a grayscale, you will get back a grayscale.
°⊸Image
edits the image in a texture. It takes the new image as the first argument and the texture as the second argument.
⍜Image
gets the image, allows you to change it, and then puts the new image back in the texture.
If any of the properties of the image are altered, like the shape or the color format, this function will error.
Source code
Image ← (⌅(^0|⟜^0|^1))!( °ToRayImage ⍜Data~Buffer Rayua~LoadImageFromTexture | ⟜(Rayua~UpdateTexture Data~Buffer)⊙(♭ °Color~Rgb ToFullColor) ◡˜ImageError)
Texture~LoadImage function
Load a texture from a Uiua image array
The provided image can be in any color format a Uiua image can be in, except for complex domain coloring.
The formats are defined in the Uiua tutorial.
The format you use to create the texture is the only one that may be used by the texture.
Calling Image
will result in an image of the same format.
[NOTE] You cannot load a texture before Open
is called, it will cause a segfault.
Source code
LoadImage ← (⌅(^0|^1|.^0|^2))‼( ⍜Data~Buffer Rayua~LoadTextureFromImage ToRayImage | Unload⟜Image | Unload)
Texture~Draw function has optional arguments
Draw a texture on the window
Color
tints a texture a particular color.
Angle
is given in rotations [0,1]
, clockwise.
Optional args: Color Angle Centered
Source code
~Draw {Color ← White|Angle ← 0|Centered ← 0} ( ⊃(Color|Angle|⋅∘|Centered) ⊓(ColorArg | ×360◿1 | ≡₁⊃(□Data~Buffer|□⊂0_0⊟°ℂSize) | ⊃(≡₀⍚⊂ ⍥(+◡⋅÷₂)¬|⋅⋅÷₂) ⊙˜⊓PosArg SizeArg) ≡₀◇Rayua~DrawTexturePro S!cdefba )
Texture~DrawScreen function has optional arguments
This function is DEPRECATED use Draw~Background
instead
Draw a texture covering the whole window.
The texture will be stretched/scaled to properly fit the size of the window.
DrawScreen
also supports a Color
arg, like Draw
Optional args: Color
Source code
~DrawScreen [Color ← White] Draw ⊙(Window~Size 0_0) Color:Color
Draw
Draw module
Draw different shapes onto the window
Draw~Background function
Fill the whole window with a color or texture
When given a color, Background
covers the whole window with that color.
When given a texture Background
scales the texture to fit over the whole window.
Source code
Background ← ( ⊸IsTexture ⨬(Rayua~ClearBackground ⍤"Background does not take multiple colors"≍[4]⊸△ °□ ColorArg | Texture~Draw⊙(Window~Size 0_0)) )
Draw~Line function
Draw a line on the window
A line will draw from point A to point B, even if either are outside the window. A thickness of zero will cause the line not to draw at all.
Source code
Line ← ≡₀◇Rayua~DrawLineEx S!cdba ⊓(ColorArg|↥₀⌈|∩PosArg)
Draw~Circle function has optional arguments
Draw a circle on the window
An angle and a starting position can be supplied to draw a sector of the circle.
Angle
can have the range [-1,1]
where positive is clockwise.
Start
can have the range [0,1]
where 0
is upward also moving clockwise.
Optional args: Angle Start
Source code
~Circle {Angle ← 1|Start ← 0} ( ⊃Angle Start ≍1⟜(⌈×32|∩(-90×360) ⊸+) ⊓(⍜⌵↧₁|◿₁|ColorArg|↥₀⌈|PosArg) # B Segments End Start Color Radius Center ? ⨬(≡₀◇Rayua~DrawCircleSector S!fecbad|≡₀◇Rayua~DrawCircle S!fed) )
Draw~Text function has optional arguments
Print text to the window
Font
is a filepath pointing to a font file. If not specified, the Raylib font is used.
Spacing
changes how far apart characters are placed from eachother. By default it is 10% of the fontsize.
Centered
centers the text both horizontally and vertically.
Optional args: Font Spacing Centered
Source code
~Text {Centered ← 0|Font ← ∞|Spacing ← 0} ( ⊃(Centered|Font|Spacing) ⊙(⊓(□|∘|ColorArg|↥₀|PosArg|≡₀⍚$"_"BoxStrings) S!afedbc ≡₀⍚LoadFont⊙⤙⊙⊙∘ ⟜(⍥⋅◡⋅÷₁₀◇≍∞) ) # Centered Font Text Pos Size Spacing Color ? ≡₀◇(Rayua~DrawTextEx⍥(⍜⊙⋅⋅∘- ◡(÷₂Rayua~MeasureTextEx⊙⊙⋅⊙∘))) )
Draw~Rect function has optional arguments
Draw a rectangle on the window
Optional args: Centered
TODO: Change back once pervasion is fixed
Source code
~Rect [Centered ← 0] ≡₀◇Rayua~DrawRectangle S!bca ⊓(ColorArg|⍥(≡₀⍚-◡⋅÷₂) ⊙˜⊓PosArg SizeArg) ⊃⋅∘Centered # TODO: Change back once pervasion is fixed
Draw~Square function has optional arguments
Draw a square on the window
Exactly like Rect
, except that the size is a scalar instead of a vector
Optional args: Centered
Source code
~Square [Centered ← 0] Rect ⊙(⍉↯2) Centered:Centered
Key
Key module
Key~Space constant
Literal value
@
Key~Pressed function
Check if a key was pressed once
Source code
Pressed ← ≡₀◇(Rayua~IsKeyPressed Fix)
Key~Down function
Check if a key is down
Source code
Down ← ≡₀◇(Rayua~IsKeyDown Fix)
Key~Pressed‼ index macro
Call a function when a key is pressed
The first function is the key to run the function on (or identity to take from the stack) The second function will be called when the key is pressed
Source code
Pressed‼ ← ⍥(^1)Pressed ^0
Key~Down‼ index macro
Call a function when a key is down
The first function is the key to run the function on (or identity to take from the stack) The second function will be called when the key is down
Source code
Down‼ ← ⍥(^1)Down ^0
Key~Typed function
Get the characters that the user has typed
This function returns a string of queued characters If the user has not typed since the function was called, the string will be empty
Source code
Typed ← (⍥(⊂:▽⊸≠@\0Rayua~GetCharPressed)∞ "")
Key~TypedCodes function
Get the key codes that the user has typed
This function returns an array of queued key codes If the user has not typed since the function was called, the array will be empty
Source code
TypedCodes ← (⍥(⊂:▽⊸≠0Rayua~GetKeyPressed)∞ [])
Key~Input function
Emulate a text input on a string
This function edits a string based on the user's keyboard inputs Typing alphanumerics will append to the string, as well as non-printing characters like newline, space, and tab The string will also respect backspace and the Delete key to clear the string
Source code
Input ← ( ⊸˜∊Delete TypedCodes ⊂:Typed ⨬(⍥(⍜↻↘₂-₁⊸⊗@\0) ⧻⊚⊸=@\0 ⊂: ˜⊏"\0\n\t"▽⊸≠∞⬚∞˜⊗[Backspace Enter Tab] | ⋅⋅"") )
Key~Arrow function
Get an arrow key for a specific direction ^: Up, v: Down, <: Left, >: Right
Source code
Arrow ← get⊙(map "^v<>" Rayua~Key![Up Down Left Right])
Key~F function
Get a particular function key
Source code
F ← get⊙(map⍜¯⇡12 +290⇡12)
Key~WASD function
Returns array of direction constants for WASD keys pressed Takes a boolean to choose between keypress and keydown
Source code
WASD ← Impl⊙"wasd"
Key~ULDR function
Returns array of direction constants for arrow keys pressed Takes a boolean to choose between keypress and keydown
Source code
ULDR ← Impl⊙(Arrow "^<v>")
Mouse
Mouse module
Mouse~Pressed function
Check if a mouse button was pressed once
Source code
Pressed ← ≡₀Rayua~IsMouseButtonPressed
Mouse~Down function
Check if a mouse button is down
Source code
Down ← ≡₀Rayua~IsMouseButtonDown
Mouse~Pos function
The current position of the mouse
Source code
Pos ← (°T~Coords Rayua~GetMousePosition)
Mouse~Change function
How many pixels the mouse has moved since the last frame
Source code
Change ← (°T~Coords Rayua~GetMouseDelta)
Mouse~Hide function
Hide the mouse from the user
°Hide
will make the mouse reappear.
The user can still use the mouse while it it hidden. The affect is purely visual.
Source code
Hide ← ⌅(Rayua~HideCursor|Rayua~ShowCursor)
Mouse~Scroll function
The direction the mouse is scrolling
Returns 0
if the mouse has not scrolled, and 1
or ¯1
depending on the direction scrolled.
The sign may not nicely correspond to 'up' or 'down' since the direction of scrolling depends on the user's device.
Source code
Scroll ← (⊣Rayua~GetMouseWheelMoveV)
Mouse~Scroll! index macro
Call a function on the scroll direction when the wheel is scrolled
The function will be called on a value of either 1
or ¯1
, but never 0
Source code
Scroll! ← ⨬◌(^0) ⊸≠0 Scroll
Mouse~Drag‼ index macro
Call a function when the user drags the mouse
The first function is the mouse button that must be down while dragging. If it is monadic it will pull from the stack. The second function is called when a drag occurs and is supplied the distance dragged. If the mouse does not move, this will not trigger, thus the distance cannot be zero.
Source code
Drag‼ ← ⨬◌(^1) ×Down ⊙(⊸≠0 Change) ^0
Mouse~Pressed‼ index macro
Call a function on the mouse position when a button is pressed
The first function is the button to run the function on (or identity to take from the stack) The second function will be called with the mouse position as its first argument
Source code
Pressed‼ ← ⍥(^1 Pos)Pressed ^0
Mouse~Down‼ index macro
Call a function on the mouse position when a button is down
The first function is the button to run the function on (or identity to take from the stack) The second function will be called with the mouse position as its first argument
Source code
Down‼ ← ⍥(^1 Pos)Down ^0
Mouse~OnWindow function
Check if the mouse is on the window
Source code
OnWindow ← (Rayua~IsCursorOnScreen)
Mouse~OnScreen function
Source code
OnScreen ← (OnWindow)
Index macros
Loop‼ index macro
Source code
Loop‼ ← Rayua~CloseWindow ⍢( Rayua~EndDrawing ^1 Rayua~BeginDrawing| ׬Rayua~WindowShouldClose ^0)
Loop! index macro
Source code
Loop! ← Loop‼1^0
Noadic functions
Debug function
Sets the trace log to DEBUG
, printing extra information about what Raylib is doing
Source code
Debug ← Rayua~SetTraceLogLevel Rayua~TraceLogLevel~Debug
Dt function
Delta-time since last frame in seconds
Source code
Dt ← (Rayua~GetFrameTime)
Dyadic functions
Open function
Open a new window with a title
Source code
Open ← Rayua~InitWindow ⊓(°⊟ ⍥(↯2)≍[]⊸△ T~Coords|$"_") Rayua~SetTraceLogLevel Rayua~TraceLogLevel~Warning