simplify docs
This commit is contained in:
@@ -1,7 +1 @@
|
||||
Thank you for using Prosperon!
|
||||
|
||||
Provided are prosperon builds for all available platforms. Simply run prosperon for your platform in a game folder to play!
|
||||
|
||||
To get started, take a dive into the provided example games in the examples folder. You can either copy the prosperon executable into an example directory and run it there, or run `prosperon path/to/example` from the project root.
|
||||
|
||||
You can take a look through the docs folder for the prosperon manual to learn all about it. The manual is available on the web at [docs.prosperon.dev](https://docs.prosperon.dev).
|
||||
Read the docs to get started.
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# actor
|
||||
|
||||
### toString() <sub>function</sub>
|
||||
|
||||
### spawn(script, config, callback) <sub>function</sub>
|
||||
|
||||
### clear() <sub>function</sub>
|
||||
|
||||
### kill() <sub>function</sub>
|
||||
|
||||
### delay(fn, seconds) <sub>function</sub>
|
||||
@@ -1,37 +0,0 @@
|
||||
# console
|
||||
|
||||
The console object provides various logging, debugging, and output methods.
|
||||
|
||||
### print() <sub>function</sub>
|
||||
|
||||
### spam(msg) <sub>function</sub>
|
||||
|
||||
Output a spam-level message for very verbose logging.
|
||||
|
||||
### debug(msg) <sub>function</sub>
|
||||
|
||||
Output a debug-level message.
|
||||
|
||||
### info(msg) <sub>function</sub>
|
||||
|
||||
Output info level message.
|
||||
|
||||
### warn(msg) <sub>function</sub>
|
||||
|
||||
Output warn level message.
|
||||
|
||||
### log(msg) <sub>function</sub>
|
||||
|
||||
Output directly to in game console.
|
||||
|
||||
### error(e) <sub>function</sub>
|
||||
|
||||
Output error level message, and print stacktrace.
|
||||
|
||||
### panic(e) <sub>function</sub>
|
||||
|
||||
Output a panic-level message and exit the program.
|
||||
|
||||
### assert(op, str = `assertion failed [value '${op}']`) <sub>function</sub>
|
||||
|
||||
If the condition is false, print an error and panic.
|
||||
@@ -1,5 +0,0 @@
|
||||
# Appendix B - api
|
||||
|
||||
This is a complete list of accessible functions and parameters that are built into Prosperon. For the most part, developers will concern themselves with the modules, all of which can be imported with `use`.
|
||||
|
||||
Types document particular javascript objects with a specific object in their prototype chain, which can allow access to an underlying C data structure. A lot of these are used only internally by Prosperon, but brave developers can pick around in the module internals to see how they're used and do their own thing if they want!
|
||||
@@ -1,87 +0,0 @@
|
||||
# actor
|
||||
|
||||
|
||||
A set of utilities for iterating over a hierarchy of actor-like objects, as well
|
||||
as managing tag-based lookups. Objects are assumed to have a "objects" property,
|
||||
pointing to children or sub-objects, forming a tree.
|
||||
|
||||
|
||||
### all_objects(fn, startobj) <sub>function</sub>
|
||||
|
||||
|
||||
Iterate over each object (and its sub-objects) in the hierarchy, calling fn for each one.
|
||||
|
||||
|
||||
**fn**: A callback function that receives each object. If it returns a truthy value, iteration stops and that value is returned.
|
||||
|
||||
**startobj**: The root object at which iteration begins, default is the global "world".
|
||||
|
||||
|
||||
**Returns**: The first truthy value returned by fn, or undefined if none.
|
||||
|
||||
|
||||
### find_object(fn, startobj) <sub>function</sub>
|
||||
|
||||
|
||||
Intended to find a matching object within the hierarchy.
|
||||
|
||||
|
||||
**fn**: A callback or criteria to locate a particular object.
|
||||
|
||||
**startobj**: The root object at which search begins, default "world".
|
||||
|
||||
|
||||
**Returns**: Not yet implemented.
|
||||
|
||||
|
||||
### tag_add(tag, obj) <sub>function</sub>
|
||||
|
||||
|
||||
Associate the given object with the specified tag. Creates a new tag set if it does not exist.
|
||||
|
||||
|
||||
**tag**: A string tag to associate with the object.
|
||||
|
||||
**obj**: The object to add under this tag.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### tag_rm(tag, obj) <sub>function</sub>
|
||||
|
||||
|
||||
Remove the given object from the specified tag’s set, if it exists.
|
||||
|
||||
|
||||
**tag**: The tag to remove the object from.
|
||||
|
||||
**obj**: The object to remove from the tag set.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### tag_clear_guid(obj) <sub>function</sub>
|
||||
|
||||
|
||||
Remove the object from all tag sets.
|
||||
|
||||
|
||||
**obj**: The object whose tags should be cleared.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### objects_with_tag(tag) <sub>function</sub>
|
||||
|
||||
|
||||
Retrieve all objects currently tagged with the specified tag.
|
||||
|
||||
|
||||
**tag**: A string tag to look up.
|
||||
|
||||
|
||||
**Returns**: An array of objects associated with the given tag.
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
# camera
|
||||
|
||||
### list() <sub>function</sub>
|
||||
|
||||
Return an array of available camera device IDs.
|
||||
|
||||
|
||||
|
||||
**Returns**: An array of camera IDs, or undefined if no cameras are available.
|
||||
|
||||
|
||||
### open(id) <sub>function</sub>
|
||||
|
||||
Open a camera device with the given ID.
|
||||
|
||||
|
||||
|
||||
**id**: The camera ID to open.
|
||||
|
||||
|
||||
**Returns**: A camera object on success, or throws an error if the camera cannot be opened.
|
||||
|
||||
|
||||
### name(id) <sub>function</sub>
|
||||
|
||||
Return the name of the camera with the given ID.
|
||||
|
||||
|
||||
|
||||
**id**: The camera ID to query.
|
||||
|
||||
|
||||
**Returns**: A string with the camera's name, or throws an error if the name cannot be retrieved.
|
||||
|
||||
|
||||
### position(id) <sub>function</sub>
|
||||
|
||||
Return the physical position of the camera with the given ID.
|
||||
|
||||
|
||||
|
||||
**id**: The camera ID to query.
|
||||
|
||||
|
||||
**Returns**: A string indicating the camera position ("unknown", "front", or "back").
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
# cmd
|
||||
|
||||
### length <sub>number</sub>
|
||||
|
||||
### name <sub>string</sub>
|
||||
|
||||
### prototype <sub>object</sub>
|
||||
@@ -1,7 +0,0 @@
|
||||
# color
|
||||
|
||||
### Color <sub>object</sub>
|
||||
|
||||
### esc <sub>object</sub>
|
||||
|
||||
### ColorMap <sub>object</sub>
|
||||
@@ -1,76 +0,0 @@
|
||||
# debug
|
||||
|
||||
### stack_depth() <sub>function</sub>
|
||||
|
||||
Return the current stack depth.
|
||||
|
||||
|
||||
|
||||
**Returns**: A number representing the stack depth.
|
||||
|
||||
|
||||
### build_backtrace() <sub>function</sub>
|
||||
|
||||
Build and return a backtrace of the current call stack.
|
||||
|
||||
|
||||
|
||||
**Returns**: An object representing the call stack backtrace.
|
||||
|
||||
|
||||
### closure_vars(fn) <sub>function</sub>
|
||||
|
||||
Return the closure variables for a given function.
|
||||
|
||||
|
||||
|
||||
**fn**: The function object to inspect.
|
||||
|
||||
|
||||
**Returns**: An object containing the closure variables.
|
||||
|
||||
|
||||
### local_vars(depth) <sub>function</sub>
|
||||
|
||||
Return the local variables for a specific stack frame.
|
||||
|
||||
|
||||
|
||||
**depth**: The stack frame depth to inspect.
|
||||
|
||||
|
||||
**Returns**: An object containing the local variables at the specified depth.
|
||||
|
||||
|
||||
### fn_info(fn) <sub>function</sub>
|
||||
|
||||
Return metadata about a given function.
|
||||
|
||||
|
||||
|
||||
**fn**: The function object to inspect.
|
||||
|
||||
|
||||
**Returns**: An object with metadata about the function.
|
||||
|
||||
|
||||
### backtrace_fns() <sub>function</sub>
|
||||
|
||||
Return an array of functions in the current backtrace.
|
||||
|
||||
|
||||
|
||||
**Returns**: An array of function objects from the call stack.
|
||||
|
||||
|
||||
### dump_obj(obj) <sub>function</sub>
|
||||
|
||||
Return a string representation of a given object.
|
||||
|
||||
|
||||
|
||||
**obj**: The object to dump.
|
||||
|
||||
|
||||
**Returns**: A string describing the object's contents.
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
# dmon
|
||||
|
||||
### watch() <sub>function</sub>
|
||||
|
||||
Start watching the root directory, recursively.
|
||||
|
||||
This function begins monitoring the specified directory and its subdirectories recursively for events such as file creation, deletion, modification, or movement. Events are queued and can be retrieved by calling poll.
|
||||
|
||||
:throws: An error if dmon is already watching.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### unwatch() <sub>function</sub>
|
||||
|
||||
Stop watching the currently monitored directory.
|
||||
|
||||
This function halts filesystem monitoring for the directory previously set by watch. It clears the watch state, allowing a new watch to be started.
|
||||
|
||||
:throws: An error if no directory is currently being watched.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### poll(callback) <sub>function</sub>
|
||||
|
||||
Retrieve and process queued filesystem events.
|
||||
|
||||
This function dequeues all pending filesystem events and invokes the provided callback for each one. The callback receives an event object with properties: 'action' (string: "create", "delete", "modify", or "move"), 'root' (string: watched directory), 'file' (string: affected file path), and 'old' (string: previous file path for move events, empty if not applicable).
|
||||
|
||||
|
||||
|
||||
**callback**: A function to call for each event, receiving an event object as its argument.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
# doc
|
||||
|
||||
|
||||
Provides a consistent way to create documentation for prosperon elements. Objects are documented by adding docstrings directly to object-like things (functions, objects, ...), or to an object's own "doc object".
|
||||
|
||||
Docstrings are set to the symbol `cell.DOC`
|
||||
|
||||
```js
|
||||
// Suppose we have a module that returns a function
|
||||
function greet(name) { log.console("Hello, " + name) }
|
||||
|
||||
// We can attach a docstring
|
||||
greet.doc = `
|
||||
Greets the user by name.
|
||||
`
|
||||
|
||||
// A single function is a valid return!
|
||||
return greet
|
||||
```
|
||||
|
||||
```js
|
||||
// Another way is to add a docstring object to an object
|
||||
var greet = {
|
||||
hello() { log.console('hello!') }
|
||||
}
|
||||
|
||||
greet[cell.DOC] = {}
|
||||
greet[cell.DOC][cell.DOC] = 'An object full of different greeter functions'
|
||||
greet[cell.DOC].hello = 'A greeter that says, "hello!"'
|
||||
```
|
||||
|
||||
|
||||
**name**: The name of the person to greet.
|
||||
|
||||
|
||||
### writeDocFile(obj, title) <sub>function</sub>
|
||||
|
||||
Return a markdown string for a given obj, with an optional title.
|
||||
@@ -1,228 +0,0 @@
|
||||
# draw2d
|
||||
|
||||
|
||||
A collection of 2D drawing functions that operate in screen space. Provides primitives
|
||||
for lines, rectangles, text, sprite drawing, etc.
|
||||
|
||||
|
||||
### point(pos, size, color) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**pos**: A 2D position ([x, y]) where the point should be drawn.
|
||||
|
||||
**size**: The size of the point (not currently affecting rendering).
|
||||
|
||||
**color**: The color of the point, defaults to Color.blue.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### line(points, color, thickness, pipeline) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**points**: An array of 2D positions representing the line vertices.
|
||||
|
||||
**color**: The color of the line, default Color.white.
|
||||
|
||||
**thickness**: The line thickness, default 1.
|
||||
|
||||
**pipeline**: (Optional) A pipeline or rendering state object.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### cross(pos, size, color, thickness, pipe) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**pos**: The center of the cross as a 2D position ([x, y]).
|
||||
|
||||
**size**: Half the size of each cross arm.
|
||||
|
||||
**color**: The color of the cross, default Color.red.
|
||||
|
||||
**thickness**: The thickness of each line, default 1.
|
||||
|
||||
**pipe**: (Optional) A pipeline or rendering state object.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### arrow(start, end, color, wingspan, wingangle, pipe) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**start**: The start position of the arrow ([x, y]).
|
||||
|
||||
**end**: The end (tip) position of the arrow ([x, y]).
|
||||
|
||||
**color**: The color, default Color.red.
|
||||
|
||||
**wingspan**: The length of each arrowhead 'wing', default 4.
|
||||
|
||||
**wingangle**: Wing rotation in degrees, default 10.
|
||||
|
||||
**pipe**: (Optional) A pipeline or rendering state object.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### rectangle(rect, color, pipeline) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**rect**: A rectangle object with {x, y, width, height}.
|
||||
|
||||
**color**: The fill color, default Color.white.
|
||||
|
||||
**pipeline**: (Optional) A pipeline or rendering state object.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### tile(image, rect, color, tile, pipeline) <sub>function</sub>
|
||||
|
||||
|
||||
:raises Error: If no image is provided.
|
||||
|
||||
|
||||
**image**: An image object or string path to a texture.
|
||||
|
||||
**rect**: A rectangle specifying draw location/size ({x, y, width, height}).
|
||||
|
||||
**color**: The color tint, default Color.white.
|
||||
|
||||
**tile**: A tiling definition ({repeat_x, repeat_y}), default tile_def.
|
||||
|
||||
**pipeline**: (Optional) A pipeline or rendering state object.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### slice9(image, rect, slice, color, info, pipeline) <sub>function</sub>
|
||||
|
||||
|
||||
:raises Error: If no image is provided.
|
||||
|
||||
|
||||
**image**: An image object or string path to a texture.
|
||||
|
||||
**rect**: A rectangle specifying draw location/size, default [0, 0].
|
||||
|
||||
**slice**: The pixel inset or spacing for the 9-slice (number or object).
|
||||
|
||||
**color**: The color tint, default Color.white.
|
||||
|
||||
**info**: A slice9 info object controlling tiling of edges/corners.
|
||||
|
||||
**pipeline**: (Optional) A pipeline or rendering state object.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### image(image, rect, rotation, color, pipeline) <sub>function</sub>
|
||||
|
||||
|
||||
:raises Error: If no image is provided.
|
||||
|
||||
|
||||
**image**: An image object or string path to a texture.
|
||||
|
||||
**rect**: A rectangle specifying draw location/size, default [0,0]; width/height default to image size.
|
||||
|
||||
**rotation**: Rotation in degrees (not currently used).
|
||||
|
||||
**color**: The color tint, default none.
|
||||
|
||||
**pipeline**: (Optional) A pipeline or rendering state object.
|
||||
|
||||
|
||||
**Returns**: A sprite object that was created for this draw call.
|
||||
|
||||
|
||||
### images(image, rects, config) <sub>function</sub>
|
||||
|
||||
|
||||
:raises Error: If no image is provided.
|
||||
|
||||
|
||||
**image**: An image object or string path to a texture.
|
||||
|
||||
**rects**: An array of rectangle objects ({x, y, width, height}) to draw.
|
||||
|
||||
**config**: (Unused) Additional config data if needed.
|
||||
|
||||
|
||||
**Returns**: An array of sprite objects created and queued for rendering.
|
||||
|
||||
|
||||
### sprites(sprites, sort, pipeline) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**sprites**: An array of sprite objects to draw.
|
||||
|
||||
**sort**: Sorting mode or order, default 0.
|
||||
|
||||
**pipeline**: (Optional) A pipeline or rendering state object.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### circle(pos, radius, color, inner_radius, pipeline) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**pos**: Center of the circle ([x, y]).
|
||||
|
||||
**radius**: The circle radius.
|
||||
|
||||
**color**: The fill color of the circle, default none.
|
||||
|
||||
**inner_radius**: (Unused) Possibly ring thickness, default 1.
|
||||
|
||||
**pipeline**: (Optional) A pipeline or rendering state object.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### text(text, rect, font, size, color, wrap, pipeline) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**text**: The string to draw.
|
||||
|
||||
**rect**: A rectangle specifying draw position (and possibly wrapping area).
|
||||
|
||||
**font**: A font object or string path, default sysfont.
|
||||
|
||||
**size**: (Unused) Possibly intended for scaling the font size.
|
||||
|
||||
**color**: The text color, default Color.white.
|
||||
|
||||
**wrap**: Pixel width for text wrapping, default 0 (no wrap).
|
||||
|
||||
**pipeline**: (Optional) A pipeline or rendering state object.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
# enet
|
||||
|
||||
### initialize() <sub>function</sub>
|
||||
|
||||
|
||||
Initialize the ENet library. Must be called before using any ENet functionality.
|
||||
Throws an error if initialization fails.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### deinitialize() <sub>function</sub>
|
||||
|
||||
|
||||
Deinitialize the ENet library, cleaning up all resources. Call this when you no longer
|
||||
need any ENet functionality.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### create_host(address) <sub>function</sub>
|
||||
|
||||
|
||||
Create an ENet host for either a client-like unbound host or a server bound to a specific
|
||||
address and port:
|
||||
|
||||
- If no argument is provided, creates an unbound "client-like" host with default settings
|
||||
(maximum 32 peers, 2 channels, unlimited bandwidth).
|
||||
- If you pass an "ip:port" string (e.g. "127.0.0.1:7777"), it creates a server bound to
|
||||
that address. The server supports up to 32 peers, 2 channels, and unlimited bandwidth.
|
||||
|
||||
Throws an error if host creation fails for any reason.
|
||||
|
||||
omit to create an unbound client-like host.
|
||||
|
||||
|
||||
**address**: (optional) A string in 'ip:port' format to bind the host (server), or
|
||||
|
||||
|
||||
**Returns**: An ENetHost object.
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
# event
|
||||
|
||||
### push_event(event) <sub>function</sub>
|
||||
|
||||
Push a custom user event into SDL's queue, passing a callback function.
|
||||
|
||||
|
||||
|
||||
**event**: A function to call when this event is consumed.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### engine_input(callback) <sub>function</sub>
|
||||
|
||||
Poll all system events (keyboard, mouse, etc.) and call the given function with each event object.
|
||||
|
||||
|
||||
|
||||
**callback**: A function that executes on each event consumed from the poll.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
@@ -1,221 +0,0 @@
|
||||
# geometry
|
||||
|
||||
|
||||
A collection of geometry-related functions for circles, spheres, boxes, polygons,
|
||||
and rectangle utilities. Some functionality is implemented in C and exposed here.
|
||||
|
||||
|
||||
### rect_intersection(a, b) <sub>function</sub>
|
||||
|
||||
|
||||
Return the intersection of two rectangles. The result may be empty if no intersection.
|
||||
|
||||
|
||||
**a**: The first rectangle as {x, y, w, h}.
|
||||
|
||||
**b**: The second rectangle as {x, y, w, h}.
|
||||
|
||||
|
||||
**Returns**: A rectangle that is the intersection of the two. May have zero width/height if no overlap.
|
||||
|
||||
|
||||
### rect_intersects(a, b) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**a**: Rectangle {x,y,w,h}.
|
||||
|
||||
**b**: Rectangle {x,y,w,h}.
|
||||
|
||||
|
||||
**Returns**: A boolean indicating whether the two rectangles overlap.
|
||||
|
||||
|
||||
### rect_expand(a, b) <sub>function</sub>
|
||||
|
||||
|
||||
Merge or combine two rectangles, returning their bounding rectangle.
|
||||
|
||||
|
||||
**a**: Rectangle {x,y,w,h}.
|
||||
|
||||
**b**: Rectangle {x,y,w,h}.
|
||||
|
||||
|
||||
**Returns**: A new rectangle that covers the bounds of both input rectangles.
|
||||
|
||||
|
||||
### rect_inside(inner, outer) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**inner**: A rectangle to test.
|
||||
|
||||
**outer**: A rectangle that may contain 'inner'.
|
||||
|
||||
|
||||
**Returns**: True if 'inner' is completely inside 'outer', otherwise false.
|
||||
|
||||
|
||||
### rect_random(rect) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**rect**: A rectangle {x,y,w,h}.
|
||||
|
||||
|
||||
**Returns**: A random point within the rectangle (uniform distribution).
|
||||
|
||||
|
||||
### cwh2rect(center, wh) <sub>function</sub>
|
||||
|
||||
|
||||
Helper: convert a center point and width/height vector to a rect object.
|
||||
|
||||
|
||||
**center**: A 2D point [cx, cy].
|
||||
|
||||
**wh**: A 2D size [width, height].
|
||||
|
||||
|
||||
**Returns**: A rectangle {x, y, w, h} with x,y set to center and w,h set to the given size.
|
||||
|
||||
|
||||
### rect_point_inside(rect, point) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**rect**: A rectangle {x,y,w,h}.
|
||||
|
||||
**point**: A 2D point [px, py].
|
||||
|
||||
|
||||
**Returns**: True if the point lies inside the rectangle, otherwise false.
|
||||
|
||||
|
||||
### rect_pos(rect) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**rect**: A rectangle {x,y,w,h}.
|
||||
|
||||
|
||||
**Returns**: A 2D vector [x,y] giving the rectangle's position.
|
||||
|
||||
|
||||
### rect_move(rect, offset) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**rect**: A rectangle {x,y,w,h}.
|
||||
|
||||
**offset**: A 2D vector to add to the rectangle's position.
|
||||
|
||||
|
||||
**Returns**: A new rectangle with updated x,y offset.
|
||||
|
||||
|
||||
### box(w, h) <sub>function</sub>
|
||||
|
||||
|
||||
Construct a box centered at the origin with the given width and height. This overrides the box object above.
|
||||
|
||||
|
||||
**w**: The width of the box.
|
||||
|
||||
**h**: The height of the box.
|
||||
|
||||
|
||||
**Returns**: An array of four 2D points representing the corners of a rectangle centered at [0,0].
|
||||
|
||||
|
||||
### sphere <sub>object</sub>
|
||||
|
||||
|
||||
Sphere-related geometry functions:
|
||||
- volume(r): Return the volume of a sphere with radius r.
|
||||
- random(r, theta, phi): Return a random point on or inside a sphere.
|
||||
|
||||
|
||||
### circle <sub>object</sub>
|
||||
|
||||
|
||||
Circle-related geometry functions:
|
||||
- area(r): Return the area of a circle with radius r.
|
||||
- random(r, theta): Return a random 2D point on a circle; uses sphere.random internally and extracts x,z.
|
||||
|
||||
|
||||
### ngon(radius, n) <sub>function</sub>
|
||||
|
||||
|
||||
Generates a regular n-gon by calling geometry.arc with full 360 degrees.
|
||||
|
||||
|
||||
**radius**: The radius of the n-gon from center to each vertex.
|
||||
|
||||
**n**: Number of sides/vertices.
|
||||
|
||||
|
||||
**Returns**: An array of 2D points forming a regular n-gon.
|
||||
|
||||
|
||||
### arc(radius, angle, n, start) <sub>function</sub>
|
||||
|
||||
|
||||
Generate an arc (or partial circle) of n points, each angle spread equally over 'angle' degrees from 'start'.
|
||||
|
||||
|
||||
**radius**: The distance from center to the arc points.
|
||||
|
||||
**angle**: The total angle (in degrees) over which points are generated, capped at 360.
|
||||
|
||||
**n**: Number of segments (if <=1, empty array is returned).
|
||||
|
||||
**start**: Starting angle (in degrees), default 0.
|
||||
|
||||
|
||||
**Returns**: An array of 2D points along the arc.
|
||||
|
||||
|
||||
### corners2points(ll, ur) <sub>function</sub>
|
||||
|
||||
|
||||
Similar to box.points, but calculates differently.
|
||||
|
||||
|
||||
**ll**: Lower-left 2D coordinate.
|
||||
|
||||
**ur**: Upper-right 2D coordinate (relative offset in x,y).
|
||||
|
||||
|
||||
**Returns**: A four-point array of corners [ll, lower-right, upper-right, upper-left].
|
||||
|
||||
|
||||
### sortpointsccw(points) <sub>function</sub>
|
||||
|
||||
|
||||
Sort an array of points in CCW order based on their angles from the centroid.
|
||||
|
||||
|
||||
**points**: An array of 2D points.
|
||||
|
||||
|
||||
**Returns**: A new array of the same points, sorted counterclockwise around their centroid.
|
||||
|
||||
|
||||
### points2cm(points) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**points**: An array of 2D points.
|
||||
|
||||
|
||||
**Returns**: The centroid (average x,y) of the given points.
|
||||
|
||||
@@ -1,278 +0,0 @@
|
||||
# graphics
|
||||
|
||||
|
||||
Provides functionality for loading and managing images, fonts, textures, and sprite meshes.
|
||||
Includes both JavaScript and C-implemented routines for creating geometry buffers, performing
|
||||
rectangle packing, etc.
|
||||
|
||||
|
||||
### make_sprite_mesh(sprites) <sub>function</sub>
|
||||
|
||||
|
||||
:param oldMesh (optional): An existing mesh object to reuse/resize if possible.
|
||||
Given an array of sprites, build a single geometry mesh for rendering them.
|
||||
|
||||
|
||||
**sprites**: An array of sprite objects, each containing .rect (or transform), .src (UV region), .color, etc.
|
||||
|
||||
|
||||
**Returns**: A GPU mesh object with pos, uv, color, and indices buffers for all sprites.
|
||||
|
||||
|
||||
### make_sprite_queue(sprites, camera, pipeline, sort) <sub>function</sub>
|
||||
|
||||
|
||||
Given an array of sprites, optionally sort them, then build a queue of pipeline commands.
|
||||
Each group with a shared image becomes one command.
|
||||
|
||||
|
||||
**sprites**: An array of sprite objects.
|
||||
|
||||
**camera**: (unused in the C code example) Typically a camera or transform for sorting?
|
||||
|
||||
**pipeline**: A pipeline object for rendering.
|
||||
|
||||
**sort**: An integer or boolean for whether to sort sprites; if truthy, sorts by layer & texture.
|
||||
|
||||
|
||||
**Returns**: An array of pipeline commands: geometry with mesh references, grouped by image.
|
||||
|
||||
|
||||
### make_text_buffer(text, rect, angle, color, wrap, font) <sub>function</sub>
|
||||
|
||||
|
||||
Generate a GPU buffer mesh of text quads for rendering with a font, etc.
|
||||
|
||||
|
||||
**text**: The string to render.
|
||||
|
||||
**rect**: A rectangle specifying position and possibly wrapping.
|
||||
|
||||
**angle**: Rotation angle (unused or optional).
|
||||
|
||||
**color**: A color for the text (could be a vec4).
|
||||
|
||||
**wrap**: The width in pixels to wrap text, or 0 for no wrap.
|
||||
|
||||
**font**: A font object created by graphics.make_font or graphics.get_font.
|
||||
|
||||
|
||||
**Returns**: A geometry buffer mesh (pos, uv, color, indices) for rendering text.
|
||||
|
||||
|
||||
### rectpack(width, height, sizes) <sub>function</sub>
|
||||
|
||||
|
||||
Perform a rectangle packing using the stbrp library. Return positions for each rect.
|
||||
|
||||
|
||||
**width**: The width of the area to pack into.
|
||||
|
||||
**height**: The height of the area to pack into.
|
||||
|
||||
**sizes**: An array of [w,h] pairs for the rectangles to pack.
|
||||
|
||||
|
||||
**Returns**: An array of [x,y] coordinates placing each rect, or null if they don't fit.
|
||||
|
||||
|
||||
### make_rtree() <sub>function</sub>
|
||||
|
||||
|
||||
Create a new R-Tree for geometry queries.
|
||||
|
||||
|
||||
**Returns**: An R-Tree object for quickly querying many rectangles or sprite bounds.
|
||||
|
||||
|
||||
### make_texture(data) <sub>function</sub>
|
||||
|
||||
|
||||
Convert raw image bytes into an SDL_Surface object.
|
||||
|
||||
|
||||
**data**: Raw image bytes (PNG, JPG, etc.) as an ArrayBuffer.
|
||||
|
||||
|
||||
**Returns**: An SDL_Surface object representing the decoded image in RAM, for use with GPU or software rendering.
|
||||
|
||||
|
||||
### make_gif(data) <sub>function</sub>
|
||||
|
||||
|
||||
Load a GIF, returning its frames. If it's a single-frame GIF, the result may have .surface only.
|
||||
|
||||
|
||||
**data**: An ArrayBuffer containing GIF data.
|
||||
|
||||
|
||||
**Returns**: An object with frames[], each frame having its own .surface. Some also have a .texture for GPU use.
|
||||
|
||||
|
||||
### make_aseprite(data) <sub>function</sub>
|
||||
|
||||
|
||||
Load an Aseprite/ASE file from an array of bytes, returning frames or animations.
|
||||
|
||||
|
||||
**data**: An ArrayBuffer containing Aseprite (ASE) file data.
|
||||
|
||||
|
||||
**Returns**: An object containing frames or animations, each with .surface. May also have top-level .surface for a single-layer case.
|
||||
|
||||
|
||||
### cull_sprites(sprites, camera) <sub>function</sub>
|
||||
|
||||
|
||||
Filter an array of sprites to only those visible in the provided camera’s view.
|
||||
|
||||
|
||||
**sprites**: An array of sprite objects (each has rect or transform).
|
||||
|
||||
**camera**: A camera or bounding rectangle defining the view area.
|
||||
|
||||
|
||||
**Returns**: A new array of sprites that are visible in the camera's view.
|
||||
|
||||
|
||||
### rects_to_sprites(rects, image) <sub>function</sub>
|
||||
|
||||
|
||||
Convert an array of rect coords into sprite objects referencing a single image.
|
||||
|
||||
|
||||
**rects**: An array of rect coords or objects.
|
||||
|
||||
**image**: An image object (with .texture).
|
||||
|
||||
|
||||
**Returns**: An array of sprite objects referencing the 'image' and each rect for UV or position.
|
||||
|
||||
|
||||
### make_surface(dimensions) <sub>function</sub>
|
||||
|
||||
|
||||
Create a blank surface in RAM.
|
||||
|
||||
|
||||
**dimensions**: The size object {width, height}, or an array [w,h].
|
||||
|
||||
|
||||
**Returns**: A blank RGBA surface with the given dimensions, typically for software rendering or icons.
|
||||
|
||||
|
||||
### make_cursor(opts) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**opts**: An object with {surface, hotx, hoty} or similar.
|
||||
|
||||
|
||||
**Returns**: An SDL_Cursor object referencing the given surface for a custom mouse cursor.
|
||||
|
||||
|
||||
### make_font(data, size) <sub>function</sub>
|
||||
|
||||
|
||||
Load a font from TTF/OTF data at the given size.
|
||||
|
||||
|
||||
**data**: TTF/OTF file data as an ArrayBuffer.
|
||||
|
||||
**size**: Pixel size for rendering glyphs.
|
||||
|
||||
|
||||
**Returns**: A font object with surface, texture, and glyph data, for text rendering with make_text_buffer.
|
||||
|
||||
|
||||
### make_sprite() <sub>function</sub>
|
||||
|
||||
|
||||
Create a new sprite object, storing default properties.
|
||||
|
||||
|
||||
**Returns**: A new sprite object, which typically has .rect, .color, .layer, .image, etc.
|
||||
|
||||
|
||||
### make_line_prim(points, thickness, startCap, endCap, color) <sub>function</sub>
|
||||
|
||||
|
||||
Build a GPU mesh representing a thick polyline from an array of points, using parsl or a similar library under the hood.
|
||||
|
||||
|
||||
**points**: An array of [x,y] points forming the line.
|
||||
|
||||
**thickness**: The thickness (width) of the polyline.
|
||||
|
||||
**startCap**: (Unused) Possibly the type of cap for the start.
|
||||
|
||||
**endCap**: (Unused) Possibly the type of cap for the end.
|
||||
|
||||
**color**: A color to apply to the line.
|
||||
|
||||
|
||||
**Returns**: A geometry mesh object suitable for rendering the line via a pipeline command.
|
||||
|
||||
|
||||
### is_image(obj) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
|
||||
**obj**: An object to check.
|
||||
|
||||
|
||||
**Returns**: True if 'obj' has a .texture and a .rect property, indicating it's an image object.
|
||||
|
||||
|
||||
### texture(path) <sub>function</sub>
|
||||
|
||||
|
||||
Load or retrieve a cached image, converting it into a GPU texture. If 'path' is already an object, it’s returned directly.
|
||||
|
||||
|
||||
**path**: A string path to an image file or an already-loaded image object.
|
||||
|
||||
|
||||
**Returns**: An image object with {surface, texture, frames?, etc.} depending on the format.
|
||||
|
||||
|
||||
### tex_hotreload(file) <sub>function</sub>
|
||||
|
||||
|
||||
Reload the image for the given file, updating the cached copy in memory and GPU.
|
||||
|
||||
|
||||
**file**: The file path that was changed on disk.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### get_font(path, size) <sub>function</sub>
|
||||
|
||||
|
||||
Load a font from file if not cached, or retrieve from cache if already loaded.
|
||||
|
||||
|
||||
**path**: A string path to a font file, optionally with ".size" appended.
|
||||
|
||||
**size**: Pixel size of the font, if not included in 'path'.
|
||||
|
||||
|
||||
**Returns**: A font object with .surface and .texture for rendering text.
|
||||
|
||||
|
||||
### queue_sprite_mesh(queue) <sub>function</sub>
|
||||
|
||||
|
||||
Builds a single geometry mesh for all sprite-type commands in the queue, storing first_index/num_indices
|
||||
so they can be rendered in one draw call.
|
||||
|
||||
|
||||
**queue**: An array of draw commands, some of which are {type:'sprite'} objects.
|
||||
|
||||
|
||||
**Returns**: An array of references to GPU buffers [pos,uv,color,indices].
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,68 +0,0 @@
|
||||
# input
|
||||
|
||||
### mouse_show(show) <sub>function</sub>
|
||||
|
||||
Show or hide the mouse cursor. Pass true to show, false to hide.
|
||||
|
||||
|
||||
|
||||
**show**: Boolean. True to show, false to hide.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### mouse_lock(lock) <sub>function</sub>
|
||||
|
||||
Capture or release the mouse, confining it within the window if locked.
|
||||
|
||||
|
||||
|
||||
**lock**: Boolean. True to lock, false to unlock.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### cursor_set(cursor) <sub>function</sub>
|
||||
|
||||
Set the given cursor (created by os.make_cursor) as the active mouse cursor.
|
||||
|
||||
|
||||
|
||||
**cursor**: The cursor to set.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### keyname(keycode) <sub>function</sub>
|
||||
|
||||
Given a numeric keycode, return the corresponding key name (e.g., from SDL).
|
||||
|
||||
|
||||
|
||||
**keycode**: A numeric SDL keycode.
|
||||
|
||||
|
||||
**Returns**: A string with the key name.
|
||||
|
||||
|
||||
### keymod() <sub>function</sub>
|
||||
|
||||
Return an object describing the current modifier keys, e.g. {shift:true, ctrl:true}.
|
||||
|
||||
|
||||
|
||||
**Returns**: An object with boolean fields for each modifier key.
|
||||
|
||||
|
||||
### mousestate() <sub>function</sub>
|
||||
|
||||
Return an object describing the current mouse state, including x,y coordinates
|
||||
and booleans for pressed buttons (left, middle, right, x1, x2).
|
||||
|
||||
|
||||
|
||||
**Returns**: Object { x, y, left, middle, right, x1, x2 }
|
||||
|
||||
@@ -1,243 +0,0 @@
|
||||
# io
|
||||
|
||||
### rm(path) <sub>function</sub>
|
||||
|
||||
Remove the file or empty directory at the given path.
|
||||
|
||||
|
||||
|
||||
**path**: The file or empty directory to remove. Must be empty if a directory.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### mkdir(path) <sub>function</sub>
|
||||
|
||||
Create a directory at the given path.
|
||||
|
||||
|
||||
|
||||
**path**: The directory path to create.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### stat(path) <sub>function</sub>
|
||||
|
||||
Return an object describing file metadata for the given path. The object includes
|
||||
filesize, modtime, createtime, and accesstime. Throw an error if the path does not exist.
|
||||
|
||||
|
||||
|
||||
**path**: The file or directory to retrieve metadata for.
|
||||
|
||||
|
||||
**Returns**: An object with metadata (filesize, modtime, createtime, accesstime).
|
||||
|
||||
|
||||
### globfs(patterns) <sub>function</sub>
|
||||
|
||||
Return an array of files that do not match any of the provided glob patterns. It
|
||||
recursively enumerates the filesystem within PHYSFS. Each pattern is treated as an
|
||||
"ignore" rule, similar to .gitignore usage.
|
||||
|
||||
|
||||
|
||||
**patterns**: An array of glob patterns to ignore. Any file matching one of these is skipped.
|
||||
|
||||
|
||||
**Returns**: An array of matching file paths.
|
||||
|
||||
|
||||
### match(pattern, string) <sub>function</sub>
|
||||
|
||||
Return boolean indicating whether the given wildcard pattern matches the provided
|
||||
string. Dots must match dots. Case is not ignored.
|
||||
|
||||
Patterns can incorporate:
|
||||
'?' - Matches exactly one character (except leading dots or slashes).
|
||||
'*' - Matches zero or more characters (excluding path separators).
|
||||
'**' - Matches zero or more characters, including path separators.
|
||||
'[abc]' - A bracket expression; matches any single character from the set. Ranges like [a-z], [0-9] also work.
|
||||
'[[:alpha:]]' - POSIX character classes can be used inside brackets.
|
||||
'\' - Backslash escapes the next character.
|
||||
'!' - If placed immediately inside brackets (like [!abc]), it negates the set.
|
||||
|
||||
|
||||
|
||||
**pattern**: The wildcard pattern to compare.
|
||||
|
||||
**string**: The string to test against the wildcard pattern.
|
||||
|
||||
|
||||
**Returns**: True if matched, otherwise false.
|
||||
|
||||
|
||||
### exists(path) <sub>function</sub>
|
||||
|
||||
Return a boolean indicating whether the file or directory at the given path exists.
|
||||
|
||||
|
||||
|
||||
**path**: The file or directory path to check.
|
||||
|
||||
|
||||
**Returns**: True if the path exists, otherwise false.
|
||||
|
||||
|
||||
### mount(archiveOrDir, mountPoint) <sub>function</sub>
|
||||
|
||||
Mount a directory or archive at the specified mount point. An undefined mount
|
||||
point mounts to '/'. Throw on error.
|
||||
|
||||
|
||||
|
||||
**archiveOrDir**: The directory or archive to mount.
|
||||
|
||||
**mountPoint**: The path at which to mount. If omitted or undefined, '/' is used.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### unmount(path) <sub>function</sub>
|
||||
|
||||
Unmount a previously mounted directory or archive. Throw on error.
|
||||
|
||||
|
||||
|
||||
**path**: The directory or archive mount point to unmount.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### slurp(path) <sub>function</sub>
|
||||
|
||||
Read the entire file at the given path as a string. Throw on error.
|
||||
|
||||
|
||||
|
||||
**path**: The file path to read from.
|
||||
|
||||
|
||||
**Returns**: A string with the file’s contents.
|
||||
|
||||
|
||||
### slurpbytes(path) <sub>function</sub>
|
||||
|
||||
Read the entire file at the given path as a raw ArrayBuffer. Throw on error.
|
||||
|
||||
|
||||
|
||||
**path**: The file path to read from.
|
||||
|
||||
|
||||
**Returns**: An ArrayBuffer containing the file’s raw bytes.
|
||||
|
||||
|
||||
### slurpwrite(data, path) <sub>function</sub>
|
||||
|
||||
Write data (string or ArrayBuffer) to the given file path. Overwrite if it exists.
|
||||
Throw on error.
|
||||
|
||||
|
||||
|
||||
**data**: The data to write (string or ArrayBuffer).
|
||||
|
||||
**path**: The file path to write to.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### writepath(path) <sub>function</sub>
|
||||
|
||||
Set the write directory. Subsequent writes will go here by default. Throw on error.
|
||||
|
||||
|
||||
|
||||
**path**: The directory path to set as writable.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### basedir() <sub>function</sub>
|
||||
|
||||
Return the application's base directory (where the executable is located).
|
||||
|
||||
|
||||
|
||||
**Returns**: A string with the base directory path.
|
||||
|
||||
|
||||
### prefdir(org, app) <sub>function</sub>
|
||||
|
||||
Get the user-and-app-specific path where files can be written.
|
||||
|
||||
|
||||
|
||||
**org**: The name of your organization.
|
||||
|
||||
**app**: The name of your application.
|
||||
|
||||
|
||||
**Returns**: A string with the user's directory path.
|
||||
|
||||
|
||||
### realdir(path) <sub>function</sub>
|
||||
|
||||
Return the actual, real directory (on the host filesystem) that contains the given
|
||||
file path. Return undefined if not found.
|
||||
|
||||
|
||||
|
||||
**path**: The file path whose real directory is requested.
|
||||
|
||||
|
||||
**Returns**: A string with the real directory path, or undefined.
|
||||
|
||||
|
||||
### open(path) <sub>function</sub>
|
||||
|
||||
Open a file for writing, returning a file object that can be used for further
|
||||
operations. Throw on error.
|
||||
|
||||
|
||||
|
||||
**path**: The file path to open for writing.
|
||||
|
||||
|
||||
**Returns**: A file object for subsequent write operations.
|
||||
|
||||
|
||||
### searchpath() <sub>function</sub>
|
||||
|
||||
Return an array of all directories in the current paths.
|
||||
|
||||
|
||||
|
||||
**Returns**: An array of directory paths in the search path.
|
||||
|
||||
|
||||
### enumerate(path, recurse) <sub>function</sub>
|
||||
|
||||
Return an array of files within the given directory, optionally recursing into
|
||||
subdirectories.
|
||||
|
||||
|
||||
|
||||
**path**: The directory to list.
|
||||
|
||||
**recurse**: Whether to recursively include subdirectories (true or false).
|
||||
|
||||
|
||||
**Returns**: An array of file (and directory) paths found.
|
||||
|
||||
|
||||
### mount_core() <sub>function</sub>
|
||||
|
||||
### is_directory() <sub>function</sub>
|
||||
@@ -1,175 +0,0 @@
|
||||
# js
|
||||
|
||||
|
||||
Provides functions for introspecting and configuring the QuickJS runtime engine.
|
||||
Includes debug info, memory usage, GC controls, code evaluation, etc.
|
||||
|
||||
|
||||
### cycle_hook(callback) <sub>function</sub>
|
||||
|
||||
|
||||
or undefined to remove the callback.
|
||||
|
||||
Register or remove a hook function that QuickJS calls once per execution cycle. If the callback
|
||||
is set, it receives a single argument (an optional object/value describing the cycle). If callback
|
||||
is undefined, the hook is removed.
|
||||
|
||||
|
||||
**callback**: A function to call each time QuickJS completes a "cycle" (internal VM loop),
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### dump_shapes() <sub>function</sub>
|
||||
|
||||
|
||||
Use this for internal debugging of object shapes.
|
||||
|
||||
|
||||
**Returns**: A debug string describing the internal shape hierarchy used by QuickJS.
|
||||
|
||||
|
||||
### dump_atoms() <sub>function</sub>
|
||||
|
||||
|
||||
known by QuickJS. Helpful for diagnosing memory usage or potential key collisions.
|
||||
|
||||
|
||||
**Returns**: A debug string listing all currently registered atoms (internal property keys/symbols)
|
||||
|
||||
|
||||
### dump_class() <sub>function</sub>
|
||||
|
||||
|
||||
Shows how many objects of each class exist, useful for advanced memory or performance profiling.
|
||||
|
||||
|
||||
**Returns**: A debug string describing the distribution of JS object classes in the QuickJS runtime.
|
||||
|
||||
|
||||
### dump_objects() <sub>function</sub>
|
||||
|
||||
|
||||
useful for debugging memory leaks or object lifetimes.
|
||||
|
||||
|
||||
**Returns**: A debug string listing certain internal QuickJS objects and their references,
|
||||
|
||||
|
||||
### dump_type_overheads() <sub>function</sub>
|
||||
|
||||
|
||||
Displays memory usage breakdown for different internal object types.
|
||||
|
||||
|
||||
**Returns**: A debug string describing the overheads for various JS object types in QuickJS.
|
||||
|
||||
|
||||
### stack_info() <sub>function</sub>
|
||||
|
||||
|
||||
Internal debugging utility to examine call stack details.
|
||||
|
||||
|
||||
**Returns**: An object or string describing the runtime's current stack usage and capacity.
|
||||
|
||||
|
||||
### calc_mem(value) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
Compute the approximate size of a single JS value in memory. This is a best-effort estimate.
|
||||
|
||||
|
||||
**value**: A JavaScript value to analyze.
|
||||
|
||||
|
||||
**Returns**: Approximate memory usage (in bytes) of that single value.
|
||||
|
||||
|
||||
### mem() <sub>function</sub>
|
||||
|
||||
|
||||
including total allocated bytes, object counts, and more.
|
||||
|
||||
Retrieve an overview of the runtime’s memory usage.
|
||||
|
||||
|
||||
**Returns**: An object containing a comprehensive snapshot of memory usage for the current QuickJS runtime,
|
||||
|
||||
|
||||
### mem_limit(bytes) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
Set the upper memory limit for the QuickJS runtime. Exceeding this limit may cause operations to
|
||||
fail or throw errors.
|
||||
|
||||
|
||||
**bytes**: The maximum memory (in bytes) QuickJS is allowed to use.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### gc_threshold(bytes) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
Set the threshold (in bytes) for QuickJS to perform an automatic GC pass when memory usage surpasses it.
|
||||
|
||||
|
||||
**bytes**: The threshold (in bytes) at which the engine triggers automatic garbage collection.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### max_stacksize(bytes) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
Set the maximum stack size for QuickJS. If exceeded, the runtime may throw a stack overflow error.
|
||||
|
||||
|
||||
**bytes**: The maximum allowed stack size (in bytes) for QuickJS.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### memstate() <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
Gives a quick overview of the memory usage, including malloc size and other allocations.
|
||||
|
||||
|
||||
**Returns**: A simpler memory usage object (malloc sizes, etc.) for the QuickJS runtime.
|
||||
|
||||
|
||||
### gc() <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
Force an immediate, full garbage collection pass, reclaiming unreachable memory.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### eval(src, filename) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
Execute a string of JavaScript code in the current QuickJS context.
|
||||
|
||||
|
||||
**src**: A string of JavaScript source code to evaluate.
|
||||
|
||||
**filename**: (Optional) A string for the filename or label, used in debugging or stack traces.
|
||||
|
||||
|
||||
**Returns**: The result of evaluating the given source code.
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
# json
|
||||
|
||||
### encode(val,space,replacer,whitelist) <sub>function</sub>
|
||||
|
||||
Produce a JSON text from a Javascript object. If a record value, at any level, contains a json() method, it will be called, and the value it returns (usually a simpler record) will be JSONified.
|
||||
|
||||
If the record does not have a json() method, and if whitelist is a record, then only the keys that are associated with true in the whitelist are included.
|
||||
|
||||
If the space input is true, then line breaks and extra whitespace will be included in the text.
|
||||
|
||||
### decode(text,reviver) <sub>function</sub>
|
||||
|
||||
The text text is parsed, and the resulting value (usually a record or an array) is returned.
|
||||
|
||||
The optional reviver input is a method that will be called for every key and value at every level of the result. Each value will be replaced by the result of the reviver function. This can be used to reform data-only records into method-bearing records, or to transform date strings into seconds.
|
||||
@@ -1,3 +0,0 @@
|
||||
# loop
|
||||
|
||||
### step() <sub>function</sub>
|
||||
@@ -1,115 +0,0 @@
|
||||
# math
|
||||
|
||||
### dot() <sub>function</sub>
|
||||
|
||||
Compute the dot product between two numeric arrays, returning a scalar. Extra elements are ignored.
|
||||
|
||||
### project() <sub>function</sub>
|
||||
|
||||
Project one vector onto another, returning a new array of the same dimension.
|
||||
|
||||
### rotate() <sub>function</sub>
|
||||
|
||||
Rotate a 2D point (or array of length 2) by the given angle (in turns) around an optional pivot.
|
||||
|
||||
### midpoint() <sub>function</sub>
|
||||
|
||||
Compute the midpoint of two arrays of numbers. Only the first two entries are used if 2D is intended.
|
||||
|
||||
### reflect() <sub>function</sub>
|
||||
|
||||
Reflect a vector across a plane normal. Both arguments must be numeric arrays.
|
||||
|
||||
### distance() <sub>function</sub>
|
||||
|
||||
Compute the Euclidean distance between two numeric arrays of matching length.
|
||||
|
||||
### direction() <sub>function</sub>
|
||||
|
||||
Compute the normalized direction vector from the first array to the second.
|
||||
|
||||
### angle() <sub>function</sub>
|
||||
|
||||
Given a 2D vector, return its angle from the X-axis in radians or some chosen units.
|
||||
|
||||
### norm() <sub>function</sub>
|
||||
|
||||
Return a normalized copy of the given numeric array. For 2D/3D/4D or arbitrary length.
|
||||
|
||||
### angle_between() <sub>function</sub>
|
||||
|
||||
Compute the angle between two vectors (2D/3D/4D).
|
||||
|
||||
### lerp() <sub>function</sub>
|
||||
|
||||
Linear interpolation between two numbers: lerp(a, b, t).
|
||||
|
||||
### gcd() <sub>function</sub>
|
||||
|
||||
Compute the greatest common divisor of two integers.
|
||||
|
||||
### lcm() <sub>function</sub>
|
||||
|
||||
Compute the least common multiple of two integers.
|
||||
|
||||
### clamp() <sub>function</sub>
|
||||
|
||||
Clamp a number between low and high. clamp(value, low, high).
|
||||
|
||||
### angledist() <sub>function</sub>
|
||||
|
||||
Compute the signed distance between two angles in 'turn' units, e.g. 0..1 range.
|
||||
|
||||
### jitter() <sub>function</sub>
|
||||
|
||||
Apply a random +/- percentage noise to a number. Example: jitter(100, 0.05) -> ~95..105.
|
||||
|
||||
### mean() <sub>function</sub>
|
||||
|
||||
Compute the arithmetic mean of an array of numbers.
|
||||
|
||||
### sum() <sub>function</sub>
|
||||
|
||||
Sum all elements of an array of numbers.
|
||||
|
||||
### sigma() <sub>function</sub>
|
||||
|
||||
Compute standard deviation of an array of numbers.
|
||||
|
||||
### median() <sub>function</sub>
|
||||
|
||||
Compute the median of an array of numbers.
|
||||
|
||||
### length() <sub>function</sub>
|
||||
|
||||
Return the length of a vector (i.e. sqrt of sum of squares).
|
||||
|
||||
### from_to() <sub>function</sub>
|
||||
|
||||
Return an array of points from a start to an end, spaced out by a certain distance.
|
||||
|
||||
### rand() <sub>function</sub>
|
||||
|
||||
Return a random float in [0,1).
|
||||
|
||||
### randi() <sub>function</sub>
|
||||
|
||||
Return a random 32-bit integer.
|
||||
|
||||
### srand() <sub>function</sub>
|
||||
|
||||
Seed the random number generator with the given integer, or with current time if none.
|
||||
|
||||
### TAU <sub>number</sub>
|
||||
|
||||
### deg2rad(deg) <sub>function</sub>
|
||||
|
||||
### rad2deg(rad) <sub>function</sub>
|
||||
|
||||
### turn2rad(x) <sub>function</sub>
|
||||
|
||||
### rad2turn(x) <sub>function</sub>
|
||||
|
||||
### turn2deg(x) <sub>function</sub>
|
||||
|
||||
### deg2turn(x) <sub>function</sub>
|
||||
@@ -1,27 +0,0 @@
|
||||
# miniz
|
||||
|
||||
### read(data) <sub>function</sub>
|
||||
|
||||
Create a zip reader from the given ArrayBuffer containing an entire ZIP archive.
|
||||
Return undefined if the data is invalid.
|
||||
|
||||
|
||||
|
||||
**data**: An ArrayBuffer with the entire ZIP file.
|
||||
|
||||
|
||||
**Returns**: A 'zip reader' object with methods for reading from the archive (mod, exists, slurp).
|
||||
|
||||
|
||||
### write(path) <sub>function</sub>
|
||||
|
||||
Create a zip writer that writes to the specified file path. Overwrites the file if
|
||||
it already exists. Return undefined on error.
|
||||
|
||||
|
||||
|
||||
**path**: The file path where the ZIP archive will be written.
|
||||
|
||||
|
||||
**Returns**: A 'zip writer' object with methods for adding files to the archive (add_file).
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
# nota
|
||||
|
||||
### encode(value) <sub>function</sub>
|
||||
|
||||
Convert a JavaScript value into a NOTA-encoded ArrayBuffer.
|
||||
|
||||
This function serializes JavaScript values (such as numbers, strings, booleans, arrays, objects, or ArrayBuffers) into the NOTA binary format. The resulting ArrayBuffer can be stored or transmitted and later decoded back into a JavaScript value.
|
||||
|
||||
:throws: An error if no argument is provided.
|
||||
|
||||
|
||||
**value**: The JavaScript value to encode (e.g., number, string, boolean, array, object, or ArrayBuffer).
|
||||
|
||||
|
||||
**Returns**: An ArrayBuffer containing the NOTA-encoded data.
|
||||
|
||||
|
||||
### decode(buffer) <sub>function</sub>
|
||||
|
||||
Decode a NOTA-encoded ArrayBuffer into a JavaScript value.
|
||||
|
||||
This function deserializes a NOTA-formatted ArrayBuffer into its corresponding JavaScript representation, such as a number, string, boolean, array, object, or ArrayBuffer. If the input is invalid or empty, it returns undefined.
|
||||
|
||||
|
||||
|
||||
**buffer**: An ArrayBuffer containing NOTA-encoded data to decode.
|
||||
|
||||
|
||||
**Returns**: The decoded JavaScript value (e.g., number, string, boolean, array, object, or ArrayBuffer), or undefined if no argument is provided.
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
# os
|
||||
|
||||
### make_transform() <sub>function</sub>
|
||||
|
||||
Create a new transform object that can be used for 2D/3D positioning, scaling, and rotation.
|
||||
|
||||
### clean_transforms() <sub>function</sub>
|
||||
|
||||
Force an update on all transforms to remove dangling references or perform house-keeping.
|
||||
|
||||
### platform() <sub>function</sub>
|
||||
|
||||
Return a string with the underlying platform name, like 'Windows', 'Linux', or 'macOS'.
|
||||
|
||||
### arch() <sub>function</sub>
|
||||
|
||||
Return the CPU architecture string for this system (e.g. 'x64', 'arm64').
|
||||
|
||||
### totalmem() <sub>function</sub>
|
||||
|
||||
Return the total system RAM in bytes.
|
||||
|
||||
### freemem() <sub>function</sub>
|
||||
|
||||
Return the amount of free system RAM in bytes, if known.
|
||||
|
||||
### hostname() <sub>function</sub>
|
||||
|
||||
Return the system's hostname, or an empty string if not available.
|
||||
|
||||
### version() <sub>function</sub>
|
||||
|
||||
Return the OS or kernel version string, if the platform provides it.
|
||||
|
||||
### kill() <sub>function</sub>
|
||||
|
||||
Send a signal (e.g., 'SIGINT', 'SIGTERM', etc.) to the current process.
|
||||
|
||||
### exit() <sub>function</sub>
|
||||
|
||||
Exit the application with the specified exit code.
|
||||
|
||||
### now() <sub>function</sub>
|
||||
|
||||
Return current time (in seconds as a float) with high resolution.
|
||||
|
||||
### openurl() <sub>function</sub>
|
||||
|
||||
Open the provided URL in the default web browser, if possible.
|
||||
|
||||
### make_timer() <sub>function</sub>
|
||||
|
||||
Create a new timer object that will call a specified function after a certain delay.
|
||||
|
||||
### update_timers() <sub>function</sub>
|
||||
|
||||
Advance all timers by the provided time delta (in seconds).
|
||||
|
||||
### sleep() <sub>function</sub>
|
||||
|
||||
Block execution for the specified number of seconds.
|
||||
|
||||
### battery_pct() <sub>function</sub>
|
||||
|
||||
Return the battery level (percentage) or negative if unknown.
|
||||
|
||||
### battery_voltage() <sub>function</sub>
|
||||
|
||||
Return the current battery voltage in volts, if available.
|
||||
|
||||
### battery_seconds() <sub>function</sub>
|
||||
|
||||
Return the estimated remaining battery time in seconds, or negative if unknown.
|
||||
|
||||
### power_state() <sub>function</sub>
|
||||
|
||||
Return a string describing power status: 'on battery', 'charging', 'charged', etc.
|
||||
|
||||
### on() <sub>function</sub>
|
||||
|
||||
Register a global callback for certain engine-wide or system-level events.
|
||||
|
||||
### rt_info() <sub>function</sub>
|
||||
|
||||
Return internal QuickJS runtime info, such as object counts.
|
||||
|
||||
### rusage() <sub>function</sub>
|
||||
|
||||
Return resource usage stats for this process, if the platform supports it.
|
||||
|
||||
### mallinfo() <sub>function</sub>
|
||||
|
||||
Return detailed memory allocation info (arena size, free blocks, etc.) on some platforms.
|
||||
|
||||
### env() <sub>function</sub>
|
||||
|
||||
Fetch the value of a given environment variable, or undefined if it doesn't exist.
|
||||
|
||||
### system() <sub>function</sub>
|
||||
|
||||
Execute a shell command using the system() call. Returns the command's exit code.
|
||||
@@ -1,44 +0,0 @@
|
||||
# packer
|
||||
|
||||
### getAllFiles(dir) <sub>function</sub>
|
||||
|
||||
|
||||
Return a list of all files in the given directory that are not matched by .prosperonignore,
|
||||
skipping directories.
|
||||
|
||||
|
||||
|
||||
**dir**: The directory to search.
|
||||
|
||||
|
||||
**Returns**: An array of file paths found.
|
||||
|
||||
|
||||
### gatherStats(filePaths) <sub>function</sub>
|
||||
|
||||
|
||||
Analyze a list of files and categorize them as modules, programs, images, or other.
|
||||
|
||||
|
||||
|
||||
**filePaths**: An array of file paths to analyze.
|
||||
|
||||
|
||||
**Returns**: An object { modules, programs, images, other, total } with counts.
|
||||
|
||||
|
||||
### pack(dir, outPath) <sub>function</sub>
|
||||
|
||||
|
||||
Create a ZIP archive of all files (skipping those matched by .prosperonignore) in the
|
||||
specified directory and write it to outPath. This uses the miniz module.
|
||||
|
||||
|
||||
|
||||
**dir**: The directory to zip.
|
||||
|
||||
**outPath**: The path (including filename) for the resulting ZIP file.
|
||||
|
||||
|
||||
**Returns**: None (synchronous). Throws an Error if the directory does not exist.
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
# render
|
||||
|
||||
### _main <sub>object</sub>
|
||||
|
||||
A handle for low-level GPU operations via SDL GPU. Freed on GC.
|
||||
|
||||
|
||||
### device <sub>object</sub>
|
||||
|
||||
### stencil_writer(...args) <sub>function</sub>
|
||||
|
||||
### fillmask(ref) <sub>function</sub>
|
||||
|
||||
Draw a fullscreen shape using a 'screenfill' shader to populate the stencil buffer with a given reference.
|
||||
|
||||
|
||||
|
||||
**ref**: The stencil reference value to write.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### mask(image, pos, scale, rotation, ref) <sub>function</sub>
|
||||
|
||||
Draw an image to the stencil buffer, marking its area with a specified reference value.
|
||||
|
||||
|
||||
|
||||
**image**: A texture or string path (which is converted to a texture).
|
||||
|
||||
**pos**: The translation (x, y) for the image placement.
|
||||
|
||||
**scale**: Optional scaling applied to the texture.
|
||||
|
||||
**rotation**: Optional rotation in radians (unused by default).
|
||||
|
||||
**ref**: The stencil reference value to write.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### viewport(rect) <sub>function</sub>
|
||||
|
||||
Set the GPU viewport to the specified rectangle.
|
||||
|
||||
|
||||
|
||||
**rect**: A rectangle [x, y, width, height].
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### scissor(rect) <sub>function</sub>
|
||||
|
||||
Set the GPU scissor region to the specified rectangle (alias of render.viewport).
|
||||
|
||||
|
||||
|
||||
**rect**: A rectangle [x, y, width, height].
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### queue(cmd) <sub>function</sub>
|
||||
|
||||
Enqueue one or more draw commands. These commands are batched until render_camera is called.
|
||||
|
||||
|
||||
|
||||
**cmd**: Either a single command object or an array of command objects.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### setup_draw() <sub>function</sub>
|
||||
|
||||
Switch the current queue to the primary scene render queue, then invoke 'prosperon.draw' if defined.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### setup_hud() <sub>function</sub>
|
||||
|
||||
Switch the current queue to the HUD render queue, then invoke 'prosperon.hud' if defined.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
# resources
|
||||
|
||||
### scripts <sub>object</sub>
|
||||
|
||||
### images <sub>object</sub>
|
||||
|
||||
### sounds <sub>object</sub>
|
||||
|
||||
### fonts <sub>object</sub>
|
||||
|
||||
### lib <sub>object</sub>
|
||||
|
||||
### canonical(file) <sub>function</sub>
|
||||
|
||||
### find_image(...args) <sub>function</sub>
|
||||
|
||||
### find_sound(...args) <sub>function</sub>
|
||||
|
||||
### find_script(...args) <sub>function</sub>
|
||||
|
||||
### find_font(...args) <sub>function</sub>
|
||||
|
||||
### getAllFiles(dir) <sub>function</sub>
|
||||
|
||||
|
||||
Return a list of recognized files in the given directory that are not matched by
|
||||
.prosperonignore, skipping directories. Recognized extensions include scripts,
|
||||
images, sounds, fonts, and libs.
|
||||
|
||||
|
||||
|
||||
**dir**: The directory to search.
|
||||
|
||||
|
||||
**Returns**: An array of recognized file paths.
|
||||
|
||||
|
||||
### gatherStats(filePaths) <sub>function</sub>
|
||||
|
||||
|
||||
Analyze a list of recognized files and categorize them by scripts, images, sounds,
|
||||
fonts, libs, or other. Return a stats object with these counts and the total.
|
||||
|
||||
|
||||
|
||||
**filePaths**: An array of file paths to analyze.
|
||||
|
||||
|
||||
**Returns**: { scripts, images, sounds, fonts, lib, other, total }
|
||||
|
||||
|
||||
### pack(dir, outPath) <sub>function</sub>
|
||||
|
||||
|
||||
Create a ZIP archive of all recognized files (skipping those matched by .prosperonignore)
|
||||
in the specified directory and write it to outPath. Recognized extensions are scripts,
|
||||
images, sounds, fonts, or libs.
|
||||
|
||||
:raises Error: If the directory does not exist.
|
||||
|
||||
|
||||
**dir**: The directory to zip.
|
||||
|
||||
**outPath**: The path (including filename) for the resulting ZIP file.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# sound
|
||||
|
||||
### undefined <sub>string</sub>
|
||||
|
||||
### pcm(file) <sub>function</sub>
|
||||
|
||||
### play(file) <sub>function</sub>
|
||||
|
||||
### cry(file) <sub>function</sub>
|
||||
|
||||
### music(file, fade = 0.5) <sub>function</sub>
|
||||
@@ -1,9 +0,0 @@
|
||||
# spline
|
||||
|
||||
### catmull() <sub>function</sub>
|
||||
|
||||
Perform Catmull-Rom spline sampling on an array of 2D points, returning an array of samples.
|
||||
|
||||
### bezier() <sub>function</sub>
|
||||
|
||||
Perform a Bezier spline (or catmull) sampling on 2D points, returning an array of sampled points.
|
||||
@@ -1,103 +0,0 @@
|
||||
# time
|
||||
|
||||
The main time object, handling date/time utilities in earth-seconds.
|
||||
|
||||
### now() <sub>function</sub>
|
||||
|
||||
Return the current system time in seconds (implemented in C extension).
|
||||
|
||||
### computer_dst() <sub>function</sub>
|
||||
|
||||
Return true if local system time is currently in DST (implemented in C extension).
|
||||
|
||||
### computer_zone() <sub>function</sub>
|
||||
|
||||
Return local time zone offset from UTC in hours (implemented in C extension).
|
||||
|
||||
### second <sub>number</sub>
|
||||
|
||||
Number of seconds in a (real) second (always 1).
|
||||
|
||||
### minute <sub>number</sub>
|
||||
|
||||
Number of seconds in a minute (60).
|
||||
|
||||
### hour <sub>number</sub>
|
||||
|
||||
Number of seconds in an hour (3600).
|
||||
|
||||
### day <sub>number</sub>
|
||||
|
||||
Number of seconds in a day (86400).
|
||||
|
||||
### week <sub>number</sub>
|
||||
|
||||
Number of seconds in a week (604800).
|
||||
|
||||
### weekdays <sub>object</sub>
|
||||
|
||||
Names of the days of the week, Sunday through Saturday.
|
||||
|
||||
### monthstr <sub>object</sub>
|
||||
|
||||
Full names of the months of the year, January through December.
|
||||
|
||||
### epoch <sub>number</sub>
|
||||
|
||||
Base epoch year, from which day 0 is calculated (default 1970).
|
||||
|
||||
### hour2minute() <sub>function</sub>
|
||||
|
||||
Return the ratio of hour to minute in seconds, e.g. 3600 / 60 => 60.
|
||||
|
||||
### day2hour() <sub>function</sub>
|
||||
|
||||
Return the ratio of day to hour in seconds, e.g. 86400 / 3600 => 24.
|
||||
|
||||
### minute2second() <sub>function</sub>
|
||||
|
||||
Return the ratio of minute to second in seconds, e.g. 60 / 1 => 60.
|
||||
|
||||
### week2day() <sub>function</sub>
|
||||
|
||||
Return the ratio of week to day in seconds, e.g. 604800 / 86400 => 7.
|
||||
|
||||
### strparse <sub>object</sub>
|
||||
|
||||
Mapping of format tokens (yyyy, mm, dd, etc.) to time fields (year, month, day...).
|
||||
|
||||
### isleap(year) <sub>function</sub>
|
||||
|
||||
Return true if a given year is leap, based on whether it has 366 days.
|
||||
|
||||
### yearsize(y) <sub>function</sub>
|
||||
|
||||
Given a year, return 365 or 366 depending on leap-year rules.
|
||||
|
||||
### timecode(t, fps = 24) <sub>function</sub>
|
||||
|
||||
Convert seconds into a "S:frames" timecode string, with optional FPS (default 24).
|
||||
|
||||
### monthdays <sub>object</sub>
|
||||
|
||||
An array of days in each month for a non-leap year.
|
||||
|
||||
### zones <sub>object</sub>
|
||||
|
||||
Table of recognized time zone abbreviations, with offsets (e.g., "-12" -> "IDLW").
|
||||
|
||||
### record(num, zone = this.computer_zone() <sub>function</sub>
|
||||
|
||||
Convert a timestamp (in seconds) into a record with fields like day, month, year, etc.
|
||||
|
||||
### number(rec) <sub>function</sub>
|
||||
|
||||
Convert a record back into a numeric timestamp (seconds).
|
||||
|
||||
### fmt <sub>string</sub>
|
||||
|
||||
Default format string for time.text(), containing tokens like 'yyyy', 'dd', 'hh', etc.
|
||||
|
||||
### text(num, fmt = this.fmt, zone) <sub>function</sub>
|
||||
|
||||
Format a numeric or record time into a string using a format pattern, e.g. 'hh:nn:ss'.
|
||||
@@ -1,58 +0,0 @@
|
||||
# tween
|
||||
|
||||
### Tween <sub>object</sub>
|
||||
|
||||
|
||||
An object providing methods to create and control tweens with additional features
|
||||
like looping, custom easing, multiple stages, etc.
|
||||
|
||||
Properties:
|
||||
- default: A template object with loop/time/ease/whole/cb properties.
|
||||
Methods:
|
||||
- start(obj, target, tvals, options): Create a tween over multiple target values.
|
||||
- make: Alias of start.
|
||||
|
||||
|
||||
### Ease <sub>object</sub>
|
||||
|
||||
|
||||
This object provides multiple easing functions that remap a 0..1 input to produce
|
||||
a smoothed or non-linear output. They can be used standalone or inside tweens.
|
||||
|
||||
Available functions:
|
||||
- linear(t)
|
||||
- in(t), out(t), inout(t)
|
||||
- quad.in, quad.out, quad.inout
|
||||
- cubic.in, cubic.out, cubic.inout
|
||||
- quart.in, quart.out, quart.inout
|
||||
- quint.in, quint.out, quint.inout
|
||||
- expo.in, expo.out, expo.inout
|
||||
- bounce.in, bounce.out, bounce.inout
|
||||
- sine.in, sine.out, sine.inout
|
||||
- elastic.in, elastic.out, elastic.inout
|
||||
|
||||
All easing functions expect t in [0..1] and return a remapped value in [0..1].
|
||||
|
||||
|
||||
### tween(from, to, time, fn, cb) <sub>function</sub>
|
||||
|
||||
|
||||
|
||||
Creates a simple tween that linearly interpolates from "from" to "to" over "time"
|
||||
and calls "fn" with each interpolated value. Once finished, "fn" is called with "to",
|
||||
then "cb" is invoked if provided, and the tween is cleaned up.
|
||||
|
||||
|
||||
**from**: The starting object or value to interpolate from.
|
||||
|
||||
**to**: The ending object or value to interpolate to.
|
||||
|
||||
**time**: The total duration of the tween in milliseconds or some time unit.
|
||||
|
||||
**fn**: A callback function that receives the interpolated value at each update.
|
||||
|
||||
**cb**: (Optional) A callback invoked once the tween completes.
|
||||
|
||||
|
||||
**Returns**: A function that, when called, cleans up and stops the tween.
|
||||
|
||||
@@ -1,192 +0,0 @@
|
||||
# util
|
||||
|
||||
|
||||
A collection of general-purpose utility functions for object manipulation, merging,
|
||||
deep copying, safe property access, etc.
|
||||
|
||||
|
||||
### guid() <sub>function</sub>
|
||||
|
||||
|
||||
Return a random 32-character hexadecimal UUID-like string (not guaranteed RFC4122-compliant).
|
||||
|
||||
|
||||
**Returns**: A random 32-character string (hex).
|
||||
|
||||
|
||||
### insertion_sort(arr, cmp) <sub>function</sub>
|
||||
|
||||
|
||||
In-place insertion sort of an array using cmp(a,b)->Number for ordering.
|
||||
|
||||
|
||||
**arr**: The array to be sorted in-place.
|
||||
|
||||
**cmp**: Comparison function cmp(a,b)->Number.
|
||||
|
||||
|
||||
**Returns**: The same array, sorted in-place.
|
||||
|
||||
|
||||
### deepfreeze(obj) <sub>function</sub>
|
||||
|
||||
|
||||
Recursively freeze an object and all of its nested objects so they cannot be modified.
|
||||
|
||||
|
||||
**obj**: The object to recursively freeze.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### dainty_assign(target, source) <sub>function</sub>
|
||||
|
||||
|
||||
Copy non-function properties from source into matching keys of target without overwriting
|
||||
keys that don't exist in target. Arrays are deep-copied, and objects are recursively assigned.
|
||||
|
||||
|
||||
**target**: The target object whose keys may be updated.
|
||||
|
||||
**source**: The source object containing new values.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### get(obj, path, defValue) <sub>function</sub>
|
||||
|
||||
|
||||
Safely retrieve a nested property from obj at path (array or dot-string).
|
||||
Returns defValue if the property is undefined.
|
||||
|
||||
|
||||
**obj**: The object to traverse.
|
||||
|
||||
**path**: A string like "a.b.c" or an array of path segments.
|
||||
|
||||
**defValue**: The default value if the property is undefined.
|
||||
|
||||
|
||||
**Returns**: The nested property or defValue.
|
||||
|
||||
|
||||
### isEmpty(o) <sub>function</sub>
|
||||
|
||||
|
||||
Return true if the object has no own properties, otherwise false.
|
||||
|
||||
|
||||
**o**: The object to check.
|
||||
|
||||
|
||||
**Returns**: Boolean indicating if the object is empty.
|
||||
|
||||
|
||||
### dig(obj, path, def) <sub>function</sub>
|
||||
|
||||
|
||||
Ensure a nested path of objects exists inside obj; create objects if missing, and set
|
||||
the final path component to def.
|
||||
|
||||
|
||||
**obj**: The root object to modify.
|
||||
|
||||
**path**: A dot-string specifying nested objects to create.
|
||||
|
||||
**def**: The value to store in the final path component, default {}.
|
||||
|
||||
|
||||
**Returns**: The assigned final value.
|
||||
|
||||
|
||||
### access(obj, name) <sub>function</sub>
|
||||
|
||||
|
||||
Traverse obj by dot-separated path name, returning the final value or undefined
|
||||
if any step is missing.
|
||||
|
||||
|
||||
**obj**: The object to traverse.
|
||||
|
||||
**name**: A dot-string path (e.g. "foo.bar.baz").
|
||||
|
||||
|
||||
**Returns**: The value at that path, or undefined if missing.
|
||||
|
||||
|
||||
### mergekey(o1, o2, k) <sub>function</sub>
|
||||
|
||||
|
||||
Helper for merge, updating key k from o2 into o1. Arrays are deep-copied and objects are
|
||||
recursively merged.
|
||||
|
||||
|
||||
**o1**: The target object.
|
||||
|
||||
**o2**: The source object.
|
||||
|
||||
**k**: The key to merge.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### merge(target, objs) <sub>function</sub>
|
||||
|
||||
|
||||
Merge all passed objects into target, copying or merging each key as needed.
|
||||
Arrays are deep-copied, objects are recursively merged, etc.
|
||||
|
||||
|
||||
**target**: The target object.
|
||||
|
||||
**objs**: One or more objects to merge into target.
|
||||
|
||||
|
||||
**Returns**: The updated target object.
|
||||
|
||||
|
||||
### copy(proto, objs) <sub>function</sub>
|
||||
|
||||
|
||||
Create a new object with proto as its prototype, then mix in additional objects’ properties.
|
||||
|
||||
|
||||
**proto**: The prototype object for the new object.
|
||||
|
||||
**objs**: One or more objects whose properties will be mixed in.
|
||||
|
||||
|
||||
**Returns**: The newly created object.
|
||||
|
||||
|
||||
### obj_lerp(a, b, t) <sub>function</sub>
|
||||
|
||||
|
||||
Linearly interpolate between two objects a and b by factor t, assuming each property
|
||||
supports .lerp().
|
||||
|
||||
|
||||
**a**: The start object (its properties must have .lerp()).
|
||||
|
||||
**b**: The end object (matching properties).
|
||||
|
||||
**t**: Interpolation factor (0..1).
|
||||
|
||||
|
||||
**Returns**: A new object with interpolated properties.
|
||||
|
||||
|
||||
### normalizeSpacing(spacing) <sub>function</sub>
|
||||
|
||||
|
||||
Normalize any spacing input into a {l, r, t, b} object.
|
||||
|
||||
|
||||
**spacing**: A number, an array of length 2 or 4, or an object with l/r/t/b.
|
||||
|
||||
|
||||
**Returns**: An object {l, r, t, b}.
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# video
|
||||
|
||||
### make_video() <sub>function</sub>
|
||||
|
||||
Decode a video file (MPEG, etc.) from an ArrayBuffer, returning a datastream object.
|
||||
@@ -1,35 +0,0 @@
|
||||
# prosperon
|
||||
|
||||
### c_types <sub>object</sub>
|
||||
|
||||
### argv <sub>object</sub>
|
||||
|
||||
### version <sub>string</sub>
|
||||
|
||||
### revision <sub>string</sub>
|
||||
|
||||
### engine_start() <sub>function</sub>
|
||||
|
||||
### DOC <sub>symbol</sub>
|
||||
|
||||
### on(type, callback) <sub>function</sub>
|
||||
|
||||
### dispatch(type, data) <sub>function</sub>
|
||||
|
||||
### PATH <sub>object</sub>
|
||||
|
||||
### appupdate(...args) <sub>function</sub>
|
||||
|
||||
### update(...args) <sub>function</sub>
|
||||
|
||||
### physupdate(...args) <sub>function</sub>
|
||||
|
||||
### gui(...args) <sub>function</sub>
|
||||
|
||||
### hud(...args) <sub>function</sub>
|
||||
|
||||
### draw(...args) <sub>function</sub>
|
||||
|
||||
### imgui(...args) <sub>function</sub>
|
||||
|
||||
### app(...args) <sub>function</sub>
|
||||
@@ -1,55 +0,0 @@
|
||||
# PHYSFS_File
|
||||
|
||||
A file handle opened via PhysFS for writing or reading. Freed automatically when references go away.
|
||||
|
||||
|
||||
### close() <sub>function</sub>
|
||||
|
||||
Close this file handle. Throws on error.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### write(data) <sub>function</sub>
|
||||
|
||||
Write data (string or ArrayBuffer) to the file. Throws on error.
|
||||
|
||||
|
||||
|
||||
**data**: The data to write (string or ArrayBuffer).
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### buffer(size) <sub>function</sub>
|
||||
|
||||
Enable an internal write buffer of the given size on this file.
|
||||
|
||||
|
||||
|
||||
**size**: Size in bytes of the buffer.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### tell() <sub>function</sub>
|
||||
|
||||
Return the current position in the file.
|
||||
|
||||
|
||||
|
||||
**Returns**: A numeric offset.
|
||||
|
||||
|
||||
### eof() <sub>function</sub>
|
||||
|
||||
Return whether the file pointer is at end-of-file.
|
||||
|
||||
|
||||
|
||||
**Returns**: True if at EOF, false otherwise.
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
# SDL_Camera
|
||||
|
||||
A handle to a physical camera device. Freed when references drop or camera is closed.
|
||||
|
||||
|
||||
### frame() <sub>function</sub>
|
||||
|
||||
Acquire the latest camera frame (as an SDL_Surface). Returns undefined if no
|
||||
new frame is available yet. Throws on error.
|
||||
|
||||
|
||||
|
||||
**Returns**: SDL_Surface or undefined.
|
||||
|
||||
|
||||
### release_frame(surface) <sub>function</sub>
|
||||
|
||||
Release a frame surface previously acquired via camera.frame(). Must be
|
||||
done for each acquired frame.
|
||||
|
||||
|
||||
|
||||
**surface**: The surface to release.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
# SDL_Cursor
|
||||
|
||||
An SDL cursor handle. Freed automatically on GC. No direct methods.
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# SDL_GPUBuffer
|
||||
|
||||
### name() <sub>function</sub>
|
||||
@@ -1,231 +0,0 @@
|
||||
# SDL_GPUCommandBuffer
|
||||
|
||||
A command buffer that accumulates rendering, copy, and compute operations. Freed after submission or GC.
|
||||
|
||||
|
||||
### render_pass(passDesc) <sub>function</sub>
|
||||
|
||||
Begin a render pass with color/depth attachments. Provide an object with
|
||||
'color_targets' and optional 'depth_stencil'. Returns an SDL_GPURenderPass handle.
|
||||
|
||||
|
||||
|
||||
**passDesc**: {color_targets:[...], depth_stencil:...}
|
||||
|
||||
|
||||
**Returns**: SDL_GPURenderPass
|
||||
|
||||
|
||||
### compute_pass(storageTextures, storageBuffers) <sub>function</sub>
|
||||
|
||||
Begin a compute pass reading/writing given arrays of textures and buffers.
|
||||
|
||||
|
||||
|
||||
**storageTextures**: array of read/write textures
|
||||
|
||||
**storageBuffers**: array of read/write buffers
|
||||
|
||||
|
||||
**Returns**: SDL_GPUComputePass
|
||||
|
||||
|
||||
### swapchain_pass(clearColor) <sub>function</sub>
|
||||
|
||||
Begin a render pass that directly targets the swapchain (the window). Clears
|
||||
with the specified color.
|
||||
|
||||
|
||||
|
||||
**clearColor**: [r,g,b,a]
|
||||
|
||||
|
||||
**Returns**: SDL_GPURenderPass
|
||||
|
||||
|
||||
### acquire_swapchain() <sub>function</sub>
|
||||
|
||||
Acquire the current swapchain texture from the window. Internal usage.
|
||||
|
||||
|
||||
|
||||
**Returns**: SDL_GPUTexture handle
|
||||
|
||||
|
||||
### bind_vertex_buffer(slot, buffer) <sub>function</sub>
|
||||
|
||||
Bind a GPU buffer as the vertex buffer at a given slot.
|
||||
|
||||
|
||||
|
||||
**slot**: Integer slot index.
|
||||
|
||||
**buffer**: The SDL_GPUBuffer.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### bind_index_buffer(buffer, offset) <sub>function</sub>
|
||||
|
||||
Bind a GPU buffer as the index buffer (16-bit or 32-bit).
|
||||
|
||||
|
||||
|
||||
**buffer**: The SDL_GPUBuffer.
|
||||
|
||||
**offset**: Optional offset in bytes.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### bind_fragment_sampler(slot, texture, sampler) <sub>function</sub>
|
||||
|
||||
Bind a texture+sampler pair to a particular fragment shader slot.
|
||||
|
||||
|
||||
|
||||
**slot**: Index of the sampler binding.
|
||||
|
||||
**texture**: The SDL_GPUTexture
|
||||
|
||||
**sampler**: The SDL_GPUSampler
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### push_vertex_uniform_data(slot, data) <sub>function</sub>
|
||||
|
||||
Push raw data to a vertex shader uniform block.
|
||||
|
||||
|
||||
|
||||
**slot**: The uniform buffer slot.
|
||||
|
||||
**data**: An ArrayBuffer with the data to upload.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### push_fragment_uniform_data(slot, data) <sub>function</sub>
|
||||
|
||||
Push raw data to a fragment shader uniform block.
|
||||
|
||||
|
||||
|
||||
**slot**: The uniform buffer slot index.
|
||||
|
||||
**data**: An ArrayBuffer with uniform data.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### push_compute_uniform_data(slot, data) <sub>function</sub>
|
||||
|
||||
Push raw data to a compute shader uniform buffer.
|
||||
|
||||
|
||||
|
||||
**slot**: The uniform buffer slot.
|
||||
|
||||
**data**: An ArrayBuffer with the data.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### submit() <sub>function</sub>
|
||||
|
||||
Submit this command buffer to the GPU and return a fence for synchronization.
|
||||
|
||||
|
||||
|
||||
**Returns**: An SDL_GPUFence
|
||||
|
||||
|
||||
### cancel() <sub>function</sub>
|
||||
|
||||
Cancel (discard) this command buffer without submitting.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### camera(cameraTransform, uniformSlot) <sub>function</sub>
|
||||
|
||||
Write a camera transform (projection/view) to a uniform slot for 3D or 2D usage.
|
||||
|
||||
|
||||
|
||||
**cameraTransform**: A camera object or transform with .pos, fov, etc.
|
||||
|
||||
**uniformSlot**: The integer uniform buffer slot to which data is pushed.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### hud(sizeVec2, uniformSlot) <sub>function</sub>
|
||||
|
||||
Write an orthographic full-screen "HUD" matrix to a uniform slot. Typically used
|
||||
for 2D overlays.
|
||||
|
||||
|
||||
|
||||
**sizeVec2**: [width, height] of the viewport area.
|
||||
|
||||
**uniformSlot**: The integer uniform buffer slot.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### push_debug_group(name) <sub>function</sub>
|
||||
|
||||
Push a named debug group marker onto the GPU command list (for debuggers/profilers).
|
||||
|
||||
|
||||
|
||||
**name**: The debug label string.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### pop_debug_group() <sub>function</sub>
|
||||
|
||||
Pop the most recent debug group marker.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### debug_label(label) <sub>function</sub>
|
||||
|
||||
Insert a one-off debug label at the current spot in the command list.
|
||||
|
||||
|
||||
|
||||
**label**: The debug label string
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### blit(blitDesc) <sub>function</sub>
|
||||
|
||||
Blit one GPU texture to another with optional flip mode, filter, and clear operations.
|
||||
|
||||
|
||||
|
||||
**blitDesc**: { src:{texture,mip_level, etc}, dst:{texture,...}, load_op, flip, filter, clear_color:[r,g,b,a] }
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
# SDL_GPUComputePass
|
||||
|
||||
A compute pass for dispatching compute pipelines. Freed after end() or GC.
|
||||
|
||||
|
||||
### dispatch(x, y, z) <sub>function</sub>
|
||||
|
||||
Dispatch the compute pipeline with the specified threadgroup counts.
|
||||
|
||||
|
||||
|
||||
**x**: Number of groups in X dimension
|
||||
|
||||
**y**: Number of groups in Y dimension
|
||||
|
||||
**z**: Number of groups in Z dimension
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### end() <sub>function</sub>
|
||||
|
||||
End this compute pass.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### pipeline(computePipeline) <sub>function</sub>
|
||||
|
||||
Bind a compute pipeline in this pass.
|
||||
|
||||
|
||||
|
||||
**computePipeline**: The SDL_GPUComputePipeline
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### samplers(arrayOfSamplerBindings, firstSlot) <sub>function</sub>
|
||||
|
||||
Bind a set of texture/sampler pairs for compute usage.
|
||||
|
||||
|
||||
|
||||
**arrayOfSamplerBindings**: e.g. [ {texture, sampler}, ...]
|
||||
|
||||
**firstSlot**: The starting sampler slot.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### storage_buffers(arrayOfBuffers, firstSlot) <sub>function</sub>
|
||||
|
||||
Bind an array of storage buffers for the compute shader.
|
||||
|
||||
|
||||
|
||||
**arrayOfBuffers**: The buffers
|
||||
|
||||
**firstSlot**: Starting binding slot.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### storage_textures(arrayOfTextures, firstSlot) <sub>function</sub>
|
||||
|
||||
Bind an array of storage textures for the compute shader.
|
||||
|
||||
|
||||
|
||||
**arrayOfTextures**: The textures
|
||||
|
||||
**firstSlot**: Starting binding slot
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# SDL_GPUComputePipeline
|
||||
|
||||
Encapsulates a compute shader program plus associated resource layouts.
|
||||
Created via device.compute_pipeline(...).
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
# SDL_GPUCopyPass
|
||||
|
||||
A pass for CPU<->GPU or GPU<->GPU copy operations. No direct JS API besides internal usage.
|
||||
|
||||
@@ -1,236 +0,0 @@
|
||||
# SDL_GPUDevice
|
||||
|
||||
A handle for low-level GPU operations via SDL GPU. Freed on GC.
|
||||
|
||||
|
||||
### claim_window(window) <sub>function</sub>
|
||||
|
||||
Claim an existing SDL_Window so this GPU device can render to it.
|
||||
|
||||
|
||||
|
||||
**window**: The SDL_Window to attach.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### make_pipeline(pipelineDesc) <sub>function</sub>
|
||||
|
||||
Create a new graphics pipeline from a descriptor object specifying shaders,
|
||||
blend states, vertex format, etc.
|
||||
|
||||
|
||||
|
||||
**pipelineDesc**: An object containing pipeline fields (vertexShader, blend, etc.).
|
||||
|
||||
|
||||
**Returns**: A SDL_GPUGraphicsPipeline handle.
|
||||
|
||||
|
||||
### compute_pipeline(desc) <sub>function</sub>
|
||||
|
||||
Create a compute pipeline from a descriptor (shader code, threadgroup sizes, etc.).
|
||||
|
||||
|
||||
|
||||
**desc**: An object with shader code, thread counts, etc.
|
||||
|
||||
|
||||
**Returns**: SDL_GPUComputePipeline handle.
|
||||
|
||||
|
||||
### set_swapchain(composition, presentMode) <sub>function</sub>
|
||||
|
||||
Specify how the swapchain (final rendered image) is composed, e.g. 'sdr', 'hdr',
|
||||
and present mode like 'vsync' or 'immediate'.
|
||||
|
||||
|
||||
|
||||
**composition**: E.g. 'sdr', 'linear', or 'hdr'.
|
||||
|
||||
**presentMode**: E.g. 'vsync', 'immediate', 'mailbox'.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### sort_sprite(a, b) <sub>function</sub>
|
||||
|
||||
A comparator function used for sorting sprite objects by layer, y, and texture.
|
||||
Usually used internally.
|
||||
|
||||
|
||||
|
||||
**a**: A sprite object.
|
||||
|
||||
**b**: Another sprite object.
|
||||
|
||||
|
||||
**Returns**: <0, 0, or >0 for sort ordering.
|
||||
|
||||
|
||||
### make_sampler(samplerDesc) <sub>function</sub>
|
||||
|
||||
Create a sampler object specifying filtering, wrapping, anisotropy, etc.
|
||||
|
||||
|
||||
|
||||
**samplerDesc**: An object with min_filter, mag_filter, etc.
|
||||
|
||||
|
||||
**Returns**: SDL_GPUSampler handle.
|
||||
|
||||
|
||||
### load_texture(surface, compressionLevel) <sub>function</sub>
|
||||
|
||||
Upload an SDL_Surface into a GPU texture, optionally compressing with DXT. Freed automatically.
|
||||
|
||||
|
||||
|
||||
**surface**: An SDL_Surface.
|
||||
|
||||
**compressionLevel**: 0=none, 1=DXT1 or DXT5, 2=high quality, etc.
|
||||
|
||||
|
||||
**Returns**: SDL_GPUTexture
|
||||
|
||||
|
||||
### texture(desc) <sub>function</sub>
|
||||
|
||||
Create a GPU texture with the specified format usage.
|
||||
|
||||
|
||||
|
||||
**desc**: Object with {width, height, layers, type, format, usage, etc.}
|
||||
|
||||
|
||||
**Returns**: SDL_GPUTexture
|
||||
|
||||
|
||||
### make_quad() <sub>function</sub>
|
||||
|
||||
Return a simple 2-triangle quad geometry covering [0,1]x[0,1].
|
||||
Useful for post-processing passes.
|
||||
|
||||
|
||||
|
||||
**Returns**: A mesh {pos, uv, color, indices}.
|
||||
|
||||
|
||||
### driver() <sub>function</sub>
|
||||
|
||||
Return the name of the underlying GPU driver in use (e.g. 'OpenGL').
|
||||
|
||||
|
||||
|
||||
**Returns**: A string with driver name.
|
||||
|
||||
|
||||
### make_shader(desc) <sub>function</sub>
|
||||
|
||||
Compile raw shader code (vertex or fragment) in e.g. SPIR-V, MSL, or DXIL format.
|
||||
|
||||
|
||||
|
||||
**desc**: {code:ArrayBuffer, stage:'vertex'|'fragment', format:'spv'|..., entrypoint:'main', ...}
|
||||
|
||||
|
||||
**Returns**: SDL_GPUShader object
|
||||
|
||||
|
||||
### acquire_cmd_buffer() <sub>function</sub>
|
||||
|
||||
Obtain a new command buffer for recording GPU commands. Must be submitted or canceled.
|
||||
|
||||
|
||||
|
||||
**Returns**: SDL_GPUCommandBuffer handle
|
||||
|
||||
|
||||
### upload(cmdBuffer, buffers, transferBuffer) <sub>function</sub>
|
||||
|
||||
Upload CPU data into a list of GPU buffers, optionally reusing or returning a
|
||||
transfer buffer. Typically you provide (cmdBuf, arrayOfTypedArrays, [transferBuffer]).
|
||||
|
||||
|
||||
|
||||
**cmdBuffer**: The command buffer in which to record copy commands.
|
||||
|
||||
**buffers**: An array of typed-array data to upload, each must have a 'gpu' property or so.
|
||||
|
||||
**transferBuffer**: Optional existing GPU transfer buffer to reuse.
|
||||
|
||||
|
||||
**Returns**: The transfer buffer used or newly created.
|
||||
|
||||
|
||||
### wait_for_fences(fences, waitAll) <sub>function</sub>
|
||||
|
||||
Wait on an array of GPU fence objects, optionally requiring all or any.
|
||||
|
||||
|
||||
|
||||
**fences**: An array of SDL_GPUFence objects.
|
||||
|
||||
**waitAll**: Boolean, true to wait for all fences, false for any.
|
||||
|
||||
|
||||
**Returns**: True if fences signaled, false on timeout or error.
|
||||
|
||||
|
||||
### query_fence(fence) <sub>function</sub>
|
||||
|
||||
Check if the given fence has been signaled yet. Non-blocking.
|
||||
|
||||
|
||||
|
||||
**fence**: SDL_GPUFence handle
|
||||
|
||||
|
||||
**Returns**: True if signaled, false if still pending
|
||||
|
||||
|
||||
### shader_format() <sub>function</sub>
|
||||
|
||||
Return an array of supported GPU shader binary formats (like 'spv', 'dxbc', etc.).
|
||||
|
||||
|
||||
|
||||
**Returns**: Array of strings naming supported formats.
|
||||
|
||||
|
||||
### slice9(texture, dstRect, edges) <sub>function</sub>
|
||||
|
||||
Generate a 9-slice tiling geometry in one shot. For advanced usage with GPU pipeline.
|
||||
|
||||
|
||||
|
||||
**texture**: An SDL_GPUTexture
|
||||
|
||||
**dstRect**: The rectangle {x, y, w, h}
|
||||
|
||||
**edges**: {l, r, t, b} edge sizes
|
||||
|
||||
|
||||
**Returns**: A mesh object
|
||||
|
||||
|
||||
### tile(texture, srcRect, dstRect, tileInfo) <sub>function</sub>
|
||||
|
||||
Generate geometry to tile a texture portion inside a dest rect.
|
||||
Often used for repeating backgrounds.
|
||||
|
||||
|
||||
|
||||
**texture**: The SDL_GPUTexture
|
||||
|
||||
**srcRect**: The portion to tile in pixels
|
||||
|
||||
**dstRect**: Where to fill
|
||||
|
||||
**tileInfo**: e.g. {repeat_x:true, repeat_y:true}
|
||||
|
||||
|
||||
**Returns**: A mesh object
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# SDL_GPUFence
|
||||
|
||||
A GPU fence for synchronization. Created upon commandBuffer.submit().
|
||||
Wait or query it with device.wait_for_fences or device.query_fence.
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# SDL_GPUGraphicsPipeline
|
||||
|
||||
Encapsulates vertex+fragment shaders, blend/cull states, and vertex attribute layouts.
|
||||
Created via device.make_pipeline(...).
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
# SDL_GPURenderPass
|
||||
|
||||
A single pass of drawing commands with color/depth attachments. Freed after end() or GC.
|
||||
|
||||
|
||||
### bind_pipeline(pipeline) <sub>function</sub>
|
||||
|
||||
Bind a previously created graphics pipeline (shaders, states, vertex layouts, etc.).
|
||||
|
||||
|
||||
|
||||
**pipeline**: The SDL_GPUGraphicsPipeline
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### viewport(rect) <sub>function</sub>
|
||||
|
||||
Set the viewport for clipping or scaling draws, in pass-local coordinates.
|
||||
|
||||
|
||||
|
||||
**rect**: {x,y,w,h}
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### scissor(rect) <sub>function</sub>
|
||||
|
||||
Set a scissor rectangle for discarding pixels outside it.
|
||||
|
||||
|
||||
|
||||
**rect**: {x,y,w,h}
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### draw(primitiveType, baseVertex, firstVertex, vertexCount) <sub>function</sub>
|
||||
|
||||
Issue a non-indexed draw call.
|
||||
|
||||
|
||||
|
||||
**primitiveType**: e.g. SDL_GPU_PRIMITIVETYPE_TRIANGLELIST
|
||||
|
||||
**baseVertex**: Starting vertex offset.
|
||||
|
||||
**firstVertex**: The first vertex to draw.
|
||||
|
||||
**vertexCount**: How many vertices to draw.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### draw_indexed(primitiveType, baseVertex, firstIndex, indexCount, instanceCount) <sub>function</sub>
|
||||
|
||||
Issue an indexed draw call from the bound index buffer.
|
||||
|
||||
|
||||
|
||||
**primitiveType**: The primitive type constant.
|
||||
|
||||
**baseVertex**: Offset in the vertex buffer.
|
||||
|
||||
**firstIndex**: Which index to start from.
|
||||
|
||||
**indexCount**: Number of indices to draw.
|
||||
|
||||
**instanceCount**: For instanced drawing, or 1 if normal.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### end() <sub>function</sub>
|
||||
|
||||
End this render pass, finalizing the draw operations.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### bind_index_buffer(buffer, elementSize16bit) <sub>function</sub>
|
||||
|
||||
Bind an index buffer inside this pass, possibly overriding the global one.
|
||||
|
||||
|
||||
|
||||
**buffer**: The SDL_GPUBuffer
|
||||
|
||||
**elementSize16bit**: If 2, uses 16-bit indices; if 4, uses 32-bit indices
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### bind_buffers(firstSlot, arrayOfBuffers) <sub>function</sub>
|
||||
|
||||
Bind multiple vertex buffers at consecutive slots.
|
||||
|
||||
|
||||
|
||||
**firstSlot**: The starting vertex buffer slot.
|
||||
|
||||
**arrayOfBuffers**: An array of GPUBuffer objects
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### bind_samplers(vertexOrFragment, firstSlot, samplerBindings) <sub>function</sub>
|
||||
|
||||
Bind multiple texture/sampler pairs to either vertex or fragment slots.
|
||||
|
||||
|
||||
|
||||
**vertexOrFragment**: Boolean, true for vertex stage, false for fragment.
|
||||
|
||||
**firstSlot**: The first sampler slot to bind.
|
||||
|
||||
**samplerBindings**: An array of {texture, sampler}.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### bind_storage_buffers(firstSlot, buffers) <sub>function</sub>
|
||||
|
||||
Bind one or more storage buffers for read/write in the pipeline.
|
||||
|
||||
|
||||
|
||||
**firstSlot**: Starting buffer slot index.
|
||||
|
||||
**buffers**: An array of SDL_GPUBuffer objects.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### bind_storage_textures(firstSlot, textures) <sub>function</sub>
|
||||
|
||||
Bind one or more storage textures for read/write in the pipeline.
|
||||
|
||||
|
||||
|
||||
**firstSlot**: Starting texture slot index.
|
||||
|
||||
**textures**: An array of SDL_GPUTexture objects.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
# SDL_GPUSampler
|
||||
|
||||
Defines how a texture is sampled (filter mode, address mode, anisotropy, compare op, etc.).
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# SDL_GPUShader
|
||||
|
||||
A single compiled shader (vertex or fragment) in a GPU-friendly format
|
||||
(e.g., SPIR-V, MSL). Combined into a pipeline for drawing.
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# SDL_GPUTexture
|
||||
|
||||
### name() <sub>function</sub>
|
||||
@@ -1,5 +0,0 @@
|
||||
# SDL_GPUTransferBuffer
|
||||
|
||||
A staging buffer used for copying data to or from GPU buffers/textures. Typically
|
||||
allocated/used internally by device.upload(...).
|
||||
|
||||
@@ -1,333 +0,0 @@
|
||||
# SDL_Renderer
|
||||
|
||||
A 2D rendering context using the SDL renderer API. Freed automatically.
|
||||
|
||||
|
||||
### draw_color(color) <sub>function</sub>
|
||||
|
||||
Set the render draw color for subsequent primitive calls (rect, line, etc.).
|
||||
|
||||
|
||||
|
||||
**color**: [r, g, b, a] in 0..1.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### present() <sub>function</sub>
|
||||
|
||||
Display whatever has been rendered (swap buffers). Must be called each frame.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### clear() <sub>function</sub>
|
||||
|
||||
Clear the current render target with the renderer's draw color.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### rect(rectOrArray, color) <sub>function</sub>
|
||||
|
||||
Draw one or more outlines of rectangles.
|
||||
|
||||
|
||||
|
||||
**rectOrArray**: A single rect {x,y,w,h} or an array of rects.
|
||||
|
||||
**color**: Optional [r,g,b,a]. If provided, overrides current draw color.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### fillrect(rectOrArray, color) <sub>function</sub>
|
||||
|
||||
Fill one or more rectangles with the renderer's current color or an optional override.
|
||||
|
||||
|
||||
|
||||
**rectOrArray**: A single rect {x,y,w,h} or an array of rects.
|
||||
|
||||
**color**: Optional [r,g,b,a].
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### line(points, color) <sub>function</sub>
|
||||
|
||||
Draw a sequence of lines connecting points in an array.
|
||||
|
||||
|
||||
|
||||
**points**: An array of [x,y] points. Lines connect consecutive points.
|
||||
|
||||
**color**: Optional [r,g,b,a].
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### point(points, color) <sub>function</sub>
|
||||
|
||||
Draw a list of points (pixels).
|
||||
|
||||
|
||||
|
||||
**points**: An array of [x,y] positions.
|
||||
|
||||
**color**: Optional [r,g,b,a].
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### load_texture(surface) <sub>function</sub>
|
||||
|
||||
Create an SDL_Texture from a given SDL_Surface for use with this renderer.
|
||||
|
||||
|
||||
|
||||
**surface**: An SDL_Surface.
|
||||
|
||||
|
||||
**Returns**: An SDL_Texture object.
|
||||
|
||||
|
||||
### texture(tex, dstRect, srcRect, color) <sub>function</sub>
|
||||
|
||||
Draw a texture onto the render target.
|
||||
|
||||
|
||||
|
||||
**tex**: The SDL_Texture to draw.
|
||||
|
||||
**dstRect**: The destination rect {x, y, w, h}.
|
||||
|
||||
**srcRect**: Optional portion of the texture to draw {x, y, w, h}.
|
||||
|
||||
**color**: Optional color mod [r,g,b,a].
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### slice9(tex, dstRect, edges, srcRect) <sub>function</sub>
|
||||
|
||||
Draw a texture with 9-slice scaling. The argument includes edges {l, r, t, b}
|
||||
for the corners/borders that remain unscaled. The rest is tiled or stretched.
|
||||
|
||||
|
||||
|
||||
**tex**: The SDL_Texture.
|
||||
|
||||
**dstRect**: Destination region {x, y, w, h}.
|
||||
|
||||
**edges**: {l, r, t, b} for corner sizes in pixels.
|
||||
|
||||
**srcRect**: Optional portion in the texture.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### tile(tex, dstRect, srcRect, scale) <sub>function</sub>
|
||||
|
||||
Tile a texture repeatedly within the specified region. Optionally use a srcRect.
|
||||
|
||||
|
||||
|
||||
**tex**: The SDL_Texture to tile.
|
||||
|
||||
**dstRect**: The region to fill {x, y, w, h}.
|
||||
|
||||
**srcRect**: Optional portion of texture.
|
||||
|
||||
**scale**: A float scale factor for each tile.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### get_image(rect) <sub>function</sub>
|
||||
|
||||
Read back the rendered pixels into a new SDL_Surface. If rect is undefined, capture entire output.
|
||||
|
||||
|
||||
|
||||
**rect**: Optional {x,y,w,h}.
|
||||
|
||||
|
||||
**Returns**: An SDL_Surface with the requested region's pixels.
|
||||
|
||||
|
||||
### fasttext(text, pos, color) <sub>function</sub>
|
||||
|
||||
Draw debug text using an internal fast path. Typically used for quick debugging overlays.
|
||||
|
||||
|
||||
|
||||
**text**: The string to draw.
|
||||
|
||||
**pos**: The [x, y] position to draw text.
|
||||
|
||||
**color**: Optional [r,g,b,a].
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### geometry(texture, meshObject) <sub>function</sub>
|
||||
|
||||
Render custom geometry from a mesh object {pos, uv, color, indices, count} with an optional texture.
|
||||
|
||||
|
||||
|
||||
**texture**: The SDL_Texture or undefined.
|
||||
|
||||
**meshObject**: The geometry data with typed arrays.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### scale(scaleVec2) <sub>function</sub>
|
||||
|
||||
Set a scaling factor for all subsequent rendering on this renderer.
|
||||
|
||||
|
||||
|
||||
**scaleVec2**: [sx, sy] scaling factors.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### logical_size(size) <sub>function</sub>
|
||||
|
||||
Set a "logical" size that the renderer will scale to.
|
||||
For example, (320, 240) can auto-scale up to the window resolution.
|
||||
|
||||
|
||||
|
||||
**size**: [width, height].
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### viewport(rect) <sub>function</sub>
|
||||
|
||||
Set the clipping viewport for rendering. Pass undefined to use the full render target.
|
||||
|
||||
|
||||
|
||||
**rect**: {x, y, w, h}, or undefined.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### clip(rect) <sub>function</sub>
|
||||
|
||||
Set or clear the clipping rectangle for drawing. Pass undefined to clear.
|
||||
|
||||
|
||||
|
||||
**rect**: {x, y, w, h} or undefined.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### vsync(flag) <sub>function</sub>
|
||||
|
||||
Enable or disable vertical sync. This may have no effect depending on the driver.
|
||||
|
||||
|
||||
|
||||
**flag**: True or false.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### coords(pos) <sub>function</sub>
|
||||
|
||||
Convert window coordinates to this renderer's coordinate space.
|
||||
|
||||
|
||||
|
||||
**pos**: [x, y] in window space.
|
||||
|
||||
|
||||
**Returns**: [x, y] in renderer coordinate space.
|
||||
|
||||
|
||||
### camera(cameraTransform, centered) <sub>function</sub>
|
||||
|
||||
Set up a basic 2D camera matrix from a given transform. If 'centered' is true,
|
||||
the origin is the center of the viewport, else top-left.
|
||||
|
||||
|
||||
|
||||
**cameraTransform**: The transform whose pos is used.
|
||||
|
||||
**centered**: Boolean true or false.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### get_viewport() <sub>function</sub>
|
||||
|
||||
Return the current viewport rect.
|
||||
|
||||
|
||||
|
||||
**Returns**: {x, y, w, h}
|
||||
|
||||
|
||||
### screen2world(pos) <sub>function</sub>
|
||||
|
||||
Convert a screen coordinate to world space based on the current camera transform.
|
||||
|
||||
|
||||
|
||||
**pos**: [x, y] screen coords
|
||||
|
||||
|
||||
**Returns**: [wx, wy] in world space
|
||||
|
||||
|
||||
### target(texture) <sub>function</sub>
|
||||
|
||||
Set or clear the current render target texture. Pass undefined to reset to the default/window.
|
||||
|
||||
|
||||
|
||||
**texture**: An SDL_Texture or undefined
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### make_sprite_mesh(sprites) <sub>function</sub>
|
||||
|
||||
Generate a mesh from an array of sprite objects, combining their positions, UVs,
|
||||
and colors into a single geometry block.
|
||||
|
||||
|
||||
|
||||
**sprites**: An array of sprite-like objects.
|
||||
|
||||
|
||||
**Returns**: A 'mesh' object with pos, uv, color, indices, etc.
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
# SDL_Surface
|
||||
|
||||
A software (CPU) image in memory. Freed when references vanish. Typically converted
|
||||
to SDL_Texture for drawing, or used as raw pixel data.
|
||||
|
||||
|
||||
### blit(dstRect, srcSurface, srcRect) <sub>function</sub>
|
||||
|
||||
Blit (copy) another surface onto this surface, scaling if needed.
|
||||
|
||||
|
||||
|
||||
**dstRect**: Destination {x, y, w, h}
|
||||
|
||||
**srcSurface**: The source SDL_Surface
|
||||
|
||||
**srcRect**: {x, y, w, h} portion from source
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### scale(newSize) <sub>function</sub>
|
||||
|
||||
Return a new SDL_Surface scaled to [width, height] using linear filtering.
|
||||
|
||||
|
||||
|
||||
**newSize**: [width, height]
|
||||
|
||||
|
||||
**Returns**: A new SDL_Surface with the scaled result.
|
||||
|
||||
|
||||
### fill(color) <sub>function</sub>
|
||||
|
||||
Fill the entire surface with a single color.
|
||||
|
||||
|
||||
|
||||
**color**: [r, g, b, a] in 0..1
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### rect(rect, color) <sub>function</sub>
|
||||
|
||||
Fill a sub-rectangle of the surface with a color.
|
||||
|
||||
|
||||
|
||||
**rect**: {x, y, w, h}
|
||||
|
||||
**color**: [r, g, b, a]
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### dup() <sub>function</sub>
|
||||
|
||||
Make a copy of this surface in RGBA format.
|
||||
|
||||
|
||||
|
||||
**Returns**: A new SDL_Surface copy.
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# SDL_Texture
|
||||
|
||||
A 2D GPU-accelerated texture for rendering with SDL_Renderer. Freed automatically.
|
||||
|
||||
|
||||
### mode(mode) <sub>function</sub>
|
||||
|
||||
Set texture scale mode or filtering mode (nearest/linear).
|
||||
|
||||
|
||||
|
||||
**mode**: A string or numeric mode to set (e.g., 'linear').
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
# SDL_Thread
|
||||
|
||||
A handle to an SDL-created thread. Freed on GC after join.
|
||||
|
||||
Note: The engine generally doesn't expose custom usage for threads.
|
||||
|
||||
|
||||
### wait() <sub>function</sub>
|
||||
|
||||
Block until this thread terminates.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
# SDL_Window
|
||||
|
||||
An application window, created via prosperon.engine_start or SDL calls. Freed on GC.
|
||||
|
||||
|
||||
### fullscreen() <sub>function</sub>
|
||||
|
||||
Toggle fullscreen mode for this window (SDL_WINDOW_FULLSCREEN).
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### make_renderer(name) <sub>function</sub>
|
||||
|
||||
Create an SDL_Renderer for 2D rendering tied to this window.
|
||||
|
||||
|
||||
|
||||
**name**: The renderer driver name, e.g. "opengl" (may be optional).
|
||||
|
||||
|
||||
**Returns**: An SDL_Renderer object.
|
||||
|
||||
|
||||
### make_gpu(debug, driverName) <sub>function</sub>
|
||||
|
||||
Create an SDL_GPUDevice for low-level GPU rendering on this window.
|
||||
|
||||
|
||||
|
||||
**debug**: If true, enable debugging in the GPU device.
|
||||
|
||||
**driverName**: The GPU back-end driver, e.g. "opengl".
|
||||
|
||||
|
||||
**Returns**: An SDL_GPUDevice.
|
||||
|
||||
|
||||
### keyboard_shown() <sub>function</sub>
|
||||
|
||||
Return whether the on-screen keyboard is visible (mobile/tablet).
|
||||
|
||||
|
||||
|
||||
**Returns**: True if shown, false otherwise.
|
||||
|
||||
|
||||
### theme() <sub>function</sub>
|
||||
|
||||
Currently returns undefined. Placeholder for retrieving OS window theme info.
|
||||
|
||||
|
||||
|
||||
**Returns**: undefined
|
||||
|
||||
|
||||
### safe_area() <sub>function</sub>
|
||||
|
||||
Return a rect describing any OS-specific "safe" region for UI, e.g. on iPhone with a notch.
|
||||
|
||||
|
||||
|
||||
**Returns**: A rect object {x, y, w, h}.
|
||||
|
||||
|
||||
### bordered(flag) <sub>function</sub>
|
||||
|
||||
Enable or disable window borders.
|
||||
|
||||
|
||||
|
||||
**flag**: True to show borders, false to hide.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### set_icon(surface) <sub>function</sub>
|
||||
|
||||
Set the window's icon from an SDL_Surface.
|
||||
|
||||
|
||||
|
||||
**surface**: An SDL_Surface holding the icon.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### title <sub>accessor</sub>
|
||||
|
||||
Get or set the window's title text in the title bar.
|
||||
|
||||
|
||||
|
||||
**newTitle**: (when setting) A string title.
|
||||
|
||||
|
||||
**Returns**: The current title if getting, or None if setting.
|
||||
|
||||
|
||||
### size <sub>accessor</sub>
|
||||
|
||||
Get or set the window's size as [width, height].
|
||||
|
||||
|
||||
|
||||
**newSize**: (when setting) e.g. [640, 480]
|
||||
|
||||
|
||||
**Returns**: The current [width, height] or None if setting.
|
||||
|
||||
|
||||
### mouse_grab(flag) <sub>function</sub>
|
||||
|
||||
Grab or ungrab the mouse for this window (so the pointer won't leave).
|
||||
|
||||
|
||||
|
||||
**flag**: True to grab mouse input, false to release.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
# datastream
|
||||
|
||||
A streaming media handle, typically for MPEG video. Freed automatically.
|
||||
|
||||
|
||||
### time() <sub>function</sub>
|
||||
|
||||
Return the current playback time in seconds.
|
||||
|
||||
|
||||
|
||||
**Returns**: Current time as a float in seconds.
|
||||
|
||||
|
||||
### seek(seconds) <sub>function</sub>
|
||||
|
||||
Seek to the specified time (in seconds).
|
||||
|
||||
|
||||
|
||||
**seconds**: The time to jump to in the stream.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### advance(seconds) <sub>function</sub>
|
||||
|
||||
Advance by a certain number of seconds, decoding video as needed.
|
||||
|
||||
|
||||
|
||||
**seconds**: The amount of time to skip forward.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### duration() <sub>function</sub>
|
||||
|
||||
Return the total duration of the video stream, in seconds, if known.
|
||||
|
||||
|
||||
|
||||
**Returns**: Float seconds duration, or 0 if unknown.
|
||||
|
||||
|
||||
### framerate() <sub>function</sub>
|
||||
|
||||
Return the framerate (FPS) of the stream if known.
|
||||
|
||||
|
||||
|
||||
**Returns**: Float frames per second, or 0 if unknown.
|
||||
|
||||
|
||||
### callback <sub>accessor</sub>
|
||||
|
||||
A function to call whenever a new frame is decoded. If not set, no callback is invoked.
|
||||
|
||||
|
||||
|
||||
**fn**: (when setting) A function that receives (surface).
|
||||
|
||||
|
||||
**Returns**: The existing function or undefined if none.
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
# enet_host
|
||||
|
||||
### service(callback, timeout) <sub>function</sub>
|
||||
|
||||
|
||||
Poll for and process any available network events (connect, receive, disconnect, or none)
|
||||
from this host, calling the provided callback for each event. This function loops until
|
||||
no more events are available in the current timeframe.
|
||||
|
||||
Event object properties:
|
||||
- type: String, one of "connect", "receive", "disconnect", or "none".
|
||||
- peer: (present if type = "connect") The ENetPeer object for the new connection.
|
||||
- channelID: (present if type = "receive") The channel on which the data was received.
|
||||
- data: (present if type = "receive") The received data as a *plain JavaScript object*.
|
||||
If the JSON parse fails or the data isn't an object, a JavaScript error is thrown.
|
||||
|
||||
object as its single argument.
|
||||
|
||||
|
||||
**callback**: A function called once for each available event, receiving an event
|
||||
|
||||
**timeout**: (optional) Timeout in milliseconds. Defaults to 0 (non-blocking).
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### connect(host, port) <sub>function</sub>
|
||||
|
||||
|
||||
Initiate a connection from this host to a remote server. Throws an error if the
|
||||
connection cannot be started.
|
||||
|
||||
|
||||
|
||||
**host**: The hostname or IP address of the remote server (e.g. "example.com" or "127.0.0.1").
|
||||
|
||||
**port**: The port number to connect to.
|
||||
|
||||
|
||||
**Returns**: An ENetPeer object representing the connection.
|
||||
|
||||
|
||||
### flush() <sub>function</sub>
|
||||
|
||||
|
||||
Flush all pending outgoing packets for this host immediately.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### broadcast(data) <sub>function</sub>
|
||||
|
||||
|
||||
Broadcast a JavaScript object to all connected peers on channel 0. The object is
|
||||
serialized to JSON, and the packet is sent reliably. Throws an error if serialization fails.
|
||||
|
||||
|
||||
|
||||
**data**: A JavaScript object to broadcast to all peers.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
# enet_peer
|
||||
|
||||
### send(data) <sub>function</sub>
|
||||
|
||||
|
||||
Send a JavaScript object to this peer on channel 0. The object is serialized to JSON and
|
||||
sent reliably. Throws an error if serialization fails.
|
||||
|
||||
|
||||
|
||||
**data**: A JavaScript object to send.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### disconnect() <sub>function</sub>
|
||||
|
||||
|
||||
Request a graceful disconnection from this peer. The connection will close after
|
||||
pending data is sent.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### disconnect_now() <sub>function</sub>
|
||||
|
||||
|
||||
Immediately terminate the connection to this peer, discarding any pending data.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### disconnect_later() <sub>function</sub>
|
||||
|
||||
|
||||
Request a disconnection from this peer after all queued packets are sent.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### reset() <sub>function</sub>
|
||||
|
||||
|
||||
Reset this peer's connection, immediately dropping it and clearing its internal state.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### ping() <sub>function</sub>
|
||||
|
||||
|
||||
Send a ping request to this peer to measure latency.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### throttle_configure(interval, acceleration, deceleration) <sub>function</sub>
|
||||
|
||||
|
||||
Configure the throttling behavior for this peer, controlling how ENet adjusts its sending
|
||||
rate based on packet loss or congestion.
|
||||
|
||||
|
||||
|
||||
**interval**: The interval (ms) between throttle adjustments.
|
||||
|
||||
**acceleration**: The factor to increase sending speed when conditions improve.
|
||||
|
||||
**deceleration**: The factor to decrease sending speed when conditions worsen.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### timeout(timeout_limit, timeout_min, timeout_max) <sub>function</sub>
|
||||
|
||||
|
||||
Set timeout parameters for this peer, determining how long ENet waits before considering
|
||||
the connection lost.
|
||||
|
||||
|
||||
|
||||
**timeout_limit**: The total time (ms) before the peer is disconnected.
|
||||
|
||||
**timeout_min**: The minimum timeout (ms) used for each timeout attempt.
|
||||
|
||||
**timeout_max**: The maximum timeout (ms) used for each timeout attempt.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
# font
|
||||
|
||||
A bitmap or TTF-based font object storing glyph data.
|
||||
Used for measuring/drawing text. Freed when GC sees no references.
|
||||
|
||||
|
||||
### linegap <sub>accessor</sub>
|
||||
|
||||
Get or set the font's additional line spacing above the built-in metrics.
|
||||
|
||||
|
||||
|
||||
**value**: (when setting) The new line gap.
|
||||
|
||||
|
||||
**Returns**: The current line gap (when getting), or None (when setting).
|
||||
|
||||
|
||||
### height <sub>accessor</sub>
|
||||
|
||||
(read only)
|
||||
|
||||
The baseline-to-baseline height in pixels.
|
||||
|
||||
|
||||
|
||||
**Returns**: The font's total height in px.
|
||||
|
||||
|
||||
### ascent <sub>accessor</sub>
|
||||
|
||||
(read only)
|
||||
|
||||
How far above the baseline the font extends.
|
||||
|
||||
|
||||
|
||||
**Returns**: A scalar float for ascent.
|
||||
|
||||
|
||||
### descent <sub>accessor</sub>
|
||||
|
||||
(read only)
|
||||
|
||||
How far below baseline the font extends.
|
||||
|
||||
|
||||
|
||||
**Returns**: A scalar float for descent.
|
||||
|
||||
|
||||
### text_size(text, letterSpacing, wrap) <sub>function</sub>
|
||||
|
||||
Measure a piece of text's width/height when rendered with this font.
|
||||
|
||||
|
||||
|
||||
**text**: The string to measure.
|
||||
|
||||
**letterSpacing**: Extra spacing between characters.
|
||||
|
||||
**wrap**: If nonzero, word-wrap to this maximum width.
|
||||
|
||||
|
||||
**Returns**: [width, height] as a float array.
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
# rtree
|
||||
|
||||
An R-tree for spatial lookups. Insert bounding boxes, query by bounding box, etc.
|
||||
|
||||
|
||||
### add(obj) <sub>function</sub>
|
||||
|
||||
Insert an object that has a 'rect' property {x, y, w, h} into the tree.
|
||||
|
||||
|
||||
|
||||
**obj**: The object to add (must have rectAtom).
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### delete(obj) <sub>function</sub>
|
||||
|
||||
Remove an object from the tree. Must match the same rect as used when adding.
|
||||
|
||||
|
||||
|
||||
**obj**: The object to remove.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### query(rect) <sub>function</sub>
|
||||
|
||||
Return an array of objects whose bounding boxes intersect the given rect.
|
||||
|
||||
|
||||
|
||||
**rect**: {x, y, w, h} bounding region to query.
|
||||
|
||||
|
||||
**Returns**: Array of objects that overlap that region.
|
||||
|
||||
|
||||
### size <sub>accessor</sub>
|
||||
|
||||
(read only)
|
||||
|
||||
Indicates how many items are stored in the rtree.
|
||||
|
||||
|
||||
|
||||
**Returns**: Integer count of items in the tree.
|
||||
|
||||
|
||||
### forEach(callback) <sub>function</sub>
|
||||
|
||||
Call a function for every item in the rtree.
|
||||
|
||||
|
||||
|
||||
**callback**: A function called with no arguments, or possibly (item).
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### has(obj) <sub>function</sub>
|
||||
|
||||
Return true if the specified object is in the tree, false otherwise.
|
||||
|
||||
|
||||
|
||||
**obj**: The object to check.
|
||||
|
||||
|
||||
**Returns**: True if found, else false.
|
||||
|
||||
|
||||
### values() <sub>function</sub>
|
||||
|
||||
Return an array of all items currently in the rtree.
|
||||
|
||||
|
||||
|
||||
**Returns**: Array of all stored objects.
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
# sprite
|
||||
|
||||
A 'sprite' is a simple struct for 2D drawing. It stores a rectangle (pos + size),
|
||||
UV coordinates, color, and layer, as well as an associated 'image' object. The sprite
|
||||
can be drawn via GPU or SDL_Renderer. Freed when no JS references remain.
|
||||
|
||||
|
||||
### set_affine(transform) <sub>function</sub>
|
||||
|
||||
Update this sprite's position and size from a transform's pos and scale.
|
||||
|
||||
|
||||
|
||||
**transform**: The transform whose pos/scale will overwrite the sprite's rect.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### set_rect(rect) <sub>function</sub>
|
||||
|
||||
Set the sprite's rect (x, y, w, h) directly.
|
||||
|
||||
|
||||
|
||||
**rect**: An object or array specifying x, y, width, and height.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### set_image(image) <sub>function</sub>
|
||||
|
||||
Assign or replace the sprite's underlying image. Automatically updates UV if
|
||||
the image has a 'rect' property.
|
||||
|
||||
|
||||
|
||||
**image**: A JS object representing the image (with .texture, .rect, etc.).
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### layer <sub>accessor</sub>
|
||||
|
||||
Get or set the sprite's z-layer integer. Sprites with higher layers typically
|
||||
draw on top of lower layers.
|
||||
|
||||
|
||||
|
||||
**value**: (when setting) An integer specifying the layer.
|
||||
|
||||
|
||||
**Returns**: The current layer (when getting), or None (when setting).
|
||||
|
||||
|
||||
### color <sub>accessor</sub>
|
||||
|
||||
Get or set the sprite's color tint as [r, g, b, a].
|
||||
|
||||
|
||||
|
||||
**value**: (when setting) An array [r, g, b, a] in the 0.0..1.0 range.
|
||||
|
||||
|
||||
**Returns**: The current color array (when getting), or None (when setting).
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
# timer
|
||||
|
||||
A scheduled callback or countdown. Freed automatically once no longer referenced
|
||||
or once it completes.
|
||||
|
||||
|
||||
### remain <sub>accessor</sub>
|
||||
|
||||
Get or set how many seconds remain before the timer triggers.
|
||||
|
||||
|
||||
|
||||
**value**: (when setting) A float specifying new time remaining.
|
||||
|
||||
|
||||
**Returns**: The current time left (when getting), or None (when setting).
|
||||
|
||||
|
||||
### fn <sub>accessor</sub>
|
||||
|
||||
Get or set the function called when the timer expires.
|
||||
|
||||
|
||||
|
||||
**value**: (when setting) The function.
|
||||
|
||||
|
||||
**Returns**: The function or undefined if none is set.
|
||||
|
||||
@@ -1,214 +0,0 @@
|
||||
# transform
|
||||
|
||||
A hierarchical transform storing 3D or 2D position, rotation (as a quaternion),
|
||||
and scale. Can have a parent transform. Freed automatically on GC.
|
||||
|
||||
|
||||
### pos <sub>accessor</sub>
|
||||
|
||||
Get or set the transform's position as a 3D vector [x, y, z].
|
||||
|
||||
|
||||
|
||||
**value**: (when setting) [x, y, z].
|
||||
|
||||
|
||||
**Returns**: The current position vector (when getting), or None (when setting).
|
||||
|
||||
|
||||
### scale <sub>accessor</sub>
|
||||
|
||||
Get or set the transform's scale as a 3D vector [x, y, z].
|
||||
For 2D usage, z is often 1.
|
||||
|
||||
|
||||
|
||||
**value**: (when setting) [sx, sy, sz].
|
||||
|
||||
|
||||
**Returns**: The current scale (when getting), or None (when setting).
|
||||
|
||||
|
||||
### rotation <sub>accessor</sub>
|
||||
|
||||
Get or set the transform's rotation as a quaternion [x, y, z, w].
|
||||
Angles in degrees or radians must first be converted prior to making a quaternion.
|
||||
|
||||
|
||||
|
||||
**value**: (when setting) [qx, qy, qz, qw].
|
||||
|
||||
|
||||
**Returns**: The current quaternion (when getting), or None (when setting).
|
||||
|
||||
|
||||
### parent <sub>accessor</sub>
|
||||
|
||||
Get or set the transform's parent. If set, this transform becomes a child of
|
||||
the parent (re-parenting). Must be another transform object or undefined.
|
||||
|
||||
|
||||
|
||||
**value**: (when setting) Another transform or undefined.
|
||||
|
||||
|
||||
**Returns**: The current parent transform (when getting), or None (when setting).
|
||||
|
||||
|
||||
### change_hook <sub>accessor</sub>
|
||||
|
||||
A user-supplied function that's called whenever the transform's local matrix changes.
|
||||
If undefined, no hook is called.
|
||||
|
||||
|
||||
|
||||
**value**: (when setting) A function.
|
||||
|
||||
|
||||
**Returns**: The current function or undefined.
|
||||
|
||||
|
||||
### trs(pos, quat, scale) <sub>function</sub>
|
||||
|
||||
Set the transform's position, rotation, and scale in one call.
|
||||
|
||||
|
||||
|
||||
**pos**: [x,y,z] for position, or undefined to keep existing.
|
||||
|
||||
**quat**: [qx,qy,qz,qw] for rotation, or undefined.
|
||||
|
||||
**scale**: [sx,sy,sz] for scale, or undefined.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### phys2d(velocity, angularVel, dt) <sub>function</sub>
|
||||
|
||||
Apply simple 2D velocity and angular velocity to this transform.
|
||||
|
||||
|
||||
|
||||
**velocity**: [vx, vy] added to 'pos' each frame.
|
||||
|
||||
**angularVel**: A scalar for rotation in (radians/second).
|
||||
|
||||
**dt**: The time delta in seconds.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### move(delta) <sub>function</sub>
|
||||
|
||||
Translate this transform by the specified vector.
|
||||
|
||||
|
||||
|
||||
**delta**: [dx, dy, dz] to add to .pos
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### rotate(axis, angle) <sub>function</sub>
|
||||
|
||||
Rotate this transform by an axis+angle.
|
||||
|
||||
|
||||
|
||||
**axis**: [ax, ay, az] the axis of rotation.
|
||||
|
||||
**angle**: The angle in turns or radians (depending on usage).
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### angle(axis) <sub>function</sub>
|
||||
|
||||
Return the transform's rotation about a specified axis (x, y, or z).
|
||||
For example, angle([1,0,0]) returns the roll about the X-axis.
|
||||
|
||||
|
||||
|
||||
**axis**: Which axis [1,0,0] or [0,1,0] or [0,0,1].
|
||||
|
||||
|
||||
**Returns**: The numeric angle in 'turns' or radians, depending on usage.
|
||||
|
||||
|
||||
### lookat(target) <sub>function</sub>
|
||||
|
||||
Rotate this transform so it looks toward the given world position.
|
||||
|
||||
|
||||
|
||||
**target**: [x, y, z] position in world coords.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### direction(localDir) <sub>function</sub>
|
||||
|
||||
Rotate a vector by this transform's rotation, effectively "transforming"
|
||||
a direction from local space to world space.
|
||||
|
||||
|
||||
|
||||
**localDir**: [dx, dy, dz] in local transform coordinates.
|
||||
|
||||
|
||||
**Returns**: [dx', dy', dz'] direction in world space.
|
||||
|
||||
|
||||
### unit() <sub>function</sub>
|
||||
|
||||
Reset position, rotation, and scale to [0,0,0], identity rotation, and [1,1,1].
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### rect(rect) <sub>function</sub>
|
||||
|
||||
Set this transform's pos and scale from a 2D rect object {x, y, w, h}.
|
||||
|
||||
|
||||
|
||||
**rect**: Object with .x, .y, .w, .h
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### array() <sub>function</sub>
|
||||
|
||||
Return this transform's matrix as a 16-element float array in column-major order.
|
||||
|
||||
|
||||
|
||||
**Returns**: An array of 16 floats.
|
||||
|
||||
|
||||
### torect() <sub>function</sub>
|
||||
|
||||
Convert transform's 2D position/scale to a rect {x, y, w, h}.
|
||||
Rotation is currently ignored.
|
||||
|
||||
|
||||
|
||||
**Returns**: A rect object {x, y, w, h}.
|
||||
|
||||
|
||||
### children() <sub>function</sub>
|
||||
|
||||
Return an array of child transforms belonging to this transform.
|
||||
|
||||
|
||||
|
||||
**Returns**: An array of transform objects.
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
# use
|
||||
|
||||
### length <sub>number</sub>
|
||||
|
||||
### name <sub>string</sub>
|
||||
|
||||
### prototype <sub>object</sub>
|
||||
@@ -1,6 +1,6 @@
|
||||
# Cell Language
|
||||
|
||||
Cell is a JavaScript variant used in the Prosperon game engine. While very similar to JavaScript, it has several important differences that make it more suitable for game development and actor-based programming.
|
||||
Cell is a JavaScript variant used in cell. While very similar to JavaScript, it has several important differences that make it more suitable for actor-based programming.
|
||||
|
||||
## Key Differences from JavaScript
|
||||
|
||||
@@ -173,8 +173,3 @@ var text = time.text() // Human-readable time
|
||||
setTimeout(() => console.log(i), 100) // Works as expected
|
||||
}
|
||||
```
|
||||
|
||||
## See Also
|
||||
- [Actor Model](actor.md) - Cell's actor-based programming model
|
||||
- [Module System](modules.md) - How to use and create modules
|
||||
- [API Reference](api/index.md) - Complete API documentation
|
||||
BIN
docs/dos.ttf
BIN
docs/dos.ttf
Binary file not shown.
@@ -1,661 +0,0 @@
|
||||
# Array
|
||||
|
||||
### length <sub>number</sub>
|
||||
|
||||
### at(index) <sub>function</sub>
|
||||
|
||||
Return the item at index 'index', supporting negative indices to count from
|
||||
the end. If 'index' is out of range, returns undefined.
|
||||
|
||||
|
||||
|
||||
**index**: The index of the element to return (can be negative).
|
||||
|
||||
|
||||
**Returns**: The element at the given index, or undefined.
|
||||
|
||||
|
||||
### with(index, value) <sub>function</sub>
|
||||
|
||||
Return a shallow copy of the array, but with the element at 'index' replaced
|
||||
by 'value'. If 'index' is negative, it counts from the end. Throws if out of range.
|
||||
|
||||
|
||||
|
||||
**index**: The zero-based index (can be negative) to replace.
|
||||
|
||||
**value**: The new value for the specified position.
|
||||
|
||||
|
||||
**Returns**: A new array with the updated element.
|
||||
|
||||
|
||||
### concat(items) <sub>function</sub>
|
||||
|
||||
Return a new array that is the result of concatenating this array with
|
||||
any additional arrays or values provided.
|
||||
|
||||
|
||||
|
||||
**items**: One or more arrays or values to concatenate.
|
||||
|
||||
|
||||
**Returns**: A new array with the items appended.
|
||||
|
||||
|
||||
### every(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Return true if the provided callback function returns a truthy value for
|
||||
every element in the array; otherwise false.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => boolean.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: True if all elements pass the test, otherwise false.
|
||||
|
||||
|
||||
### some(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Return true if the provided callback function returns a truthy value for at
|
||||
least one element in the array; otherwise false.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => boolean.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: True if at least one element passes the test, otherwise false.
|
||||
|
||||
|
||||
### forEach(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Call the provided callback function once for each element in the array.
|
||||
Does not produce a return value.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array).
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### map(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Create a new array with the results of calling a provided callback function
|
||||
on every element in this array.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => newElement.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: A new array of transformed elements.
|
||||
|
||||
|
||||
### filter(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Create a new array containing all elements for which the provided callback
|
||||
function returns a truthy value.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => boolean.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: A new array of elements that passed the test.
|
||||
|
||||
|
||||
### reduce(callback, initialValue) <sub>function</sub>
|
||||
|
||||
Apply a callback function against an accumulator and each element in the
|
||||
array (from left to right) to reduce it to a single value.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(accumulator, element, index, array) => newAccumulator.
|
||||
|
||||
**initialValue**: Optional. The initial value for the accumulator.
|
||||
|
||||
|
||||
**Returns**: The single resulting value.
|
||||
|
||||
|
||||
### reduceRight(callback, initialValue) <sub>function</sub>
|
||||
|
||||
Similar to reduce(), except it processes elements from right to left.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(accumulator, element, index, array) => newAccumulator.
|
||||
|
||||
**initialValue**: Optional. The initial value for the accumulator.
|
||||
|
||||
|
||||
**Returns**: The single resulting value.
|
||||
|
||||
|
||||
### fill(value, start, end) <sub>function</sub>
|
||||
|
||||
Fill the array with a static value from 'start' index up to (but not including)
|
||||
'end' index. Modifies the original array.
|
||||
|
||||
|
||||
|
||||
**value**: The value to fill.
|
||||
|
||||
**start**: The starting index (default 0).
|
||||
|
||||
**end**: The ending index (default array.length).
|
||||
|
||||
|
||||
**Returns**: The modified array (with filled values).
|
||||
|
||||
|
||||
### find(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Return the first element in the array that satisfies the provided callback
|
||||
function. If none is found, return undefined.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => boolean.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: The first matching element, or undefined if not found.
|
||||
|
||||
|
||||
### findIndex(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Return the index of the first element in the array that satisfies the
|
||||
provided callback function. If none is found, return -1.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => boolean.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: The index of the first matching element, or -1 if not found.
|
||||
|
||||
|
||||
### findLast(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Return the last element in the array that satisfies the provided callback
|
||||
function, searching from right to left. If none is found, return undefined.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => boolean.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: The last matching element, or undefined if not found.
|
||||
|
||||
|
||||
### findLastIndex(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Return the index of the last element in the array that satisfies the
|
||||
provided callback function, searching from right to left. If none is found,
|
||||
return -1.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => boolean.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: The index of the last matching element, or -1 if not found.
|
||||
|
||||
|
||||
### indexOf(searchElement, fromIndex) <sub>function</sub>
|
||||
|
||||
Return the first index at which a given element can be found. If not present,
|
||||
return -1.
|
||||
|
||||
|
||||
|
||||
**searchElement**: The item to locate in the array.
|
||||
|
||||
**fromIndex**: The index at which to start searching (default 0).
|
||||
|
||||
|
||||
**Returns**: The index of the found element, or -1 if not found.
|
||||
|
||||
|
||||
### lastIndexOf(searchElement, fromIndex) <sub>function</sub>
|
||||
|
||||
Return the last index at which a given element can be found, or -1 if not
|
||||
present. Searches backward from 'fromIndex'.
|
||||
|
||||
|
||||
|
||||
**searchElement**: The item to locate in the array.
|
||||
|
||||
**fromIndex**: The index at which to start searching backward (default array.length - 1).
|
||||
|
||||
|
||||
**Returns**: The last index of the found element, or -1 if not found.
|
||||
|
||||
|
||||
### includes(searchElement, fromIndex) <sub>function</sub>
|
||||
|
||||
Return a boolean indicating whether the array contains the given element,
|
||||
comparing elements using the SameValueZero algorithm.
|
||||
|
||||
|
||||
|
||||
**searchElement**: The value to search for.
|
||||
|
||||
**fromIndex**: The position in the array to start searching (default 0).
|
||||
|
||||
|
||||
**Returns**: True if the element is found, otherwise false.
|
||||
|
||||
|
||||
### join(separator) <sub>function</sub>
|
||||
|
||||
Join all elements of the array into a string, separated by 'separator'.
|
||||
|
||||
|
||||
|
||||
**separator**: The delimiter string to separate elements (default ',').
|
||||
|
||||
|
||||
**Returns**: A string of array elements joined by the separator.
|
||||
|
||||
|
||||
### toString() <sub>function</sub>
|
||||
|
||||
Return a string representing the elements of the array, separated by commas.
|
||||
Overrides Object.prototype.toString.
|
||||
|
||||
|
||||
|
||||
**Returns**: A comma-separated string of array elements.
|
||||
|
||||
|
||||
### toLocaleString() <sub>function</sub>
|
||||
|
||||
Return a localized string representing the array and its elements, calling
|
||||
each element's toLocaleString if available.
|
||||
|
||||
|
||||
|
||||
**Returns**: A locale-sensitive, comma-separated string of array elements.
|
||||
|
||||
|
||||
### pop() <sub>function</sub>
|
||||
|
||||
Remove the last element from the array and return it. This changes the length
|
||||
of the array.
|
||||
|
||||
|
||||
|
||||
**Returns**: The removed element, or undefined if the array is empty.
|
||||
|
||||
|
||||
### push(items) <sub>function</sub>
|
||||
|
||||
Append one or more elements to the end of the array and return the new length
|
||||
of the array.
|
||||
|
||||
|
||||
|
||||
**items**: One or more items to append.
|
||||
|
||||
|
||||
**Returns**: The new length of the array.
|
||||
|
||||
|
||||
### shift() <sub>function</sub>
|
||||
|
||||
Remove the first element from the array and return it. This changes the length
|
||||
of the array.
|
||||
|
||||
|
||||
|
||||
**Returns**: The removed element, or undefined if the array is empty.
|
||||
|
||||
|
||||
### unshift(items) <sub>function</sub>
|
||||
|
||||
Insert one or more elements at the start of the array and return the new
|
||||
length of the array.
|
||||
|
||||
|
||||
|
||||
**items**: One or more elements to insert at the start.
|
||||
|
||||
|
||||
**Returns**: The new length of the array.
|
||||
|
||||
|
||||
### reverse() <sub>function</sub>
|
||||
|
||||
Reverse the elements of the array in place and return the modified array.
|
||||
|
||||
|
||||
|
||||
**Returns**: The reversed array.
|
||||
|
||||
|
||||
### toReversed() <sub>function</sub>
|
||||
|
||||
Return a shallow copy of the array in reverse order, without modifying the original array.
|
||||
|
||||
|
||||
|
||||
**Returns**: A new reversed array.
|
||||
|
||||
|
||||
### sort(compareFunction) <sub>function</sub>
|
||||
|
||||
Sort the array in place, returning it. By default, sorts elements as strings in ascending order. An optional compareFunction may be used for custom sorting.
|
||||
|
||||
|
||||
|
||||
**compareFunction**: A function(a, b) => number, defining sort order.
|
||||
|
||||
|
||||
**Returns**: The sorted array.
|
||||
|
||||
|
||||
### toSorted(compareFunction) <sub>function</sub>
|
||||
|
||||
Return a shallow copy of the array, sorted according to the optional compare
|
||||
function, without modifying the original array.
|
||||
|
||||
|
||||
|
||||
**compareFunction**: A function(a, b) => number, defining sort order.
|
||||
|
||||
|
||||
**Returns**: A new sorted array.
|
||||
|
||||
|
||||
### slice(start, end) <sub>function</sub>
|
||||
|
||||
Return a shallow copy of a portion of the array into a new array object, selected from 'start' to 'end' (end not included).
|
||||
|
||||
|
||||
|
||||
**start**: The beginning index (0-based). Negative values count from the end.
|
||||
|
||||
**end**: The end index (exclusive). Negative values count from the end.
|
||||
|
||||
|
||||
**Returns**: A new array containing the extracted elements.
|
||||
|
||||
|
||||
### splice(start, deleteCount, items) <sub>function</sub>
|
||||
|
||||
Change the contents of the array by removing or replacing existing elements and/or adding new elements in place. Returns an array of removed elements.
|
||||
|
||||
|
||||
|
||||
**start**: The index at which to start changing the array.
|
||||
|
||||
**deleteCount**: Number of elements to remove.
|
||||
|
||||
**items**: Elements to add in place of the removed elements.
|
||||
|
||||
|
||||
**Returns**: An array containing the removed elements (if any).
|
||||
|
||||
|
||||
### toSpliced(start, deleteCount, items) <sub>function</sub>
|
||||
|
||||
Return a shallow copy of the array, with a splice-like operation applied at 'start' removing 'deleteCount' elements and adding 'items'. Does not mutate the original array.
|
||||
|
||||
|
||||
|
||||
**start**: The index at which to start the splice operation.
|
||||
|
||||
**deleteCount**: Number of elements to remove.
|
||||
|
||||
**items**: Elements to add in place of the removed elements.
|
||||
|
||||
|
||||
**Returns**: A new array with the splice applied.
|
||||
|
||||
|
||||
### copyWithin(target, start, end) <sub>function</sub>
|
||||
|
||||
Copy a sequence of array elements within the array, overwriting existing values. This operation is performed in place and returns the modified array.
|
||||
|
||||
|
||||
|
||||
**target**: The index at which to copy the sequence to.
|
||||
|
||||
**start**: The beginning index of the sequence to copy.
|
||||
|
||||
**end**: The end index (exclusive) of the sequence to copy (default array.length).
|
||||
|
||||
|
||||
**Returns**: The modified array.
|
||||
|
||||
|
||||
### flatMap(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Return a new array formed by applying a callback function to each element and then flattening the result by one level.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => array or value.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: A new array with the flattened results.
|
||||
|
||||
|
||||
### flat(depth) <sub>function</sub>
|
||||
|
||||
Return a new array with all sub-array elements concatenated into it recursively up to the specified depth.
|
||||
|
||||
|
||||
|
||||
**depth**: The maximum depth to flatten (default 1).
|
||||
|
||||
|
||||
**Returns**: A new flattened array.
|
||||
|
||||
|
||||
### values() <sub>function</sub>
|
||||
|
||||
Return a new Array Iterator object that contains the values for each index in the array.
|
||||
|
||||
|
||||
|
||||
**Returns**: An iterator over the array's elements.
|
||||
|
||||
|
||||
### keys() <sub>function</sub>
|
||||
|
||||
Return a new Array Iterator object that contains the keys (indexes) for each index in the array.
|
||||
|
||||
|
||||
|
||||
**Returns**: An iterator over the array's indices.
|
||||
|
||||
|
||||
### entries() <sub>function</sub>
|
||||
|
||||
Return a new Array Iterator object that contains key/value pairs for each index in the array. Each entry is [index, value].
|
||||
|
||||
|
||||
|
||||
**Returns**: An iterator over [index, value] pairs.
|
||||
|
||||
|
||||
### add(other) <sub>function</sub>
|
||||
|
||||
Non-standard. Add corresponding elements of the current array and 'other' element-wise, returning a new array. Behavior depends on data types.
|
||||
|
||||
|
||||
|
||||
**other**: Another array or scalar to add to each element.
|
||||
|
||||
|
||||
**Returns**: A new array with element-wise sum results.
|
||||
|
||||
|
||||
### sub(other) <sub>function</sub>
|
||||
|
||||
Non-standard. Subtract corresponding elements of 'other' from the current array element-wise, returning a new array. Behavior depends on data types.
|
||||
|
||||
|
||||
|
||||
**other**: Another array or scalar to subtract from each element.
|
||||
|
||||
|
||||
**Returns**: A new array with element-wise difference results.
|
||||
|
||||
|
||||
### div(other) <sub>function</sub>
|
||||
|
||||
Non-standard. Divide each element of the current array by the corresponding element of 'other' (or a scalar) element-wise, returning a new array. Behavior depends on data types.
|
||||
|
||||
|
||||
|
||||
**other**: Another array or scalar for the division.
|
||||
|
||||
|
||||
**Returns**: A new array with element-wise division results.
|
||||
|
||||
|
||||
### scale() <sub>function</sub>
|
||||
|
||||
### lerp() <sub>function</sub>
|
||||
|
||||
### x <sub>accessor</sub>
|
||||
|
||||
### y <sub>accessor</sub>
|
||||
|
||||
### xy <sub>accessor</sub>
|
||||
|
||||
### r <sub>accessor</sub>
|
||||
|
||||
### g <sub>accessor</sub>
|
||||
|
||||
### b <sub>accessor</sub>
|
||||
|
||||
### a <sub>accessor</sub>
|
||||
|
||||
### rgb <sub>accessor</sub>
|
||||
|
||||
### rgba <sub>accessor</sub>
|
||||
|
||||
### filter!(fn) <sub>function</sub>
|
||||
|
||||
Perform an in-place filter of this array using the provided callback 'fn'.
|
||||
Any element for which 'fn' returns a falsy value is removed. The array is modified
|
||||
and then returned.
|
||||
|
||||
|
||||
|
||||
**fn**: A callback function(element, index, array) => boolean.
|
||||
|
||||
|
||||
**Returns**: The filtered (modified) array.
|
||||
|
||||
|
||||
### delete(item) <sub>function</sub>
|
||||
|
||||
Remove the first occurrence of 'item' from the array, if it exists.
|
||||
Returns undefined.
|
||||
|
||||
|
||||
|
||||
**item**: The item to remove.
|
||||
|
||||
|
||||
**Returns**: undefined
|
||||
|
||||
|
||||
### copy() <sub>function</sub>
|
||||
|
||||
Return a deep copy of this array by applying 'deep_copy' to each element.
|
||||
The resulting array is entirely new.
|
||||
|
||||
|
||||
|
||||
**Returns**: A new array that is a deep copy of the original.
|
||||
|
||||
|
||||
### equal(b) <sub>function</sub>
|
||||
|
||||
Check if this array and array 'b' have the same elements in the same order.
|
||||
If they are of different lengths, return false. Otherwise compare them via JSON.
|
||||
|
||||
|
||||
|
||||
**b**: Another array to compare against.
|
||||
|
||||
|
||||
**Returns**: True if they match, false otherwise.
|
||||
|
||||
|
||||
### last() <sub>function</sub>
|
||||
|
||||
Return the last element of this array. If the array is empty, returns undefined.
|
||||
|
||||
|
||||
|
||||
**Returns**: The last element of the array, or undefined if empty.
|
||||
|
||||
|
||||
### wrapped(x) <sub>function</sub>
|
||||
|
||||
Return a copy of the array with the first 'x' elements appended to the end.
|
||||
Does not modify the original array.
|
||||
|
||||
|
||||
|
||||
**x**: The number of leading elements to re-append.
|
||||
|
||||
|
||||
**Returns**: A new array with the leading elements wrapped to the end.
|
||||
|
||||
|
||||
### wrap_idx(x) <sub>function</sub>
|
||||
|
||||
Wrap the integer 'x' around this array's length, ensuring the resulting index
|
||||
lies within [0, this.length - 1].
|
||||
|
||||
|
||||
|
||||
**x**: The index to wrap.
|
||||
|
||||
|
||||
**Returns**: A wrapped index within this array's bounds.
|
||||
|
||||
|
||||
### mirrored(x) <sub>function</sub>
|
||||
|
||||
Return a new array that appends a reversed copy (excluding the last element)
|
||||
of itself to the end. For example, [1,2,3] -> [1,2,3,2,1]. If the array has length
|
||||
<= 1, a copy of it is returned directly.
|
||||
|
||||
|
||||
|
||||
**Returns**: A new "mirrored" array.
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
# ArrayBuffer
|
||||
|
||||
### byteLength <sub>accessor</sub>
|
||||
|
||||
(read only)
|
||||
|
||||
### slice() <sub>function</sub>
|
||||
@@ -1,27 +0,0 @@
|
||||
# Function
|
||||
|
||||
### length <sub>number</sub>
|
||||
|
||||
### name <sub>string</sub>
|
||||
|
||||
### caller <sub>accessor</sub>
|
||||
|
||||
### arguments <sub>accessor</sub>
|
||||
|
||||
### call() <sub>function</sub>
|
||||
|
||||
### apply() <sub>function</sub>
|
||||
|
||||
### bind() <sub>function</sub>
|
||||
|
||||
### toString() <sub>function</sub>
|
||||
|
||||
### fileName <sub>accessor</sub>
|
||||
|
||||
(read only)
|
||||
|
||||
### lineNumber <sub>accessor</sub>
|
||||
|
||||
(read only)
|
||||
|
||||
### hashify() <sub>function</sub>
|
||||
120
docs/dull/Map.md
120
docs/dull/Map.md
@@ -1,120 +0,0 @@
|
||||
# Map
|
||||
|
||||
A Map object holds key-value pairs, where any value (both objects and primitive values) may be used as either a key or a value. Insertion order is remembered, which allows iteration in that order.
|
||||
|
||||
### set(key, value) <sub>function</sub>
|
||||
|
||||
Add or update an entry in the Map with the specified key and value.
|
||||
|
||||
|
||||
|
||||
**key**: The key of the element to add or update.
|
||||
|
||||
**value**: The value associated with the key.
|
||||
|
||||
|
||||
**Returns**: The Map object (for chaining).
|
||||
|
||||
|
||||
### get(key) <sub>function</sub>
|
||||
|
||||
Return the value associated with the specified key, or undefined if no
|
||||
such key exists.
|
||||
|
||||
|
||||
|
||||
**key**: The key of the element to retrieve.
|
||||
|
||||
|
||||
**Returns**: The value associated with the key, or undefined if not found.
|
||||
|
||||
|
||||
### has(key) <sub>function</sub>
|
||||
|
||||
Return a boolean indicating whether the Map contains an element with the
|
||||
specified key.
|
||||
|
||||
|
||||
|
||||
**key**: The key to test for presence in the Map.
|
||||
|
||||
|
||||
**Returns**: True if the key is found, otherwise false.
|
||||
|
||||
|
||||
### delete(key) <sub>function</sub>
|
||||
|
||||
Remove the specified key and its associated value from the Map, if it exists.
|
||||
|
||||
|
||||
|
||||
**key**: The key to remove.
|
||||
|
||||
|
||||
**Returns**: True if an element was removed, otherwise false.
|
||||
|
||||
|
||||
### clear() <sub>function</sub>
|
||||
|
||||
Remove all entries from the Map, leaving it empty.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### size <sub>accessor</sub>
|
||||
|
||||
(read only)
|
||||
|
||||
A read-only property returning the number of key-value pairs in the Map.
|
||||
|
||||
|
||||
|
||||
**Returns**: The number of entries in the Map.
|
||||
|
||||
|
||||
### forEach(callbackFn, thisArg) <sub>function</sub>
|
||||
|
||||
Execute a provided callback function once per each key-value pair in the Map,
|
||||
in insertion order.
|
||||
|
||||
|
||||
|
||||
**callbackFn**: A function(value, key, map) to execute on each entry.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' when executing callbackFn.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### values() <sub>function</sub>
|
||||
|
||||
Return a new Iterator object that contains the values for each element
|
||||
in the Map, in insertion order.
|
||||
|
||||
|
||||
|
||||
**Returns**: An iterator of the Map's values.
|
||||
|
||||
|
||||
### keys() <sub>function</sub>
|
||||
|
||||
Return a new Iterator object that contains the keys for each element in
|
||||
the Map, in insertion order.
|
||||
|
||||
|
||||
|
||||
**Returns**: An iterator of the Map's keys.
|
||||
|
||||
|
||||
### entries() <sub>function</sub>
|
||||
|
||||
Return a new Iterator object that contains the [key, value] pairs for
|
||||
each element in the Map, in insertion order.
|
||||
|
||||
|
||||
|
||||
**Returns**: An iterator of [key, value] pairs.
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
# Object
|
||||
|
||||
### toString() <sub>function</sub>
|
||||
|
||||
Return a string representing this object. By default, it returns a string of the form '[object <className>]', where <className> is the object's class.
|
||||
|
||||
|
||||
|
||||
**Returns**: A string that describes the object.
|
||||
|
||||
|
||||
### toLocaleString() <sub>function</sub>
|
||||
|
||||
Return a localized string representation of this object, calling toString() by default or a locale-specific override if defined.
|
||||
|
||||
|
||||
|
||||
**Returns**: A locale-sensitive string representation of the object.
|
||||
|
||||
|
||||
### valueOf() <sub>function</sub>
|
||||
|
||||
Return the primitive value of this object if one exists. Typically, an object returns itself, while a wrapped type (e.g. Number, String) may return the underlying primitive value.
|
||||
|
||||
|
||||
|
||||
**Returns**: The primitive value of the object, or the object itself.
|
||||
|
||||
|
||||
### hasOwnProperty(prop) <sub>function</sub>
|
||||
|
||||
Return a boolean indicating whether the object has a property with the specified name (key) as its own direct property, as opposed to inheriting it. It does not check the prototype chain.
|
||||
|
||||
|
||||
|
||||
**prop**: The name or Symbol of the property to test.
|
||||
|
||||
|
||||
**Returns**: True if the property is found directly on the object, otherwise false.
|
||||
|
||||
|
||||
### isPrototypeOf(obj) <sub>function</sub>
|
||||
|
||||
Return true if the object appears anywhere in the prototype chain of the specified object, otherwise false.
|
||||
|
||||
|
||||
|
||||
**obj**: The object whose prototype chain will be checked.
|
||||
|
||||
|
||||
**Returns**: True if this object is in 'obj's prototype chain, otherwise false.
|
||||
|
||||
|
||||
### propertyIsEnumerable(prop) <sub>function</sub>
|
||||
|
||||
Return a boolean indicating whether the specified property is enumerable, i.e., whether it shows up in a for...in loop or Object.keys() on the object.
|
||||
|
||||
|
||||
|
||||
**prop**: The name or Symbol of the property to test.
|
||||
|
||||
|
||||
**Returns**: True if the property is found and enumerable, otherwise false.
|
||||
|
||||
|
||||
### __proto__ <sub>accessor</sub>
|
||||
|
||||
### __defineGetter__() <sub>function</sub>
|
||||
|
||||
### __defineSetter__() <sub>function</sub>
|
||||
|
||||
### __lookupGetter__() <sub>function</sub>
|
||||
|
||||
### __lookupSetter__() <sub>function</sub>
|
||||
|
||||
### mixin(obj) <sub>function</sub>
|
||||
|
||||
Mix properties from 'obj' into the current object. If 'obj' is a string,
|
||||
it first calls 'use(obj)' to retrieve the object.
|
||||
|
||||
|
||||
|
||||
**obj**: The object (or string reference to an object) to mix in.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
104
docs/dull/Set.md
104
docs/dull/Set.md
@@ -1,104 +0,0 @@
|
||||
# Set
|
||||
|
||||
A Set object lets you store unique values of any type, whether primitive values or object references. It remembers insertion order for iteration.
|
||||
|
||||
### add(value) <sub>function</sub>
|
||||
|
||||
Add a new element with the given value to the Set, if it’s not already present.
|
||||
|
||||
|
||||
|
||||
**value**: The value to add.
|
||||
|
||||
|
||||
**Returns**: The Set object (for chaining).
|
||||
|
||||
|
||||
### has(value) <sub>function</sub>
|
||||
|
||||
Return a boolean indicating whether the Set contains the specified value.
|
||||
|
||||
|
||||
|
||||
**value**: The value to check for presence in the Set.
|
||||
|
||||
|
||||
**Returns**: True if the value is found, otherwise false.
|
||||
|
||||
|
||||
### delete(value) <sub>function</sub>
|
||||
|
||||
Remove the specified value from the Set if it exists.
|
||||
|
||||
|
||||
|
||||
**value**: The value to remove.
|
||||
|
||||
|
||||
**Returns**: True if the value was present and removed, otherwise false.
|
||||
|
||||
|
||||
### clear() <sub>function</sub>
|
||||
|
||||
Remove all elements from the Set, leaving it empty.
|
||||
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### size <sub>accessor</sub>
|
||||
|
||||
(read only)
|
||||
|
||||
A read-only property returning the number of elements in the Set.
|
||||
|
||||
|
||||
|
||||
**Returns**: The number of unique values in the Set.
|
||||
|
||||
|
||||
### forEach(callbackFn, thisArg) <sub>function</sub>
|
||||
|
||||
Execute a provided callback function once for each value in the Set,
|
||||
in insertion order.
|
||||
|
||||
|
||||
|
||||
**callbackFn**: A function(value, valueAgain, set) to execute on each element.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' when executing callbackFn.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### values() <sub>function</sub>
|
||||
|
||||
Alias for values() in a Set. Return a new Iterator object containing all
|
||||
the values (as keys) in the Set, in insertion order.
|
||||
|
||||
|
||||
|
||||
**Returns**: An iterator of the Set's values.
|
||||
|
||||
|
||||
### keys() <sub>function</sub>
|
||||
|
||||
Alias for values() in a Set. Return a new Iterator object containing all
|
||||
the values (as keys) in the Set, in insertion order.
|
||||
|
||||
|
||||
|
||||
**Returns**: An iterator of the Set's values.
|
||||
|
||||
|
||||
### entries() <sub>function</sub>
|
||||
|
||||
Return a new Iterator object containing [value, value] pairs for each value
|
||||
in the Set, in insertion order. This maintains API consistency with Map objects.
|
||||
|
||||
|
||||
|
||||
**Returns**: An iterator of [value, value] pairs.
|
||||
|
||||
@@ -1,793 +0,0 @@
|
||||
# String
|
||||
|
||||
### length <sub>number</sub>
|
||||
|
||||
### at(index) <sub>function</sub>
|
||||
|
||||
Return the character (or surrogate pair) at the specified index, with support
|
||||
for negative indices (counting from the end). If the index is out of range,
|
||||
returns undefined.
|
||||
|
||||
|
||||
|
||||
**index**: The position of the character to return (can be negative).
|
||||
|
||||
|
||||
**Returns**: A string of length 1 representing the character, or undefined if out of range.
|
||||
|
||||
|
||||
### charCodeAt(index) <sub>function</sub>
|
||||
|
||||
Return a number indicating the UTF-16 code unit value at the given index.
|
||||
If the index is out of range, returns NaN.
|
||||
|
||||
|
||||
|
||||
**index**: An integer between 0 and string length - 1.
|
||||
|
||||
|
||||
**Returns**: An integer in the range [0, 65535] or NaN if out of range.
|
||||
|
||||
|
||||
### charAt(index) <sub>function</sub>
|
||||
|
||||
Return a string consisting of the single UTF-16 code unit at the given index.
|
||||
If the index is out of range, returns an empty string.
|
||||
|
||||
|
||||
|
||||
**index**: The zero-based index of the desired character.
|
||||
|
||||
|
||||
**Returns**: The single-character string at the specified index, or '' if out of range.
|
||||
|
||||
|
||||
### concat(stringN) <sub>function</sub>
|
||||
|
||||
Concatenate the provided string arguments to the current string and return a
|
||||
new string.
|
||||
|
||||
|
||||
|
||||
**stringN**: One or more strings to concatenate.
|
||||
|
||||
|
||||
**Returns**: A new string formed by joining the caller with the provided arguments.
|
||||
|
||||
|
||||
### codePointAt(position) <sub>function</sub>
|
||||
|
||||
Return a non-negative integer that is the Unicode code point value at the
|
||||
given position. Supports code points above 0xFFFF. Returns undefined if index
|
||||
is out of range.
|
||||
|
||||
|
||||
|
||||
**position**: The index in the string (can be surrogate pairs).
|
||||
|
||||
|
||||
**Returns**: The code point value, or undefined if out of range.
|
||||
|
||||
|
||||
### isWellFormed() <sub>function</sub>
|
||||
|
||||
Return a boolean indicating whether the string is valid Unicode.
|
||||
If it contains unpaired surrogate code points, return false.
|
||||
|
||||
|
||||
|
||||
**Returns**: True if the string is well-formed UTF-16, otherwise false.
|
||||
|
||||
|
||||
### toWellFormed() <sub>function</sub>
|
||||
|
||||
Return a new string in which any unpaired surrogate code points have been
|
||||
replaced by the Unicode replacement character U+FFFD.
|
||||
|
||||
|
||||
|
||||
**Returns**: A well-formed UTF-16 version of the string.
|
||||
|
||||
|
||||
### indexOf(searchValue, fromIndex) <sub>function</sub>
|
||||
|
||||
Return the zero-based index of the first occurrence of 'searchValue' in the
|
||||
string, starting at 'fromIndex'. If not found, return -1.
|
||||
|
||||
|
||||
|
||||
**searchValue**: The substring to search for.
|
||||
|
||||
**fromIndex**: The index at which to begin searching (default 0).
|
||||
|
||||
|
||||
**Returns**: The index of the first match, or -1 if not found.
|
||||
|
||||
|
||||
### lastIndexOf(searchValue, fromIndex) <sub>function</sub>
|
||||
|
||||
Return the zero-based index of the last occurrence of 'searchValue' in the
|
||||
string, searching backwards from 'fromIndex'. If not found, return -1.
|
||||
|
||||
|
||||
|
||||
**searchValue**: The substring to search for.
|
||||
|
||||
**fromIndex**: The index at which to begin the backward search (defaults to string length - 1).
|
||||
|
||||
|
||||
**Returns**: The index of the last match, or -1 if not found.
|
||||
|
||||
|
||||
### includes(searchString, position) <sub>function</sub>
|
||||
|
||||
Return a boolean indicating whether 'searchString' appears within this string.
|
||||
An optional position can be provided to start searching.
|
||||
|
||||
|
||||
|
||||
**searchString**: The substring to search for.
|
||||
|
||||
**position**: The position from which to begin searching (default 0).
|
||||
|
||||
|
||||
**Returns**: True if the substring is found, otherwise false.
|
||||
|
||||
|
||||
### endsWith(searchString, length) <sub>function</sub>
|
||||
|
||||
Return a boolean indicating whether the string ends with 'searchString'.
|
||||
An optional 'length' can be provided to treat the string as if it were only
|
||||
that long.
|
||||
|
||||
|
||||
|
||||
**searchString**: The substring to search for at the end.
|
||||
|
||||
**length**: An optional length to truncate the string before testing.
|
||||
|
||||
|
||||
**Returns**: True if the string ends with 'searchString', otherwise false.
|
||||
|
||||
|
||||
### startsWith(searchString, position) <sub>function</sub>
|
||||
|
||||
Return a boolean indicating whether the string begins with 'searchString'.
|
||||
An optional position can be provided to start checking at that index.
|
||||
|
||||
|
||||
|
||||
**searchString**: The substring to search for at the start.
|
||||
|
||||
**position**: The index in the string to start searching (default 0).
|
||||
|
||||
|
||||
**Returns**: True if the string starts with 'searchString', otherwise false.
|
||||
|
||||
|
||||
### match(regexp) <sub>function</sub>
|
||||
|
||||
Use a regular expression to match the string. If 'regexp' is not a RegExp, it
|
||||
is converted to one. Return an array of matches or null if none found.
|
||||
|
||||
|
||||
|
||||
**regexp**: The pattern to match (RegExp or string).
|
||||
|
||||
|
||||
**Returns**: An array of matches or null.
|
||||
|
||||
|
||||
### matchAll(regexp) <sub>function</sub>
|
||||
|
||||
Return an iterator of all RegExp match objects found within the string.
|
||||
If 'regexp' is not a global or sticky RegExp, a TypeError is thrown.
|
||||
|
||||
|
||||
|
||||
**regexp**: The global/sticky RegExp to match over this string.
|
||||
|
||||
|
||||
**Returns**: An iterator of match arrays.
|
||||
|
||||
|
||||
### search(regexp) <sub>function</sub>
|
||||
|
||||
Use a regular expression to search for a match within the string. Return the
|
||||
index of the first match, or -1 if no match is found.
|
||||
|
||||
|
||||
|
||||
**regexp**: A RegExp or string. If a string, it is converted to RegExp.
|
||||
|
||||
|
||||
**Returns**: The index of the first match, or -1 if not found.
|
||||
|
||||
|
||||
### split(separator, limit) <sub>function</sub>
|
||||
|
||||
Split the string into an array of substrings using 'separator' (RegExp or
|
||||
string). An optional 'limit' can be provided to limit the number of splits.
|
||||
|
||||
|
||||
|
||||
**separator**: A string or RegExp used to divide the string.
|
||||
|
||||
**limit**: Maximum number of splits to include in the result array.
|
||||
|
||||
|
||||
**Returns**: An array of the split substrings.
|
||||
|
||||
|
||||
### substring(start, end) <sub>function</sub>
|
||||
|
||||
Return the substring between 'start' and 'end'. Indices outside the range
|
||||
are clamped. If 'end' < 'start', they swap.
|
||||
|
||||
|
||||
|
||||
**start**: The starting index (0-based).
|
||||
|
||||
**end**: The ending index (exclusive).
|
||||
|
||||
|
||||
**Returns**: The extracted substring.
|
||||
|
||||
|
||||
### substr(start, length) <sub>function</sub>
|
||||
|
||||
Return the substring from 'start' for 'length' characters. Negative 'start'
|
||||
counts from the end. This method is deprecated but still supported in many
|
||||
engines.
|
||||
|
||||
|
||||
|
||||
**start**: The starting index.
|
||||
|
||||
**length**: The number of characters to extract.
|
||||
|
||||
|
||||
**Returns**: The extracted substring.
|
||||
|
||||
|
||||
### slice(start, end) <sub>function</sub>
|
||||
|
||||
Extract a section of the string from 'start' up to (but not including) 'end',
|
||||
and return it as a new string. Supports negative indices.
|
||||
|
||||
|
||||
|
||||
**start**: The starting index. Negative values count from the end.
|
||||
|
||||
**end**: The ending index (exclusive). Negative values count from the end.
|
||||
|
||||
|
||||
**Returns**: The extracted slice.
|
||||
|
||||
|
||||
### repeat(count) <sub>function</sub>
|
||||
|
||||
Construct and return a new string which contains the specified number of copies
|
||||
of the calling string, concatenated together.
|
||||
|
||||
|
||||
|
||||
**count**: The number of times to repeat the string (must be >= 0).
|
||||
|
||||
|
||||
**Returns**: A new repeated string.
|
||||
|
||||
|
||||
### replace(searchValue, replaceValue) <sub>function</sub>
|
||||
|
||||
Return a new string where the first match (or all matches if 'searchValue'
|
||||
is a global RegExp) of 'searchValue' is replaced by 'replaceValue'.
|
||||
If 'searchValue' is a string, only the first occurrence is replaced.
|
||||
|
||||
|
||||
|
||||
**searchValue**: A string or RegExp to match.
|
||||
|
||||
**replaceValue**: The replacement string or function.
|
||||
|
||||
|
||||
**Returns**: A new string with the matched substring(s) replaced.
|
||||
|
||||
|
||||
### replaceAll(searchValue, replaceValue) <sub>function</sub>
|
||||
|
||||
Return a new string where all (non-overlapping) occurrences of 'searchValue'
|
||||
are replaced by 'replaceValue'. If 'searchValue' is a string, each exact match
|
||||
is replaced.
|
||||
|
||||
|
||||
|
||||
**searchValue**: A string or RegExp with the 'g' flag.
|
||||
|
||||
**replaceValue**: The replacement string or function.
|
||||
|
||||
|
||||
**Returns**: A new string with all matches replaced.
|
||||
|
||||
|
||||
### padEnd(maxLength, padString) <sub>function</sub>
|
||||
|
||||
Pad the string from the end with the given 'padString' so its length reaches
|
||||
'maxLength'. The result is a new string.
|
||||
|
||||
|
||||
|
||||
**maxLength**: The desired length of the resulting string.
|
||||
|
||||
**padString**: The string to pad with (default ' ').
|
||||
|
||||
|
||||
**Returns**: A new string padded at the end.
|
||||
|
||||
|
||||
### padStart(maxLength, padString) <sub>function</sub>
|
||||
|
||||
Pad the string from the start with the given 'padString' so its length reaches
|
||||
'maxLength'. The result is a new string.
|
||||
|
||||
|
||||
|
||||
**maxLength**: The desired length of the resulting string.
|
||||
|
||||
**padString**: The string to pad with (default ' ').
|
||||
|
||||
|
||||
**Returns**: A new string padded at the start.
|
||||
|
||||
|
||||
### trim() <sub>function</sub>
|
||||
|
||||
Return a new string with whitespace trimmed from the start and end of this
|
||||
string.
|
||||
|
||||
|
||||
|
||||
**Returns**: The trimmed string.
|
||||
|
||||
|
||||
### trimEnd() <sub>function</sub>
|
||||
|
||||
Alias for trimEnd(). Remove trailing whitespace from the string.
|
||||
|
||||
|
||||
|
||||
**Returns**: The string without trailing whitespace.
|
||||
|
||||
|
||||
### trimRight() <sub>function</sub>
|
||||
|
||||
Alias for trimEnd(). Remove trailing whitespace from the string.
|
||||
|
||||
|
||||
|
||||
**Returns**: The string without trailing whitespace.
|
||||
|
||||
|
||||
### trimStart() <sub>function</sub>
|
||||
|
||||
Alias for trimStart(). Remove leading whitespace from the string.
|
||||
|
||||
|
||||
|
||||
**Returns**: The string without leading whitespace.
|
||||
|
||||
|
||||
### trimLeft() <sub>function</sub>
|
||||
|
||||
Alias for trimStart(). Remove leading whitespace from the string.
|
||||
|
||||
|
||||
|
||||
**Returns**: The string without leading whitespace.
|
||||
|
||||
|
||||
### toString() <sub>function</sub>
|
||||
|
||||
Return a string representing the specified object (itself). Usually called
|
||||
implicitly. Overrides Object.prototype.toString.
|
||||
|
||||
|
||||
|
||||
**Returns**: The string itself.
|
||||
|
||||
|
||||
### valueOf() <sub>function</sub>
|
||||
|
||||
Return the primitive string value of this String object.
|
||||
|
||||
|
||||
|
||||
**Returns**: The primitive string value.
|
||||
|
||||
|
||||
### __quote() <sub>function</sub>
|
||||
|
||||
(Non-standard) Return a quoted representation of the string, typically for
|
||||
debug or serialization. Implementation details may vary.
|
||||
|
||||
|
||||
|
||||
**Returns**: A quoted version of the string.
|
||||
|
||||
|
||||
### localeCompare(compareString) <sub>function</sub>
|
||||
|
||||
Return a number indicating whether this string is less than, equal to, or
|
||||
greater than 'compareString' in sort order, according to the current locale.
|
||||
|
||||
|
||||
|
||||
**compareString**: The string to compare against.
|
||||
|
||||
|
||||
**Returns**: A negative number if less, 0 if the same, or a positive number if greater.
|
||||
|
||||
|
||||
### toLowerCase() <sub>function</sub>
|
||||
|
||||
Return a new string with all alphabetic characters converted to lowercase.
|
||||
|
||||
|
||||
|
||||
**Returns**: The lowercase version of this string.
|
||||
|
||||
|
||||
### toUpperCase() <sub>function</sub>
|
||||
|
||||
Return a new string with all alphabetic characters converted to uppercase.
|
||||
|
||||
|
||||
|
||||
**Returns**: The uppercase version of this string.
|
||||
|
||||
|
||||
### toLocaleLowerCase() <sub>function</sub>
|
||||
|
||||
Return a locale-aware lowercase version of this string, using the host's
|
||||
current locale or the specified locale if supported.
|
||||
|
||||
|
||||
|
||||
**Returns**: The locale-sensitive lowercase string.
|
||||
|
||||
|
||||
### toLocaleUpperCase() <sub>function</sub>
|
||||
|
||||
Return a locale-aware uppercase version of this string, using the host's
|
||||
current locale or the specified locale if supported.
|
||||
|
||||
|
||||
|
||||
**Returns**: The locale-sensitive uppercase string.
|
||||
|
||||
|
||||
### anchor(name) <sub>function</sub>
|
||||
|
||||
Return a string representing an HTML <a> element with a 'name' attribute
|
||||
set to the current string.
|
||||
|
||||
|
||||
|
||||
**name**: The name attribute for the anchor.
|
||||
|
||||
|
||||
**Returns**: An HTML <a name="...">...</a> string.
|
||||
|
||||
|
||||
### big() <sub>function</sub>
|
||||
|
||||
Return a string representing an HTML <big> element containing the current
|
||||
string.
|
||||
|
||||
|
||||
|
||||
**Returns**: An HTML <big>...</big> string.
|
||||
|
||||
|
||||
### blink() <sub>function</sub>
|
||||
|
||||
Return a string representing an HTML <blink> element containing the current
|
||||
string (historical, not recommended).
|
||||
|
||||
|
||||
|
||||
**Returns**: An HTML <blink>...</blink> string.
|
||||
|
||||
|
||||
### bold() <sub>function</sub>
|
||||
|
||||
Return a string representing an HTML <b> element containing the current
|
||||
string in bold.
|
||||
|
||||
|
||||
|
||||
**Returns**: An HTML <b>...</b> string.
|
||||
|
||||
|
||||
### fixed() <sub>function</sub>
|
||||
|
||||
Return a string representing an HTML <tt> element containing the current
|
||||
string in fixed-width font.
|
||||
|
||||
|
||||
|
||||
**Returns**: An HTML <tt>...</tt> string.
|
||||
|
||||
|
||||
### fontcolor(color) <sub>function</sub>
|
||||
|
||||
Return a string representing an HTML <font> element with a 'color' attribute,
|
||||
containing the current string.
|
||||
|
||||
|
||||
|
||||
**color**: The color value for the 'font' element.
|
||||
|
||||
|
||||
**Returns**: An HTML <font color="...">...</font> string.
|
||||
|
||||
|
||||
### fontsize(size) <sub>function</sub>
|
||||
|
||||
Return a string representing an HTML <font> element with a 'size' attribute,
|
||||
containing the current string.
|
||||
|
||||
|
||||
|
||||
**size**: The size value for the 'font' element.
|
||||
|
||||
|
||||
**Returns**: An HTML <font size="...">...</font> string.
|
||||
|
||||
|
||||
### italics() <sub>function</sub>
|
||||
|
||||
Return a string representing an HTML <i> element containing the current
|
||||
string in italics.
|
||||
|
||||
|
||||
|
||||
**Returns**: An HTML <i>...</i> string.
|
||||
|
||||
|
||||
### link(url) <sub>function</sub>
|
||||
|
||||
Return a string representing an HTML <a> element with an 'href' attribute set
|
||||
to the current string.
|
||||
|
||||
|
||||
|
||||
**url**: The URL for the 'href' attribute.
|
||||
|
||||
|
||||
**Returns**: An HTML <a href="...">...</a> string.
|
||||
|
||||
|
||||
### small() <sub>function</sub>
|
||||
|
||||
Return a string representing an HTML <small> element containing the current
|
||||
string.
|
||||
|
||||
|
||||
|
||||
**Returns**: An HTML <small>...</small> string.
|
||||
|
||||
|
||||
### strike() <sub>function</sub>
|
||||
|
||||
Return a string representing an HTML <strike> element containing the current
|
||||
string with strike-through.
|
||||
|
||||
|
||||
|
||||
**Returns**: An HTML <strike>...</strike> string.
|
||||
|
||||
|
||||
### sub() <sub>function</sub>
|
||||
|
||||
Return a string representing an HTML <sub> element containing the current
|
||||
string as subscript.
|
||||
|
||||
|
||||
|
||||
**Returns**: An HTML <sub>...</sub> string.
|
||||
|
||||
|
||||
### sup() <sub>function</sub>
|
||||
|
||||
Return a string representing an HTML <sup> element containing the current
|
||||
string as superscript.
|
||||
|
||||
|
||||
|
||||
**Returns**: An HTML <sup>...</sup> string.
|
||||
|
||||
|
||||
### rm(index, endidx) <sub>function</sub>
|
||||
|
||||
Remove characters from this string between 'index' (inclusive)
|
||||
and 'endidx' (exclusive). If 'endidx' is omitted, it defaults to 'index + 1'.
|
||||
|
||||
|
||||
|
||||
**index**: The starting index to remove.
|
||||
|
||||
**endidx**: The ending index (exclusive).
|
||||
|
||||
|
||||
**Returns**: A new string with the specified characters removed.
|
||||
|
||||
|
||||
### tolast(val) <sub>function</sub>
|
||||
|
||||
Return the substring of this string up to the last occurrence of 'val'.
|
||||
If 'val' is not found, the entire string is returned.
|
||||
|
||||
|
||||
|
||||
**val**: The substring to locate from the end.
|
||||
|
||||
|
||||
**Returns**: A substring up to the last occurrence of 'val'.
|
||||
|
||||
|
||||
### dir() <sub>function</sub>
|
||||
|
||||
Return everything before the last slash ('/') in the string.
|
||||
If no slash is found, return an empty string.
|
||||
|
||||
|
||||
|
||||
**Returns**: The directory portion of the path.
|
||||
|
||||
|
||||
### next(char, from) <sub>function</sub>
|
||||
|
||||
Search for the next occurrence of 'char' in this string, starting at 'from'.
|
||||
If 'char' is an array, any of those characters qualifies. Return the matching index,
|
||||
or -1 if none is found.
|
||||
|
||||
|
||||
|
||||
**char**: A character (or array of characters) to locate.
|
||||
|
||||
**from**: The index to start from.
|
||||
|
||||
|
||||
**Returns**: The index of the next occurrence, or -1 if not found.
|
||||
|
||||
|
||||
### prev(char, from, count) <sub>function</sub>
|
||||
|
||||
Search for the previous occurrence of 'char' before index 'from'.
|
||||
If 'count' is greater than 1, skip multiple occurrences going backward.
|
||||
Return the found index or 0 if not found.
|
||||
|
||||
|
||||
|
||||
**char**: The character to locate.
|
||||
|
||||
**from**: The index to start from (defaults to the end of the string).
|
||||
|
||||
**count**: How many occurrences to skip backward (default 0).
|
||||
|
||||
|
||||
**Returns**: The index of the previous occurrence, or 0 if not found.
|
||||
|
||||
|
||||
### strip_ext() <sub>function</sub>
|
||||
|
||||
Return the string up to (but not including) the last '.' character.
|
||||
If '.' is not found, the entire string is returned.
|
||||
|
||||
|
||||
|
||||
**Returns**: The string without its last extension.
|
||||
|
||||
|
||||
### ext() <sub>function</sub>
|
||||
|
||||
Return the substring after the last '.' in this string.
|
||||
If '.' is not found, return an empty string.
|
||||
|
||||
|
||||
|
||||
**Returns**: The file extension or an empty string.
|
||||
|
||||
|
||||
### up_path() <sub>function</sub>
|
||||
|
||||
Go up one directory level from the current path, preserving the file name at the end.
|
||||
|
||||
|
||||
|
||||
**Returns**: A new path string one directory up, with the base filename preserved.
|
||||
|
||||
|
||||
### fromlast(val) <sub>function</sub>
|
||||
|
||||
Return the substring that appears after the last occurrence of 'val'.
|
||||
If 'val' is not found, an empty string is returned.
|
||||
|
||||
|
||||
|
||||
**val**: The substring to locate.
|
||||
|
||||
|
||||
**Returns**: The substring after the last occurrence of 'val'.
|
||||
|
||||
|
||||
### tofirst(val) <sub>function</sub>
|
||||
|
||||
Return the substring from the start of this string up to the first occurrence
|
||||
of 'val' (excluded). If 'val' is not found, the entire string is returned.
|
||||
|
||||
|
||||
|
||||
**val**: The substring to locate.
|
||||
|
||||
|
||||
**Returns**: A substring up to the first occurrence of 'val'.
|
||||
|
||||
|
||||
### fromfirst(val) <sub>function</sub>
|
||||
|
||||
Return the substring after the first occurrence of 'val'.
|
||||
If 'val' is not found, the entire string is returned.
|
||||
|
||||
|
||||
|
||||
**val**: The substring to locate.
|
||||
|
||||
|
||||
**Returns**: The substring after 'val', or the entire string if 'val' not found.
|
||||
|
||||
|
||||
### name() <sub>function</sub>
|
||||
|
||||
Return the "name" portion of the path without extension.
|
||||
If no slash is found, it's up to the last '.' in the entire string.
|
||||
If there is a slash, it's from the last slash up to (but not including) the last '.'.
|
||||
|
||||
|
||||
|
||||
**Returns**: The name portion of the path without extension.
|
||||
|
||||
|
||||
### set_name(name) <sub>function</sub>
|
||||
|
||||
Set the base name (excluding extension) of the path to 'name', preserving
|
||||
the original directory and extension.
|
||||
|
||||
|
||||
|
||||
**name**: The new name to use.
|
||||
|
||||
|
||||
**Returns**: A new path string with the updated name.
|
||||
|
||||
|
||||
### base() <sub>function</sub>
|
||||
|
||||
Return the portion of this string after the last '/' character.
|
||||
If no '/' is present, the entire string is returned.
|
||||
|
||||
|
||||
|
||||
**Returns**: The base name of the path.
|
||||
|
||||
|
||||
### updir() <sub>function</sub>
|
||||
|
||||
Go up one directory from the current path, removing the last directory name.
|
||||
If the path ends with a slash, remove it first. Then remove the final directory.
|
||||
|
||||
|
||||
|
||||
**Returns**: A new string representing one directory level up.
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# Symbol
|
||||
|
||||
### toString() <sub>function</sub>
|
||||
|
||||
### valueOf() <sub>function</sub>
|
||||
|
||||
### description <sub>accessor</sub>
|
||||
|
||||
(read only)
|
||||
@@ -1,59 +0,0 @@
|
||||
# WeakMap
|
||||
|
||||
A WeakMap object is a collection of key/value pairs in which keys must be
|
||||
objects. References to key objects in a WeakMap are held weakly, meaning
|
||||
they do not prevent garbage collection if there are no other references
|
||||
to the object. WeakMap keys are not iterable.
|
||||
|
||||
### set(key, value) <sub>function</sub>
|
||||
|
||||
Set the value for the specified key in the WeakMap. The key must be an object.
|
||||
|
||||
|
||||
|
||||
**key**: The object key.
|
||||
|
||||
**value**: The value associated with the key.
|
||||
|
||||
|
||||
**Returns**: The WeakMap object (for chaining).
|
||||
|
||||
|
||||
### get(key) <sub>function</sub>
|
||||
|
||||
Return the value associated with 'key' in the WeakMap, or undefined if
|
||||
no such key exists. The key must be an object.
|
||||
|
||||
|
||||
|
||||
**key**: The object key.
|
||||
|
||||
|
||||
**Returns**: The value associated with the key, or undefined if not present.
|
||||
|
||||
|
||||
### has(key) <sub>function</sub>
|
||||
|
||||
Return a boolean indicating whether an element with the specified key
|
||||
exists in the WeakMap. The key must be an object.
|
||||
|
||||
|
||||
|
||||
**key**: The object key to check.
|
||||
|
||||
|
||||
**Returns**: True if the key is found, otherwise false.
|
||||
|
||||
|
||||
### delete(key) <sub>function</sub>
|
||||
|
||||
Remove the specified key and its associated value from the WeakMap,
|
||||
if it exists.
|
||||
|
||||
|
||||
|
||||
**key**: The object key to remove.
|
||||
|
||||
|
||||
**Returns**: True if an element was removed, otherwise false.
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
# WeakSet
|
||||
|
||||
A WeakSet object is a collection of unique objects (no primitive values).
|
||||
References to objects in a WeakSet are held weakly, so they do not prevent
|
||||
garbage collection if there are no other references to the object. WeakSet
|
||||
elements are not iterable.
|
||||
|
||||
### add(value) <sub>function</sub>
|
||||
|
||||
Add a new object to the WeakSet if it is not already present. The value
|
||||
must be an object.
|
||||
|
||||
|
||||
|
||||
**value**: The object to add.
|
||||
|
||||
|
||||
**Returns**: The WeakSet object (for chaining).
|
||||
|
||||
|
||||
### has(value) <sub>function</sub>
|
||||
|
||||
Return a boolean indicating whether an object is present in the WeakSet.
|
||||
|
||||
|
||||
|
||||
**value**: The object to check.
|
||||
|
||||
|
||||
**Returns**: True if the object is in the WeakSet, otherwise false.
|
||||
|
||||
|
||||
### delete(value) <sub>function</sub>
|
||||
|
||||
Remove the specified object from the WeakSet, if it exists.
|
||||
|
||||
|
||||
|
||||
**value**: The object to remove.
|
||||
|
||||
|
||||
**Returns**: True if the object was present and removed, otherwise false.
|
||||
|
||||
@@ -1,661 +0,0 @@
|
||||
# Array
|
||||
|
||||
### length <sub>number</sub>
|
||||
|
||||
### at(index) <sub>function</sub>
|
||||
|
||||
Return the item at index 'index', supporting negative indices to count from
|
||||
the end. If 'index' is out of range, returns undefined.
|
||||
|
||||
|
||||
|
||||
**index**: The index of the element to return (can be negative).
|
||||
|
||||
|
||||
**Returns**: The element at the given index, or undefined.
|
||||
|
||||
|
||||
### with(index, value) <sub>function</sub>
|
||||
|
||||
Return a shallow copy of the array, but with the element at 'index' replaced
|
||||
by 'value'. If 'index' is negative, it counts from the end. Throws if out of range.
|
||||
|
||||
|
||||
|
||||
**index**: The zero-based index (can be negative) to replace.
|
||||
|
||||
**value**: The new value for the specified position.
|
||||
|
||||
|
||||
**Returns**: A new array with the updated element.
|
||||
|
||||
|
||||
### concat(items) <sub>function</sub>
|
||||
|
||||
Return a new array that is the result of concatenating this array with
|
||||
any additional arrays or values provided.
|
||||
|
||||
|
||||
|
||||
**items**: One or more arrays or values to concatenate.
|
||||
|
||||
|
||||
**Returns**: A new array with the items appended.
|
||||
|
||||
|
||||
### every(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Return true if the provided callback function returns a truthy value for
|
||||
every element in the array; otherwise false.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => boolean.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: True if all elements pass the test, otherwise false.
|
||||
|
||||
|
||||
### some(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Return true if the provided callback function returns a truthy value for at
|
||||
least one element in the array; otherwise false.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => boolean.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: True if at least one element passes the test, otherwise false.
|
||||
|
||||
|
||||
### forEach(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Call the provided callback function once for each element in the array.
|
||||
Does not produce a return value.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array).
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: None
|
||||
|
||||
|
||||
### map(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Create a new array with the results of calling a provided callback function
|
||||
on every element in this array.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => newElement.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: A new array of transformed elements.
|
||||
|
||||
|
||||
### filter(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Create a new array containing all elements for which the provided callback
|
||||
function returns a truthy value.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => boolean.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: A new array of elements that passed the test.
|
||||
|
||||
|
||||
### reduce(callback, initialValue) <sub>function</sub>
|
||||
|
||||
Apply a callback function against an accumulator and each element in the
|
||||
array (from left to right) to reduce it to a single value.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(accumulator, element, index, array) => newAccumulator.
|
||||
|
||||
**initialValue**: Optional. The initial value for the accumulator.
|
||||
|
||||
|
||||
**Returns**: The single resulting value.
|
||||
|
||||
|
||||
### reduceRight(callback, initialValue) <sub>function</sub>
|
||||
|
||||
Similar to reduce(), except it processes elements from right to left.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(accumulator, element, index, array) => newAccumulator.
|
||||
|
||||
**initialValue**: Optional. The initial value for the accumulator.
|
||||
|
||||
|
||||
**Returns**: The single resulting value.
|
||||
|
||||
|
||||
### fill(value, start, end) <sub>function</sub>
|
||||
|
||||
Fill the array with a static value from 'start' index up to (but not including)
|
||||
'end' index. Modifies the original array.
|
||||
|
||||
|
||||
|
||||
**value**: The value to fill.
|
||||
|
||||
**start**: The starting index (default 0).
|
||||
|
||||
**end**: The ending index (default array.length).
|
||||
|
||||
|
||||
**Returns**: The modified array (with filled values).
|
||||
|
||||
|
||||
### find(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Return the first element in the array that satisfies the provided callback
|
||||
function. If none is found, return undefined.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => boolean.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: The first matching element, or undefined if not found.
|
||||
|
||||
|
||||
### findIndex(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Return the index of the first element in the array that satisfies the
|
||||
provided callback function. If none is found, return -1.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => boolean.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: The index of the first matching element, or -1 if not found.
|
||||
|
||||
|
||||
### findLast(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Return the last element in the array that satisfies the provided callback
|
||||
function, searching from right to left. If none is found, return undefined.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => boolean.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: The last matching element, or undefined if not found.
|
||||
|
||||
|
||||
### findLastIndex(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Return the index of the last element in the array that satisfies the
|
||||
provided callback function, searching from right to left. If none is found,
|
||||
return -1.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => boolean.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: The index of the last matching element, or -1 if not found.
|
||||
|
||||
|
||||
### indexOf(searchElement, fromIndex) <sub>function</sub>
|
||||
|
||||
Return the first index at which a given element can be found. If not present,
|
||||
return -1.
|
||||
|
||||
|
||||
|
||||
**searchElement**: The item to locate in the array.
|
||||
|
||||
**fromIndex**: The index at which to start searching (default 0).
|
||||
|
||||
|
||||
**Returns**: The index of the found element, or -1 if not found.
|
||||
|
||||
|
||||
### lastIndexOf(searchElement, fromIndex) <sub>function</sub>
|
||||
|
||||
Return the last index at which a given element can be found, or -1 if not
|
||||
present. Searches backward from 'fromIndex'.
|
||||
|
||||
|
||||
|
||||
**searchElement**: The item to locate in the array.
|
||||
|
||||
**fromIndex**: The index at which to start searching backward (default array.length - 1).
|
||||
|
||||
|
||||
**Returns**: The last index of the found element, or -1 if not found.
|
||||
|
||||
|
||||
### includes(searchElement, fromIndex) <sub>function</sub>
|
||||
|
||||
Return a boolean indicating whether the array contains the given element,
|
||||
comparing elements using the SameValueZero algorithm.
|
||||
|
||||
|
||||
|
||||
**searchElement**: The value to search for.
|
||||
|
||||
**fromIndex**: The position in the array to start searching (default 0).
|
||||
|
||||
|
||||
**Returns**: True if the element is found, otherwise false.
|
||||
|
||||
|
||||
### join(separator) <sub>function</sub>
|
||||
|
||||
Join all elements of the array into a string, separated by 'separator'.
|
||||
|
||||
|
||||
|
||||
**separator**: The delimiter string to separate elements (default ',').
|
||||
|
||||
|
||||
**Returns**: A string of array elements joined by the separator.
|
||||
|
||||
|
||||
### toString() <sub>function</sub>
|
||||
|
||||
Return a string representing the elements of the array, separated by commas.
|
||||
Overrides Object.prototype.toString.
|
||||
|
||||
|
||||
|
||||
**Returns**: A comma-separated string of array elements.
|
||||
|
||||
|
||||
### toLocaleString() <sub>function</sub>
|
||||
|
||||
Return a localized string representing the array and its elements, calling
|
||||
each element's toLocaleString if available.
|
||||
|
||||
|
||||
|
||||
**Returns**: A locale-sensitive, comma-separated string of array elements.
|
||||
|
||||
|
||||
### pop() <sub>function</sub>
|
||||
|
||||
Remove the last element from the array and return it. This changes the length
|
||||
of the array.
|
||||
|
||||
|
||||
|
||||
**Returns**: The removed element, or undefined if the array is empty.
|
||||
|
||||
|
||||
### push(items) <sub>function</sub>
|
||||
|
||||
Append one or more elements to the end of the array and return the new length
|
||||
of the array.
|
||||
|
||||
|
||||
|
||||
**items**: One or more items to append.
|
||||
|
||||
|
||||
**Returns**: The new length of the array.
|
||||
|
||||
|
||||
### shift() <sub>function</sub>
|
||||
|
||||
Remove the first element from the array and return it. This changes the length
|
||||
of the array.
|
||||
|
||||
|
||||
|
||||
**Returns**: The removed element, or undefined if the array is empty.
|
||||
|
||||
|
||||
### unshift(items) <sub>function</sub>
|
||||
|
||||
Insert one or more elements at the start of the array and return the new
|
||||
length of the array.
|
||||
|
||||
|
||||
|
||||
**items**: One or more elements to insert at the start.
|
||||
|
||||
|
||||
**Returns**: The new length of the array.
|
||||
|
||||
|
||||
### reverse() <sub>function</sub>
|
||||
|
||||
Reverse the elements of the array in place and return the modified array.
|
||||
|
||||
|
||||
|
||||
**Returns**: The reversed array.
|
||||
|
||||
|
||||
### toReversed() <sub>function</sub>
|
||||
|
||||
Return a shallow copy of the array in reverse order, without modifying the original array.
|
||||
|
||||
|
||||
|
||||
**Returns**: A new reversed array.
|
||||
|
||||
|
||||
### sort(compareFunction) <sub>function</sub>
|
||||
|
||||
Sort the array in place, returning it. By default, sorts elements as strings in ascending order. An optional compareFunction may be used for custom sorting.
|
||||
|
||||
|
||||
|
||||
**compareFunction**: A function(a, b) => number, defining sort order.
|
||||
|
||||
|
||||
**Returns**: The sorted array.
|
||||
|
||||
|
||||
### toSorted(compareFunction) <sub>function</sub>
|
||||
|
||||
Return a shallow copy of the array, sorted according to the optional compare
|
||||
function, without modifying the original array.
|
||||
|
||||
|
||||
|
||||
**compareFunction**: A function(a, b) => number, defining sort order.
|
||||
|
||||
|
||||
**Returns**: A new sorted array.
|
||||
|
||||
|
||||
### slice(start, end) <sub>function</sub>
|
||||
|
||||
Return a shallow copy of a portion of the array into a new array object, selected from 'start' to 'end' (end not included).
|
||||
|
||||
|
||||
|
||||
**start**: The beginning index (0-based). Negative values count from the end.
|
||||
|
||||
**end**: The end index (exclusive). Negative values count from the end.
|
||||
|
||||
|
||||
**Returns**: A new array containing the extracted elements.
|
||||
|
||||
|
||||
### splice(start, deleteCount, items) <sub>function</sub>
|
||||
|
||||
Change the contents of the array by removing or replacing existing elements and/or adding new elements in place. Returns an array of removed elements.
|
||||
|
||||
|
||||
|
||||
**start**: The index at which to start changing the array.
|
||||
|
||||
**deleteCount**: Number of elements to remove.
|
||||
|
||||
**items**: Elements to add in place of the removed elements.
|
||||
|
||||
|
||||
**Returns**: An array containing the removed elements (if any).
|
||||
|
||||
|
||||
### toSpliced(start, deleteCount, items) <sub>function</sub>
|
||||
|
||||
Return a shallow copy of the array, with a splice-like operation applied at 'start' removing 'deleteCount' elements and adding 'items'. Does not mutate the original array.
|
||||
|
||||
|
||||
|
||||
**start**: The index at which to start the splice operation.
|
||||
|
||||
**deleteCount**: Number of elements to remove.
|
||||
|
||||
**items**: Elements to add in place of the removed elements.
|
||||
|
||||
|
||||
**Returns**: A new array with the splice applied.
|
||||
|
||||
|
||||
### copyWithin(target, start, end) <sub>function</sub>
|
||||
|
||||
Copy a sequence of array elements within the array, overwriting existing values. This operation is performed in place and returns the modified array.
|
||||
|
||||
|
||||
|
||||
**target**: The index at which to copy the sequence to.
|
||||
|
||||
**start**: The beginning index of the sequence to copy.
|
||||
|
||||
**end**: The end index (exclusive) of the sequence to copy (default array.length).
|
||||
|
||||
|
||||
**Returns**: The modified array.
|
||||
|
||||
|
||||
### flatMap(callback, thisArg) <sub>function</sub>
|
||||
|
||||
Return a new array formed by applying a callback function to each element and then flattening the result by one level.
|
||||
|
||||
|
||||
|
||||
**callback**: A function(element, index, array) => array or value.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the callback.
|
||||
|
||||
|
||||
**Returns**: A new array with the flattened results.
|
||||
|
||||
|
||||
### flat(depth) <sub>function</sub>
|
||||
|
||||
Return a new array with all sub-array elements concatenated into it recursively up to the specified depth.
|
||||
|
||||
|
||||
|
||||
**depth**: The maximum depth to flatten (default 1).
|
||||
|
||||
|
||||
**Returns**: A new flattened array.
|
||||
|
||||
|
||||
### values() <sub>function</sub>
|
||||
|
||||
Return a new Array Iterator object that contains the values for each index in the array.
|
||||
|
||||
|
||||
|
||||
**Returns**: An iterator over the array's elements.
|
||||
|
||||
|
||||
### keys() <sub>function</sub>
|
||||
|
||||
Return a new Array Iterator object that contains the keys (indexes) for each index in the array.
|
||||
|
||||
|
||||
|
||||
**Returns**: An iterator over the array's indices.
|
||||
|
||||
|
||||
### entries() <sub>function</sub>
|
||||
|
||||
Return a new Array Iterator object that contains key/value pairs for each index in the array. Each entry is [index, value].
|
||||
|
||||
|
||||
|
||||
**Returns**: An iterator over [index, value] pairs.
|
||||
|
||||
|
||||
### add(other) <sub>function</sub>
|
||||
|
||||
Non-standard. Add corresponding elements of the current array and 'other' element-wise, returning a new array. Behavior depends on data types.
|
||||
|
||||
|
||||
|
||||
**other**: Another array or scalar to add to each element.
|
||||
|
||||
|
||||
**Returns**: A new array with element-wise sum results.
|
||||
|
||||
|
||||
### sub(other) <sub>function</sub>
|
||||
|
||||
Non-standard. Subtract corresponding elements of 'other' from the current array element-wise, returning a new array. Behavior depends on data types.
|
||||
|
||||
|
||||
|
||||
**other**: Another array or scalar to subtract from each element.
|
||||
|
||||
|
||||
**Returns**: A new array with element-wise difference results.
|
||||
|
||||
|
||||
### div(other) <sub>function</sub>
|
||||
|
||||
Non-standard. Divide each element of the current array by the corresponding element of 'other' (or a scalar) element-wise, returning a new array. Behavior depends on data types.
|
||||
|
||||
|
||||
|
||||
**other**: Another array or scalar for the division.
|
||||
|
||||
|
||||
**Returns**: A new array with element-wise division results.
|
||||
|
||||
|
||||
### scale() <sub>function</sub>
|
||||
|
||||
### lerp() <sub>function</sub>
|
||||
|
||||
### x <sub>accessor</sub>
|
||||
|
||||
### y <sub>accessor</sub>
|
||||
|
||||
### xy <sub>accessor</sub>
|
||||
|
||||
### r <sub>accessor</sub>
|
||||
|
||||
### g <sub>accessor</sub>
|
||||
|
||||
### b <sub>accessor</sub>
|
||||
|
||||
### a <sub>accessor</sub>
|
||||
|
||||
### rgb <sub>accessor</sub>
|
||||
|
||||
### rgba <sub>accessor</sub>
|
||||
|
||||
### filter!(fn) <sub>function</sub>
|
||||
|
||||
Perform an in-place filter of this array using the provided callback 'fn'.
|
||||
Any element for which 'fn' returns a falsy value is removed. The array is modified
|
||||
and then returned.
|
||||
|
||||
|
||||
|
||||
**fn**: A callback function(element, index, array) => boolean.
|
||||
|
||||
|
||||
**Returns**: The filtered (modified) array.
|
||||
|
||||
|
||||
### delete(item) <sub>function</sub>
|
||||
|
||||
Remove the first occurrence of 'item' from the array, if it exists.
|
||||
Returns undefined.
|
||||
|
||||
|
||||
|
||||
**item**: The item to remove.
|
||||
|
||||
|
||||
**Returns**: undefined
|
||||
|
||||
|
||||
### copy() <sub>function</sub>
|
||||
|
||||
Return a deep copy of this array by applying 'deep_copy' to each element.
|
||||
The resulting array is entirely new.
|
||||
|
||||
|
||||
|
||||
**Returns**: A new array that is a deep copy of the original.
|
||||
|
||||
|
||||
### equal(b) <sub>function</sub>
|
||||
|
||||
Check if this array and array 'b' have the same elements in the same order.
|
||||
If they are of different lengths, return false. Otherwise compare them via JSON.
|
||||
|
||||
|
||||
|
||||
**b**: Another array to compare against.
|
||||
|
||||
|
||||
**Returns**: True if they match, false otherwise.
|
||||
|
||||
|
||||
### last() <sub>function</sub>
|
||||
|
||||
Return the last element of this array. If the array is empty, returns undefined.
|
||||
|
||||
|
||||
|
||||
**Returns**: The last element of the array, or undefined if empty.
|
||||
|
||||
|
||||
### wrapped(x) <sub>function</sub>
|
||||
|
||||
Return a copy of the array with the first 'x' elements appended to the end.
|
||||
Does not modify the original array.
|
||||
|
||||
|
||||
|
||||
**x**: The number of leading elements to re-append.
|
||||
|
||||
|
||||
**Returns**: A new array with the leading elements wrapped to the end.
|
||||
|
||||
|
||||
### wrap_idx(x) <sub>function</sub>
|
||||
|
||||
Wrap the integer 'x' around this array's length, ensuring the resulting index
|
||||
lies within [0, this.length - 1].
|
||||
|
||||
|
||||
|
||||
**x**: The index to wrap.
|
||||
|
||||
|
||||
**Returns**: A wrapped index within this array's bounds.
|
||||
|
||||
|
||||
### mirrored(x) <sub>function</sub>
|
||||
|
||||
Return a new array that appends a reversed copy (excluding the last element)
|
||||
of itself to the end. For example, [1,2,3] -> [1,2,3,2,1]. If the array has length
|
||||
<= 1, a copy of it is returned directly.
|
||||
|
||||
|
||||
|
||||
**Returns**: A new "mirrored" array.
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 219 KiB |
@@ -1,47 +0,0 @@
|
||||
# Array
|
||||
|
||||
### length <sub>number</sub>
|
||||
|
||||
### name <sub>string</sub>
|
||||
|
||||
### prototype <sub>object</sub>
|
||||
|
||||
### isArray(value) <sub>function</sub>
|
||||
|
||||
Determine if the given value is an Array. Returns true if the argument is an array, otherwise false.
|
||||
|
||||
|
||||
|
||||
**value**: The value to be checked.
|
||||
|
||||
|
||||
**Returns**: True if 'value' is an array, otherwise false.
|
||||
|
||||
|
||||
### from(arrayLike, mapFn, thisArg) <sub>function</sub>
|
||||
|
||||
Create a new array from an array-like or iterable object. An optional map function can be invoked on each element before it is added to the new array.
|
||||
|
||||
|
||||
|
||||
**arrayLike**: An array-like or iterable object to convert.
|
||||
|
||||
**mapFn**: Optional. A function to call on every element of the new array.
|
||||
|
||||
**thisArg**: Optional. A value to use as 'this' within the map function.
|
||||
|
||||
|
||||
**Returns**: A new array populated with elements processed from arrayLike.
|
||||
|
||||
|
||||
### of(elements) <sub>function</sub>
|
||||
|
||||
Create a new array with a variable number of arguments, regardless of the number or type of the arguments. Unlike the Array constructor, there is no special treatment for a single numeric argument.
|
||||
|
||||
|
||||
|
||||
**elements**: A variable number of arguments which become array elements.
|
||||
|
||||
|
||||
**Returns**: A new array containing the provided arguments.
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
# Error
|
||||
|
||||
### length <sub>number</sub>
|
||||
|
||||
### name <sub>string</sub>
|
||||
|
||||
### prototype <sub>object</sub>
|
||||
@@ -1,7 +0,0 @@
|
||||
# Function
|
||||
|
||||
### length <sub>number</sub>
|
||||
|
||||
### name <sub>string</sub>
|
||||
|
||||
### prototype() <sub>function</sub>
|
||||
@@ -1,458 +0,0 @@
|
||||
# Math
|
||||
|
||||
### min(values) <sub>function</sub>
|
||||
|
||||
Return the smallest of the zero or more given numbers. If no arguments are provided, the result is Infinity. If any value is NaN, the result is NaN.
|
||||
|
||||
|
||||
|
||||
**values**: One or more numeric values.
|
||||
|
||||
|
||||
**Returns**: The smallest numeric value, Infinity if no arguments, or NaN if any argument cannot be converted to a number.
|
||||
|
||||
|
||||
### max(values) <sub>function</sub>
|
||||
|
||||
Return the largest of the zero or more given numbers. If no arguments are provided, the result is -Infinity. If any value is NaN, the result is NaN.
|
||||
|
||||
|
||||
|
||||
**values**: One or more numeric values.
|
||||
|
||||
|
||||
**Returns**: The largest numeric value, -Infinity if no arguments, or NaN if any argument cannot be converted to a number.
|
||||
|
||||
|
||||
### abs(x) <sub>function</sub>
|
||||
|
||||
Return the absolute value of the given number. For example, -5 becomes 5.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value.
|
||||
|
||||
|
||||
**Returns**: The absolute value of x.
|
||||
|
||||
|
||||
### floor(x) <sub>function</sub>
|
||||
|
||||
Return the greatest integer less than or equal to x, effectively rounding down to the nearest integer.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value.
|
||||
|
||||
|
||||
**Returns**: The largest integer <= x.
|
||||
|
||||
|
||||
### ceil(x) <sub>function</sub>
|
||||
|
||||
Return the smallest integer greater than or equal to x, effectively rounding up to the nearest integer.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value.
|
||||
|
||||
|
||||
**Returns**: The smallest integer >= x.
|
||||
|
||||
|
||||
### round(x) <sub>function</sub>
|
||||
|
||||
Return x rounded to the nearest integer. If the fractional portion is 0.5 or
|
||||
greater, rounds up; otherwise, rounds down. Ties away from zero in modern ECMAScript.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value.
|
||||
|
||||
|
||||
**Returns**: x rounded to the nearest integer.
|
||||
|
||||
|
||||
### sqrt(x) <sub>function</sub>
|
||||
|
||||
Return the positive square root of x. If x is negative, the result is NaN.
|
||||
|
||||
|
||||
|
||||
**x**: A non-negative numeric value.
|
||||
|
||||
|
||||
**Returns**: The positive square root of x, or NaN if x is negative.
|
||||
|
||||
|
||||
### acos(x) <sub>function</sub>
|
||||
|
||||
Return the arccosine (in radians) of x, in the range [0, π]. If x is outside
|
||||
the range [-1, 1], the result is NaN.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value in [-1, 1].
|
||||
|
||||
|
||||
**Returns**: The arccosine of x in radians, or NaN if out of range.
|
||||
|
||||
|
||||
### asin(x) <sub>function</sub>
|
||||
|
||||
Return the arcsine (in radians) of x, in the range [-π/2, π/2]. If x is
|
||||
outside [-1, 1], the result is NaN.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value in [-1, 1].
|
||||
|
||||
|
||||
**Returns**: The arcsine of x in radians, or NaN if out of range.
|
||||
|
||||
|
||||
### atan(x) <sub>function</sub>
|
||||
|
||||
Return the arctangent (in radians) of x, in the range [-π/2, π/2].
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value.
|
||||
|
||||
|
||||
**Returns**: The arctangent of x in radians.
|
||||
|
||||
|
||||
### atan2(y, x) <sub>function</sub>
|
||||
|
||||
Return the arctangent of the quotient of its arguments (y / x), in the range
|
||||
(-π, π]. This takes into account the signs of both x and y to determine
|
||||
the correct quadrant.
|
||||
|
||||
|
||||
|
||||
**y**: The y coordinate.
|
||||
|
||||
**x**: The x coordinate.
|
||||
|
||||
|
||||
**Returns**: The angle in radians between the positive x-axis and the point (x, y).
|
||||
|
||||
|
||||
### cos(x) <sub>function</sub>
|
||||
|
||||
Return the cosine of x, where x is in radians.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value in radians.
|
||||
|
||||
|
||||
**Returns**: The cosine of x, in the range [-1, 1].
|
||||
|
||||
|
||||
### exp(x) <sub>function</sub>
|
||||
|
||||
Return e^x, where e is Euler's number (approximately 2.71828).
|
||||
|
||||
|
||||
|
||||
**x**: A numeric exponent.
|
||||
|
||||
|
||||
**Returns**: The value of e raised to x.
|
||||
|
||||
|
||||
### log(x) <sub>function</sub>
|
||||
|
||||
Return the natural logarithm (base e) of x. If x is <= 0, the result is NaN.
|
||||
|
||||
|
||||
|
||||
**x**: A positive numeric value.
|
||||
|
||||
|
||||
**Returns**: The natural logarithm of x.
|
||||
|
||||
|
||||
### pow(base, exponent) <sub>function</sub>
|
||||
|
||||
Return base raised to the power exponent, i.e. base^exponent. If base is
|
||||
negative and exponent is not an integer, result is NaN.
|
||||
|
||||
|
||||
|
||||
**base**: The base number.
|
||||
|
||||
**exponent**: The exponent number.
|
||||
|
||||
|
||||
**Returns**: base raised to exponent.
|
||||
|
||||
|
||||
### sin(x) <sub>function</sub>
|
||||
|
||||
Return the sine of x, where x is in radians.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value in radians.
|
||||
|
||||
|
||||
**Returns**: The sine of x, in the range [-1, 1].
|
||||
|
||||
|
||||
### tan(x) <sub>function</sub>
|
||||
|
||||
Return the tangent of x, where x is in radians. If x is (π/2 + nπ), the
|
||||
result is ±Infinity or NaN.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value in radians.
|
||||
|
||||
|
||||
**Returns**: The tangent of x.
|
||||
|
||||
|
||||
### trunc(x) <sub>function</sub>
|
||||
|
||||
Return the integer part of x by removing any fractional digits. Does not
|
||||
round, just truncates.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value.
|
||||
|
||||
|
||||
**Returns**: x truncated toward zero.
|
||||
|
||||
|
||||
### sign(x) <sub>function</sub>
|
||||
|
||||
Return the sign of x, indicating whether x is positive, negative, or zero.
|
||||
Returns 1 if x > 0, -1 if x < 0, 0 if x is 0, and NaN if x is NaN.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value.
|
||||
|
||||
|
||||
**Returns**: 1, -1, 0, -0, or NaN, depending on x.
|
||||
|
||||
|
||||
### cosh(x) <sub>function</sub>
|
||||
|
||||
Return the hyperbolic cosine of x, (e^x + e^-x) / 2.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value.
|
||||
|
||||
|
||||
**Returns**: The hyperbolic cosine of x.
|
||||
|
||||
|
||||
### sinh(x) <sub>function</sub>
|
||||
|
||||
Return the hyperbolic sine of x, (e^x - e^-x) / 2.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value.
|
||||
|
||||
|
||||
**Returns**: The hyperbolic sine of x.
|
||||
|
||||
|
||||
### tanh(x) <sub>function</sub>
|
||||
|
||||
Return the hyperbolic tangent of x, (e^x - e^-x) / (e^x + e^-x).
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value.
|
||||
|
||||
|
||||
**Returns**: The hyperbolic tangent of x.
|
||||
|
||||
|
||||
### acosh(x) <sub>function</sub>
|
||||
|
||||
Return the inverse hyperbolic cosine of x, defined as ln(x + sqrt(x^2 - 1)).
|
||||
If x < 1, the result is NaN.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value >= 1.
|
||||
|
||||
|
||||
**Returns**: The inverse hyperbolic cosine of x.
|
||||
|
||||
|
||||
### asinh(x) <sub>function</sub>
|
||||
|
||||
Return the inverse hyperbolic sine of x, defined as ln(x + sqrt(x^2 + 1)).
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value.
|
||||
|
||||
|
||||
**Returns**: The inverse hyperbolic sine of x.
|
||||
|
||||
|
||||
### atanh(x) <sub>function</sub>
|
||||
|
||||
Return the inverse hyperbolic tangent of x, defined as 1/2 * ln((1 + x) / (1 - x)).
|
||||
If |x| >= 1, the result is NaN.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value in the range (-1, 1).
|
||||
|
||||
|
||||
**Returns**: The inverse hyperbolic tangent of x.
|
||||
|
||||
|
||||
### expm1(x) <sub>function</sub>
|
||||
|
||||
Return e^x - 1, for small values of x this provides higher precision than
|
||||
Math.exp(x) - 1.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric exponent.
|
||||
|
||||
|
||||
**Returns**: e^x - 1.
|
||||
|
||||
|
||||
### log1p(x) <sub>function</sub>
|
||||
|
||||
Return the natural logarithm of (1 + x). More accurate than Math.log(1 + x)
|
||||
for small x.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value > -1.
|
||||
|
||||
|
||||
**Returns**: ln(1 + x).
|
||||
|
||||
|
||||
### log2(x) <sub>function</sub>
|
||||
|
||||
Return the base-2 logarithm of x. If x <= 0, the result is NaN.
|
||||
|
||||
|
||||
|
||||
**x**: A positive numeric value.
|
||||
|
||||
|
||||
**Returns**: The base-2 logarithm of x.
|
||||
|
||||
|
||||
### log10(x) <sub>function</sub>
|
||||
|
||||
Return the base-10 logarithm of x. If x <= 0, the result is NaN.
|
||||
|
||||
|
||||
|
||||
**x**: A positive numeric value.
|
||||
|
||||
|
||||
**Returns**: The base-10 logarithm of x.
|
||||
|
||||
|
||||
### cbrt(x) <sub>function</sub>
|
||||
|
||||
Return the cube root of x, including negative values.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value (can be negative).
|
||||
|
||||
|
||||
**Returns**: The cube root of x.
|
||||
|
||||
|
||||
### hypot(values) <sub>function</sub>
|
||||
|
||||
Return the square root of the sum of squares of its arguments, i.e.
|
||||
sqrt(x1^2 + x2^2 + ...). If any value is ±Infinity, returns Infinity. If
|
||||
any value is NaN, returns NaN.
|
||||
|
||||
|
||||
|
||||
**values**: One or more numeric values.
|
||||
|
||||
|
||||
**Returns**: The square root of the sum of squares of the arguments.
|
||||
|
||||
|
||||
### random() <sub>function</sub>
|
||||
|
||||
Return a pseudo-random floating-point number in the range [0, 1).
|
||||
The result is usually seeded by an engine-defined source of randomness.
|
||||
|
||||
|
||||
|
||||
**Returns**: A number >= 0 and < 1.
|
||||
|
||||
|
||||
### fround(x) <sub>function</sub>
|
||||
|
||||
Return the nearest 32-bit single-precision float representation of x.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value.
|
||||
|
||||
|
||||
**Returns**: The 32-bit float representation of x.
|
||||
|
||||
|
||||
### imul(a, b) <sub>function</sub>
|
||||
|
||||
Return the result of a 32-bit integer multiplication of two values.
|
||||
Effectively (a * b) | 0 in many implementations.
|
||||
|
||||
|
||||
|
||||
**a**: A numeric value.
|
||||
|
||||
**b**: A numeric value.
|
||||
|
||||
|
||||
**Returns**: The 32-bit integer result of multiplying a by b.
|
||||
|
||||
|
||||
### clz32(x) <sub>function</sub>
|
||||
|
||||
Return the number of leading zero bits in the 32-bit binary representation
|
||||
of x. If x is 0, returns 32.
|
||||
|
||||
|
||||
|
||||
**x**: A numeric value, treated as a 32-bit unsigned integer.
|
||||
|
||||
|
||||
**Returns**: The count of leading zero bits, in the range [0, 32].
|
||||
|
||||
|
||||
### E <sub>number</sub>
|
||||
|
||||
### LN10 <sub>number</sub>
|
||||
|
||||
### LN2 <sub>number</sub>
|
||||
|
||||
### LOG2E <sub>number</sub>
|
||||
|
||||
### LOG10E <sub>number</sub>
|
||||
|
||||
### PI <sub>number</sub>
|
||||
|
||||
### SQRT1_2 <sub>number</sub>
|
||||
|
||||
### SQRT2 <sub>number</sub>
|
||||
@@ -1,99 +0,0 @@
|
||||
# Number
|
||||
|
||||
### length <sub>number</sub>
|
||||
|
||||
### name <sub>string</sub>
|
||||
|
||||
### prototype <sub>object</sub>
|
||||
|
||||
### parseInt(string, radix) <sub>function</sub>
|
||||
|
||||
Parse a string argument and return an integer of the specified radix (base).
|
||||
If the string does not start with a valid integer, return NaN. Leading
|
||||
whitespace is ignored.
|
||||
|
||||
|
||||
|
||||
**string**: The string to parse as an integer.
|
||||
|
||||
**radix**: An integer between 2 and 36 indicating the base of the number in the string.
|
||||
|
||||
|
||||
**Returns**: The parsed integer, or NaN if the input is not a valid integer.
|
||||
|
||||
|
||||
### parseFloat(string) <sub>function</sub>
|
||||
|
||||
Parse a string argument and return a floating-point number. If the string does not represent a valid number, return NaN. Leading whitespace is ignored, and the string can include a decimal point or exponent.
|
||||
|
||||
|
||||
|
||||
**string**: The string to parse as a floating-point number.
|
||||
|
||||
|
||||
**Returns**: The parsed number, or NaN if invalid.
|
||||
|
||||
|
||||
### isNaN(value) <sub>function</sub>
|
||||
|
||||
Determine if a value is the special numeric value NaN, without converting the argument. Unlike the global isNaN(), this returns false for non-numeric values.
|
||||
|
||||
|
||||
|
||||
**value**: The value to test.
|
||||
|
||||
|
||||
**Returns**: True if the value is NaN, otherwise false.
|
||||
|
||||
|
||||
### isFinite(value) <sub>function</sub>
|
||||
|
||||
Determine if a value is a finite number. Unlike the global isFinite(), this returns false for non-numeric values without attempting to convert them.
|
||||
|
||||
|
||||
|
||||
**value**: The value to test.
|
||||
|
||||
|
||||
**Returns**: True if the value is a finite number, otherwise false.
|
||||
|
||||
|
||||
### isInteger(value) <sub>function</sub>
|
||||
|
||||
Check if the given value is a finite number and also an integer (no fractional part). Returns false for non-numeric values or NaN.
|
||||
|
||||
|
||||
|
||||
**value**: The value to test.
|
||||
|
||||
|
||||
**Returns**: True if value is an integer, otherwise false.
|
||||
|
||||
|
||||
### isSafeInteger(value) <sub>function</sub>
|
||||
|
||||
Check if the given value is a safe integer. A safe integer is one that can be exactly represented as an IEEE-754 double-precision number (i.e., between -9007199254740991 and 9007199254740991 inclusive).
|
||||
|
||||
|
||||
|
||||
**value**: The value to test.
|
||||
|
||||
|
||||
**Returns**: True if value is an integer within the safe range, otherwise false.
|
||||
|
||||
|
||||
### MAX_VALUE <sub>number</sub>
|
||||
|
||||
### MIN_VALUE <sub>number</sub>
|
||||
|
||||
### NaN <sub>number</sub>
|
||||
|
||||
### NEGATIVE_INFINITY <sub>number</sub>
|
||||
|
||||
### POSITIVE_INFINITY <sub>number</sub>
|
||||
|
||||
### EPSILON <sub>number</sub>
|
||||
|
||||
### MAX_SAFE_INTEGER <sub>number</sub>
|
||||
|
||||
### MIN_SAFE_INTEGER <sub>number</sub>
|
||||
@@ -1,331 +0,0 @@
|
||||
# Object
|
||||
|
||||
### length <sub>number</sub>
|
||||
|
||||
### name <sub>string</sub>
|
||||
|
||||
### prototype <sub>object</sub>
|
||||
|
||||
### create(proto, propertiesObject) <sub>function</sub>
|
||||
|
||||
Create a new object, using the specified prototype object and optional property descriptors.
|
||||
|
||||
|
||||
|
||||
**proto**: The object to be used as the prototype.
|
||||
|
||||
**propertiesObject**: Optional. An object specifying properties to be added.
|
||||
|
||||
|
||||
**Returns**: A new object with the given prototype and properties.
|
||||
|
||||
|
||||
### getPrototypeOf(obj) <sub>function</sub>
|
||||
|
||||
Return the prototype of the specified object. If no prototype is found (e.g. the object has null as its prototype), return null.
|
||||
|
||||
|
||||
|
||||
**obj**: The object whose prototype is to be returned.
|
||||
|
||||
|
||||
**Returns**: The prototype of 'obj', or null.
|
||||
|
||||
|
||||
### setPrototypeOf(obj, proto) <sub>function</sub>
|
||||
|
||||
Set the prototype of the specified object to the provided value. Throws a TypeError if the object is non-extensible and the prototype is changed.
|
||||
|
||||
|
||||
|
||||
**obj**: The object whose prototype is set.
|
||||
|
||||
**proto**: The new prototype or null.
|
||||
|
||||
|
||||
**Returns**: The object 'obj' after setting its prototype.
|
||||
|
||||
|
||||
### defineProperty(obj, prop, descriptor) <sub>function</sub>
|
||||
|
||||
Define or modify a property on an object using a property descriptor, returning the object. Throws a TypeError if the descriptor is invalid.
|
||||
|
||||
|
||||
|
||||
**obj**: The object on which to define or modify a property.
|
||||
|
||||
**prop**: The name or Symbol of the property.
|
||||
|
||||
**descriptor**: A property descriptor object (e.g., {value, writable, get, set, ...}).
|
||||
|
||||
|
||||
**Returns**: The object with the newly defined or updated property.
|
||||
|
||||
|
||||
### defineProperties(obj, props) <sub>function</sub>
|
||||
|
||||
Define new or modify existing properties on an object, given an object of property descriptors. Returns the modified object.
|
||||
|
||||
|
||||
|
||||
**obj**: The object on which to define or modify properties.
|
||||
|
||||
**props**: An object mapping property names to property descriptors.
|
||||
|
||||
|
||||
**Returns**: The modified object.
|
||||
|
||||
|
||||
### getOwnPropertyNames(obj) <sub>function</sub>
|
||||
|
||||
Return an array of all own (non-Symbol) property names found directly on the given object, in the same order as a for...in loop would return.
|
||||
|
||||
|
||||
|
||||
**obj**: The object whose own property names are returned.
|
||||
|
||||
|
||||
**Returns**: An array of strings that correspond to the properties.
|
||||
|
||||
|
||||
### getOwnPropertySymbols(obj) <sub>function</sub>
|
||||
|
||||
Return an array of all own Symbol properties found directly on the given object.
|
||||
|
||||
|
||||
|
||||
**obj**: The object to retrieve Symbol keys from.
|
||||
|
||||
|
||||
**Returns**: An array of Symbol keys.
|
||||
|
||||
|
||||
### groupBy(obj, fn) <sub>function</sub>
|
||||
|
||||
Non-standard / Proposed. Group the own properties of an object according to the return value of a grouping function. Typically returns a new object whose keys are the group identifiers.
|
||||
|
||||
|
||||
|
||||
**obj**: The object to group.
|
||||
|
||||
**fn**: A function(key, value) => groupingKey, applied to each property.
|
||||
|
||||
|
||||
**Returns**: An object where properties are grouped by the returned keys.
|
||||
|
||||
|
||||
### keys(obj) <sub>function</sub>
|
||||
|
||||
Return an array of the object's own enumerable (non-Symbol) property names, in the same order that a normal loop would.
|
||||
|
||||
|
||||
|
||||
**obj**: The object whose property names are to be returned.
|
||||
|
||||
|
||||
**Returns**: An array of property names.
|
||||
|
||||
|
||||
### values(obj) <sub>function</sub>
|
||||
|
||||
Return an array of the object's own enumerable (non-Symbol) property values, in the same order as Object.keys().
|
||||
|
||||
|
||||
|
||||
**obj**: The object whose property values are to be returned.
|
||||
|
||||
|
||||
**Returns**: An array of property values.
|
||||
|
||||
|
||||
### entries(obj) <sub>function</sub>
|
||||
|
||||
Return an array of [key, value] pairs for the object's own enumerable (non-Symbol) properties, in the same order as Object.keys().
|
||||
|
||||
|
||||
|
||||
**obj**: The object whose [key, value] pairs are to be returned.
|
||||
|
||||
|
||||
**Returns**: An array of [key, value] pairs.
|
||||
|
||||
|
||||
### isExtensible(obj) <sub>function</sub>
|
||||
|
||||
Return a boolean indicating whether new properties can be added to the specified object.
|
||||
|
||||
|
||||
|
||||
**obj**: The object to test.
|
||||
|
||||
|
||||
**Returns**: True if the object is extensible, otherwise false.
|
||||
|
||||
|
||||
### preventExtensions(obj) <sub>function</sub>
|
||||
|
||||
Prevent new properties from ever being added to an object. Existing properties are not affected.
|
||||
|
||||
|
||||
|
||||
**obj**: The object to mark as non-extensible.
|
||||
|
||||
|
||||
**Returns**: The non-extensible object.
|
||||
|
||||
|
||||
### getOwnPropertyDescriptor(obj, prop) <sub>function</sub>
|
||||
|
||||
Return the property descriptor for a named property on the specified object, if it exists, otherwise undefined.
|
||||
|
||||
|
||||
|
||||
**obj**: The object in which to look for the property.
|
||||
|
||||
**prop**: The name or Symbol of the property.
|
||||
|
||||
|
||||
**Returns**: The property descriptor, or undefined if not found.
|
||||
|
||||
|
||||
### getOwnPropertyDescriptors(obj) <sub>function</sub>
|
||||
|
||||
Return an object containing all own property descriptors for the given object, keyed by property names (and Symbols).
|
||||
|
||||
|
||||
|
||||
**obj**: The object to retrieve property descriptors from.
|
||||
|
||||
|
||||
**Returns**: An object mapping property keys to property descriptors.
|
||||
|
||||
|
||||
### is(value1, value2) <sub>function</sub>
|
||||
|
||||
Compare two values for strict equality, like '===' but without special treatment for +0 and -0, and treating NaN as equal to NaN.
|
||||
|
||||
|
||||
|
||||
**value1**: A value to compare.
|
||||
|
||||
**value2**: Another value to compare.
|
||||
|
||||
|
||||
**Returns**: True if both values are the same, otherwise false.
|
||||
|
||||
|
||||
### assign(target, sources) <sub>function</sub>
|
||||
|
||||
Copy all enumerable own properties from one or more source objects to a target object, returning the modified target.
|
||||
|
||||
|
||||
|
||||
**target**: The object to receive properties.
|
||||
|
||||
**sources**: One or more objects containing properties to copy.
|
||||
|
||||
|
||||
**Returns**: The updated target object.
|
||||
|
||||
|
||||
### seal(obj) <sub>function</sub>
|
||||
|
||||
Seal an object, preventing new properties from being added and marking all existing properties as non-configurable. Values of present properties can still be changed if they are writable.
|
||||
|
||||
|
||||
|
||||
**obj**: The object to seal.
|
||||
|
||||
|
||||
**Returns**: The sealed object.
|
||||
|
||||
|
||||
### freeze(obj) <sub>function</sub>
|
||||
|
||||
Freeze an object, preventing new properties from being added, existing properties from being removed, or current properties from being changed (to the extent permitted by property descriptors).
|
||||
|
||||
|
||||
|
||||
**obj**: The object to freeze.
|
||||
|
||||
|
||||
**Returns**: The frozen object.
|
||||
|
||||
|
||||
### isSealed(obj) <sub>function</sub>
|
||||
|
||||
Check if an object is sealed. A sealed object has no configurable properties and is non-extensible.
|
||||
|
||||
|
||||
|
||||
**obj**: The object to test.
|
||||
|
||||
|
||||
**Returns**: True if the object is sealed, otherwise false.
|
||||
|
||||
|
||||
### isFrozen(obj) <sub>function</sub>
|
||||
|
||||
Check if an object is frozen. A frozen object is sealed and all data properties are non-writable.
|
||||
|
||||
|
||||
|
||||
**obj**: The object to test.
|
||||
|
||||
|
||||
**Returns**: True if the object is frozen, otherwise false.
|
||||
|
||||
|
||||
### __getClass() <sub>function</sub>
|
||||
|
||||
### fromEntries(entries) <sub>function</sub>
|
||||
|
||||
Transform a list of key-value pairs into an object. The iterable argument should yield pairs [key, value], which become properties on the resulting object.
|
||||
|
||||
|
||||
|
||||
**entries**: An iterable of [key, value] pairs.
|
||||
|
||||
|
||||
**Returns**: A new object formed from the given entries.
|
||||
|
||||
|
||||
### hasOwn(obj, prop) <sub>function</sub>
|
||||
|
||||
Return a boolean indicating whether the specified property exists on the object as a direct own property (similar to hasOwnProperty, but directly on Object).
|
||||
|
||||
|
||||
|
||||
**obj**: The object on which to check the property.
|
||||
|
||||
**prop**: The name or Symbol of the property to check.
|
||||
|
||||
|
||||
**Returns**: True if the property is found on 'obj', otherwise false.
|
||||
|
||||
|
||||
### id(obj) <sub>function</sub>
|
||||
|
||||
Non-standard. Return a unique identifier for the given object, assigning one if necessary. The same object will always yield the same ID.
|
||||
|
||||
|
||||
|
||||
**obj**: The object to retrieve or assign a unique ID.
|
||||
|
||||
|
||||
**Returns**: A unique identifier (string or number) associated with the object.
|
||||
|
||||
|
||||
### mixin(target, source) <sub>function</sub>
|
||||
|
||||
Copy all property descriptors from 'source' into 'target'.
|
||||
|
||||
|
||||
|
||||
**target**: The object that will receive properties.
|
||||
|
||||
**source**: The object whose properties are to be copied.
|
||||
|
||||
|
||||
**Returns**: The updated 'target' object.
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
# String
|
||||
|
||||
### length <sub>number</sub>
|
||||
|
||||
### name <sub>string</sub>
|
||||
|
||||
### prototype <sub>object</sub>
|
||||
|
||||
### fromCharCode(codeUnits) <sub>function</sub>
|
||||
|
||||
Return a string created from the specified sequence of UTF-16 code units.
|
||||
Each argument is treated as a code unit in the range [0, 65535].
|
||||
|
||||
|
||||
|
||||
**codeUnits**: A series of numbers representing UTF-16 code units.
|
||||
|
||||
|
||||
**Returns**: A string constructed by mapping each code unit to a character.
|
||||
|
||||
|
||||
### fromCodePoint(codePoints) <sub>function</sub>
|
||||
|
||||
Return a string created from the specified sequence of code points,
|
||||
including those above U+FFFF (which will become surrogate pairs).
|
||||
Throws a RangeError for invalid code points.
|
||||
|
||||
|
||||
|
||||
**codePoints**: A series of numbers representing Unicode code points.
|
||||
|
||||
|
||||
**Returns**: A string constructed from the given code points.
|
||||
|
||||
|
||||
### raw(template, substitutions) <sub>function</sub>
|
||||
|
||||
A tag function of template literals that returns a raw where escape sequences (e.g., '\n', '\u00A9') are not processed.
|
||||
Commonly used to retrieve the unprocessed text of a template.
|
||||
|
||||
|
||||
|
||||
**template**: A template literal, or an object with a 'raw' property.
|
||||
|
||||
**substitutions**: Additional values to substitute (if any).
|
||||
|
||||
|
||||
**Returns**: The combined raw string from the template.
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
# Symbol
|
||||
|
||||
### length <sub>number</sub>
|
||||
|
||||
### name <sub>string</sub>
|
||||
|
||||
### prototype <sub>object</sub>
|
||||
|
||||
### for(key) <sub>function</sub>
|
||||
|
||||
Search the global symbol registry for a symbol with the given key. If found, return that symbol; otherwise, create a new symbol with that key and add it to the registry, then return the new symbol.
|
||||
|
||||
|
||||
|
||||
**key**: A string key used to identify the symbol in the global registry.
|
||||
|
||||
|
||||
**Returns**: A symbol associated with the given key in the global registry.
|
||||
|
||||
|
||||
### keyFor(sym) <sub>function</sub>
|
||||
|
||||
Retrieve a shared symbol’s key from the global symbol registry. If the symbol is not in the global registry, return undefined.
|
||||
|
||||
|
||||
|
||||
**sym**: The symbol to find the key for.
|
||||
|
||||
|
||||
**Returns**: The string key if 'sym' is a global symbol, otherwise undefined.
|
||||
|
||||
|
||||
### toPrimitive <sub>symbol</sub>
|
||||
|
||||
### iterator <sub>symbol</sub>
|
||||
|
||||
### match <sub>symbol</sub>
|
||||
|
||||
### matchAll <sub>symbol</sub>
|
||||
|
||||
### replace <sub>symbol</sub>
|
||||
|
||||
### search <sub>symbol</sub>
|
||||
|
||||
### split <sub>symbol</sub>
|
||||
|
||||
### toStringTag <sub>symbol</sub>
|
||||
|
||||
### isConcatSpreadable <sub>symbol</sub>
|
||||
|
||||
### hasInstance <sub>symbol</sub>
|
||||
|
||||
### species <sub>symbol</sub>
|
||||
|
||||
### unscopables <sub>symbol</sub>
|
||||
|
||||
### asyncIterator <sub>symbol</sub>
|
||||
|
||||
### operatorSet <sub>symbol</sub>
|
||||
@@ -1,15 +0,0 @@
|
||||
# Appendix A - The Dull Programming Language: Extensions to Javascript
|
||||
|
||||

|
||||
|
||||
The language is dubbed "dull". Dull, because it is a less featureful Javascript. Where does it differ?
|
||||
|
||||
- No promises, async, await, generators ...
|
||||
- No import/export syntax; 'use' instead
|
||||
- No proxies
|
||||
|
||||
We gave it this name to make very clear this is NOT the javascript of the web. This is its own thing, with its own ideas.
|
||||
|
||||
Eventually, it could be JIT'd, but another trait of dull is that it is easy to integrate C code into. That is preferred over doing stuff strictly in dull.
|
||||
|
||||
Dull has C-like syntax, because that makes it trivial to push code from it into a real C file.
|
||||
@@ -1,3 +0,0 @@
|
||||
# Building & Releasing
|
||||
|
||||
To build and release your game, simply put all of your game assets in the folder into a zip (not including prosperon itself!) named `game.zip`, and ship it in the same folder as the `prosperon` executable for the given platform. `game.zip` is mounted, if present, before any other path, so it will be explored first for assets; in effect, anything in the folder is a 'mod' for a present `game.zip`!
|
||||
@@ -1,32 +1,26 @@
|
||||
# Preface: The Prosperon Vision
|
||||
# Preface: The Cell Environment
|
||||
|
||||

|
||||
|
||||
Prosperon is based around a Javascript-like language, DullJS, termed henceforth "dull", engineered to be the quickest way to make computer games. "Dull" will be explored in more detail, but for all intents and purposes it **is** Javascript, with a handful of ES6 features removed. We've given it its own name to crush from the outset any idea that what you're dealing with a web styled Javascript environment!
|
||||
Cell is an actor based scripting language.
|
||||
|
||||
## The Vision
|
||||
The less lines of code it takes to do something, the less your program does. The less your program does, the faster it is, and the fewer bugs it has. And, the less the developer needs to keep in their head, the less bugs and more understandable a program is.
|
||||
The idea is to author c code and orchestrate it using cell script, in an actor based environment, and deploy it on many platforms.
|
||||
|
||||
Prosperon is designed to achieve a minimal number of lines of code when creating a game. Prosperon is designed to be the **best** way to make computer games, quickly.
|
||||
## Building code
|
||||
There are two ways to run cell:
|
||||
|
||||
1. **Flexible API**
|
||||
A lot of the API usage is informed from 'duck typing'. If something "looks" like a camera - it can be used like one! If something "looks" like a sprite, it can be used like one! This means that if you create an enemy in the game, you may be able to pass it in to render, while in other more strict languages, you might need to create an intermediate "sprite" object.
|
||||
The dev environment is highly dynamic and available only on platforms with dynamic library loading. It lets you spawn actors and test quickly.
|
||||
|
||||
2. **Uniformity**
|
||||
Javascript has the brilliant object idea, which is used and abused everywhere in prosperon. Objects allow for a huge variety of ideas to be expressed, and act as an ideal transferring tool between the disparate parts of a computer game. Dull, our dumbed down javascript, uses objects and closures to a greater extent than modern javascript, **without** losing any of the features. There is less syntax to remember, meaning it is quicker to get code down.
|
||||
Cake is a static builder for cell, which lets you bundle a package into a static executable for a variety of target platforms.
|
||||
|
||||
3. **Highly reflective**
|
||||
Built in tools to give an overview of your game. Prosperon can tell you where and how many certain entities are created, how much space they use, and so on. Prosperon can generate an textual overview of your game, resulting in documentation.
|
||||
## Packages
|
||||
Cell doesn't assume an underlying file system.
|
||||
|
||||
4. **Text based**
|
||||
Prosperon is totally text based. It uses a script based scene structure, where scripts spawn each other and concatenate onto each other to create objects in a scene in a flexible way. This allows for a first class experience with SCM tools, and allows for easy multi user collaboration.
|
||||
Packages are the fundamental cell unit. A package is made up of a variety of cell script files and potentially C files. When bundling, everything in a package is bundled together; when running in dev, everything in a package is loaded dynamically.
|
||||
|
||||
4. **Gradual Performance**
|
||||
There are fast paths on nearly everything for well defined objects. For most use cases, the flexible, duck typing works. But in specific circumstances, where speed is required, it's possible.
|
||||
Cell code is written with cellscript.
|
||||
|
||||
5. **Interactive**
|
||||
Whenever there is a question of feature, Prosperon chooses the interactive path. Games are interactive. That means you want it to be totally dynamic and fast. Prosperon is designed to favor, for example, generated MIDI music, which you might be able to sync to goblin death animations, over static MP3 files.
|
||||
## Modules and programs
|
||||
A module returns a single object. This can be a function, an object of functions, a number, a string, whatever. It is included with the "use" keyword, ie, use('<package>/<module path>').
|
||||
|
||||
## Installation
|
||||
|
||||
Just grab the prosperon build for your platform, drop it in a folder, and run it. Prosperon is a tiny executable, so it's recommended to version it with your project.
|
||||
A program doesn't return anything. A program is an actor, with its own memory space. Actors do not share memory. Actors can send messages to each other.
|
||||
@@ -1,54 +0,0 @@
|
||||
# Program events and an example input system
|
||||
|
||||
Prosperon provides a handy `input` module. Input is done in a highly generic and customizable manner. *players* can take control of any object (actor or otherwise) in Prosperon, after which it is referred to as a *pawn* of a player. If the object has a defined *input* object, it is a valid pawn. One player can have many pawns, but each pawn may have only one player.
|
||||
|
||||
Pawns are added as a stack, with the newest ones getting priority, and handled first. It is possible for pawns to block input to lower pawns on the stack.
|
||||
|
||||
```
|
||||
*newest*
|
||||
car <== When a key is pressed, this is the first pawn to handle input
|
||||
player
|
||||
ui <== /block/ is set to true here, so editor recieves no input!
|
||||
editor
|
||||
*oldest*
|
||||
```
|
||||
|
||||
The default player can be obtained with `Player.players[0]`. Players are all local, and the highest number is determined by platform.
|
||||
|
||||
The **input** object defines a number of keys or actions, with their values being functions.
|
||||
|
||||
## Editor input
|
||||
The editor input style defines keystrokes. It is good for custom editors, or any sort of game that requires many hotkeys. Keystrokes are case sensitive and can be augmented with auxiliary keys.
|
||||
|
||||
| symbol | key |
|
||||
|--------|-------|
|
||||
| C | ctrl |
|
||||
| M | alt |
|
||||
| S | super |
|
||||
|
||||
```
|
||||
var input = use('input')
|
||||
var orc = this.spawn('orc');
|
||||
orc.inputs = {};
|
||||
orc.inputs.a = function() { ... };
|
||||
orc.inputs.A = function() { ... }; /* This is only called with a capital A! */
|
||||
orc.inputs['C-a'] = function() { ... }; /* Control-a */
|
||||
input.players[0].control(orc); /* player 0 is now in control of the orc */
|
||||
```
|
||||
|
||||
The input object can be modified to customize how it handles input.
|
||||
|
||||
| property | type | effect |
|
||||
|----------------|----------|--------------------------------------|
|
||||
| post | function | called after any input is processed |
|
||||
| =release_post= | function | called after any input is released |
|
||||
| fallthru | bool | false if input should stop with this |
|
||||
| block | bool | true if input should stop with this |
|
||||
|
||||
The input can be modified by setting properties on the associated function.
|
||||
|
||||
| property | type | effect |
|
||||
|----------|----------|--------------------------------------------------------|
|
||||
| released | function | Called when the input is released |
|
||||
| rep | bool | true if holding the input should repeatedly trigger it |
|
||||
| down | function | called while the input is down |
|
||||
@@ -1,41 +0,0 @@
|
||||
site_name: Prosperon Documentation
|
||||
|
||||
plugins:
|
||||
- search
|
||||
- awesome-pages
|
||||
- mike
|
||||
|
||||
extra_css:
|
||||
- style.css
|
||||
|
||||
theme:
|
||||
name: material
|
||||
navigation_depth: 3
|
||||
logo: prosperon.gif
|
||||
favicon: favicon.gif
|
||||
features:
|
||||
- content.action.view
|
||||
- navigation.prune
|
||||
- navigation.indexes
|
||||
- search.suggest
|
||||
- search.highlight
|
||||
- toc.follow
|
||||
icon:
|
||||
view: material/eye
|
||||
palette:
|
||||
scheme: youtube
|
||||
|
||||
extra:
|
||||
social:
|
||||
- icon: fontawesome/brands/x-twitter
|
||||
link: https://x.com/@pockleworld
|
||||
analytics:
|
||||
provider: google
|
||||
property: G-85ECSFGCBV
|
||||
version:
|
||||
default: latest
|
||||
provider: mike
|
||||
|
||||
markdown_extensions:
|
||||
- admonition
|
||||
- tables
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 76 KiB |
@@ -1,133 +0,0 @@
|
||||
# Quickstart
|
||||
|
||||
This quickstart walks through running Cell programs, exploring examples, and creating your first module and program. It assumes the `./cell` executable is present at the repo root (already built or downloaded).
|
||||
|
||||
## 1) Initialize a Project Shop (.cell)
|
||||
|
||||
Create the project structure used for module management and bytecode cache:
|
||||
|
||||
- `./cell init`
|
||||
|
||||
This creates `.cell/` with `cell.toml`, `lock.toml`, `modules/`, `build/`, and `patches/`.
|
||||
|
||||
## 2) Run Built‑in Examples
|
||||
|
||||
Examples under `examples/` are programs (`*.ce`) you can run directly:
|
||||
|
||||
- NAT portal server (introduction service):
|
||||
- `./cell examples/nat`
|
||||
- NAT client (contacts a portal):
|
||||
- `./cell examples/nat_client`
|
||||
- Non‑blocking HTTP download actor:
|
||||
- `./cell examples/http_download_actor`
|
||||
|
||||
Tip: Use these as references for portals, contacts, and non‑blocking I/O.
|
||||
|
||||
## 3) Run the Accio Game
|
||||
|
||||
Accio lives under `accio/`. The program is `accio/accio.ce` and supports modes via arguments:
|
||||
|
||||
- Start menu: `./cell accio start`
|
||||
- Load a level: `./cell accio level game/1.json`
|
||||
- Analyze assets: `./cell accio analyze`
|
||||
- Clean level data: `./cell accio clean`
|
||||
|
||||
Arguments after the program path are available inside the program via `arg` (e.g., `arg[0] == 'start'`).
|
||||
|
||||
## 4) Your First Module (.cm) and Program (.ce)
|
||||
|
||||
Create a module that returns a frozen API object, and a program that uses it.
|
||||
|
||||
- File: `examples/hello.cm` (module)
|
||||
|
||||
```javascript
|
||||
// Returns a value (frozen by the engine)
|
||||
return {
|
||||
greet: function(name) {
|
||||
return `Hello, ${name}!`
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- File: `examples/hello.ce` (program)
|
||||
|
||||
```javascript
|
||||
var hello = use('examples/hello')
|
||||
|
||||
log.console(hello.greet('Cell'))
|
||||
|
||||
$_.receiver(function(msg) {
|
||||
if (msg.type == 'ping') {
|
||||
send(msg, {type:'pong'})
|
||||
}
|
||||
})
|
||||
|
||||
$_.delay(_ => $_.stop(), 0.1)
|
||||
```
|
||||
|
||||
Run it:
|
||||
|
||||
- `./cell examples/hello`
|
||||
|
||||
Notes:
|
||||
- Modules are `*.cm` and must return a value. The engine deep‑freezes return values, so mutate via new objects or closures rather than in‑place.
|
||||
- Programs are `*.ce` and must not return a value. They run top‑to‑bottom when spawned and can register handlers via `$_.receiver()` and schedule work via `$_.delay()` or `$_.clock()`.
|
||||
|
||||
## 5) Spawning Child Programs (Actors)
|
||||
|
||||
Programs can spawn other programs and receive lifecycle events.
|
||||
|
||||
- File: `examples/spawner.ce`
|
||||
|
||||
```javascript
|
||||
$_.receiver(function(e) {
|
||||
if (e.type == 'greet' && e.actor) {
|
||||
log.console('Child greeted me')
|
||||
}
|
||||
})
|
||||
|
||||
$_.start(function(info) {
|
||||
if (info.type == 'greet') {
|
||||
log.console('Spawned child actor')
|
||||
}
|
||||
}, 'examples/hello.ce')
|
||||
|
||||
$_.delay(_ => $_.stop(), 0.5)
|
||||
```
|
||||
|
||||
Run it:
|
||||
|
||||
- `./cell examples/spawner`
|
||||
|
||||
## 6) Module Shop Basics
|
||||
|
||||
The module shop manages vendored dependencies under `.cell/modules/` and caches compiled bytecode under `.cell/build/`.
|
||||
|
||||
Common commands (all are programs under `scripts/`):
|
||||
|
||||
- Initialize (if you haven’t already):
|
||||
- `./cell init`
|
||||
- See available commands:
|
||||
- `./cell help`
|
||||
- Configure system/actor settings:
|
||||
- `./cell config list`
|
||||
- `./cell config set system.reply_timeout 60`
|
||||
- `./cell config actor prosperon/_sdl_video set resolution 1280x720`
|
||||
- Download or vendor dependencies (from `.cell/cell.toml`):
|
||||
- `./cell mod download`
|
||||
|
||||
## 7) How Module Resolution Works
|
||||
|
||||
- `use('path')` checks:
|
||||
1) The current module’s directory for `path.cm` while loading.
|
||||
2) The mounted roots (the program’s directory is mounted) for `path.cm`.
|
||||
3) Embedded/native modules if no script file is found.
|
||||
- Modules compile to `.cell/build/<canonical-path>.o` and reuse the cache if newer than the source.
|
||||
- Scripted modules can extend embedded modules via prototype; if the script returns nothing, the embedded module is used as‑is.
|
||||
|
||||
## 8) Next Steps
|
||||
|
||||
- Language details: `docs/cell.md`
|
||||
- Actors, programs, and messaging: `docs/actors.md`
|
||||
- Rendering, input, and resources: `docs/rendering.md`, `docs/input.md`, `docs/resources.md`
|
||||
- Full API reference: `docs/api/`
|
||||
@@ -1,36 +0,0 @@
|
||||
# Rendering, the camera & the world
|
||||
|
||||
Prosperon is rendered via a single camera, defined on `prosperon.camera`. Examine the `camera` object in the API for detail about its properties.
|
||||
|
||||
The camera has a width and a height, which defines the resolution of the rendered game. The camera also has a transform `prosperon.camera.transform`, which should be used to move it. The camera's position can also be set via `prosperon.camera.pos`.
|
||||
|
||||
## Coordinate System
|
||||
There are two important coordinate systems in Prosperon: world and hud. Both coordinate systems are measured in pixels, with X+ going to the right, and Y+ going up.
|
||||
|
||||
**World space** is the game world, and is what the camera "sees". The center of the camera is the coordinate it is viewing; so, for example, if the camera is at position [100,100], the pixel at the center of the screen is whatever pixel is at world space [100,100].
|
||||
|
||||
**Hud space** can be thought of as the screen itself, or the lens of the camera. The bottom left of the viewing window is [0,0], and the top right is [camera.width, camera.height].
|
||||
|
||||
## The render module & queues
|
||||
Internally, prosperon keeps a rendering queue as draw commands are issued throughout the frame. It keeps two: 'draw' and 'hud'. At the end of the frame, draw commands are sorted and issued to the GPU: first the 'draw' queue, and then the 'hud' queue, so that it overlays.
|
||||
|
||||
The render module contains functionality for low level rendering. It includes commands like 'scissor' and 'viewport', it is more recommended to use the 'draw2d' module to do the majority of the drawing.
|
||||
|
||||
## Draw2d
|
||||
The easiest way to draw with prosperon is to use the 'draw2d' module. Prosperon defines two events via `prosperon.on`: `draw` and `hud`. During a frame, the `render` module sets its internal queue to `draw`, and then the `draw` event is issued. Then it does the same for `hud`. The 'draw2d' module is a high level way to issue drawing commands to the current queue. So, a simple example:
|
||||
|
||||
```
|
||||
var draw = use('draw2d')
|
||||
// main.js
|
||||
var rect = {x:0,y:0,width:100,height:100} // a 100x100 square at [0,0]
|
||||
this.draw = function() {
|
||||
draw.rectangle(rect) // this will draw with the bottom left corner at the center of the screen
|
||||
}
|
||||
|
||||
this.hud = function() {
|
||||
draw.rectangle(rect) // this draws a rectangle at the botomm left corner of the screen
|
||||
}
|
||||
```
|
||||
|
||||
## Imgui
|
||||
Prosperon includes imgui. Another event is the `imgui` event, where you can issue imguie commands via the 'imgui' module. Examine the 'imgui' API for more info.
|
||||
@@ -1,17 +0,0 @@
|
||||
mkdocs==1.6.0
|
||||
mkdocs-material==9.5.28
|
||||
mkdocs-awesome-pages-plugin==2.10.1
|
||||
pymdown-extensions==10.7
|
||||
Markdown==3.5.2
|
||||
mergedeep==1.3.4
|
||||
bracex==2.5.post1
|
||||
PyYAML==6.0.1
|
||||
click==8.1.7
|
||||
colorama==0.4.6
|
||||
Jinja2==3.1.3
|
||||
natsort==8.4.0
|
||||
packaging==23.2
|
||||
Pygments==2.17.2
|
||||
requests==2.32.3
|
||||
ghp-import==2.1.0
|
||||
watchdog==4.0.0
|
||||
@@ -1,17 +0,0 @@
|
||||
# Resources & Data
|
||||
|
||||
Prosperon, being text based, encourages you to reference assets - images, sounds, etc - as strings.
|
||||
|
||||
## Module Loading and Discovery
|
||||
|
||||
Prosperon uses a set of **search paths** to locate modules. Each path in this list is consulted in order, and the first matching module file is loaded.
|
||||
**prosperon.PATH** is an array which is a list of directories in which it looks for resources. Developers can add or remove entries from this list, controlling where the engine will search. Assets are searched from `prosperon.PATH[0]` first.
|
||||
|
||||
**Extension Matching:** Assets should be referenced without a file extension. Based on the context of what asset is being searched for, a list of file extensions are iterated through to find the asset. When setting a sprite's texture, for example, first a 'png' may be searched for, then a 'gif', and so on. If a specific extension is requested, that specific extension - and only that one - will be searched for. it's very useful to not specify extensions at all, because that enables prosperon to optimize assets and replace them with backend specific ones, and the game will still work.
|
||||
|
||||
Prosperon **caches** each loaded assets. When a sprite references a 'png', if another one does, it uses the same GPU texture.
|
||||
|
||||
## Mounts
|
||||
Prosperon uses the idea of file mounting for all io operations. To start with, the write directory is set to the folder prosperon is ran from. That same folder is also mounted as a read directory, as well as the executable itself, which contains a zip file of the engine's core assets.
|
||||
|
||||
Folders or archives like zip records can be mounted, allowing for an easy way to overwrite specific files with new ones. Because prosperon deals with file systems and strings for its operations, this makes modding easy. For example, a mod `mod.zip` may have a file `sprites/bug.png`. Once mounted, when your game loads `bug` as a sprite, that would be grabbed instead of your game's natives `bug`.
|
||||
133
docs/style.css
133
docs/style.css
@@ -1,133 +0,0 @@
|
||||
[data-md-color-scheme="youtube"] {
|
||||
--md-primary-fg-color: #3876AD;
|
||||
--md-accent-fg-color: #94DBE8
|
||||
}
|
||||
|
||||
a:link a:visited a:hover a:active {
|
||||
color: green;
|
||||
}
|
||||
|
||||
#content {
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
html {
|
||||
scroll-padding-top:50px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: red
|
||||
}
|
||||
|
||||
#text-table-of-contents {
|
||||
background-color: #ffffec;
|
||||
border: solid;
|
||||
border-width: 2px;
|
||||
border-color: #61bcd7;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.scholium {
|
||||
background-color: #F5F5DE;
|
||||
border: solid;
|
||||
padding: 10px;
|
||||
margin: 20px;
|
||||
border-width: 2px;
|
||||
border-color: #75FB4C;
|
||||
}
|
||||
|
||||
.scholium p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.floathead {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 100;
|
||||
display flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: #3876AD;
|
||||
}
|
||||
|
||||
.floathead a {
|
||||
float: left; /* Float links side by side */
|
||||
line-height: 100%;
|
||||
margin-left: 20px;
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
height: 3rem;
|
||||
line-height: 3rem;
|
||||
text-align: center; /* Center-align text */
|
||||
font-size: 24px;
|
||||
color: #61bcd7;
|
||||
}
|
||||
|
||||
#content {
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
.floathead a:hover {
|
||||
color: white;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #61BCD7;
|
||||
}
|
||||
|
||||
#org-div-home-and-up {
|
||||
position: sticky;
|
||||
top: 20px;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: code;
|
||||
color: #61bcd7;
|
||||
}
|
||||
|
||||
.example {
|
||||
margin: 10px 20px;
|
||||
padding: 20px;
|
||||
font-family: code;
|
||||
font-size: 16px;
|
||||
line-height: 1em;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.code {
|
||||
padding: 2px 5px;
|
||||
background-color: rgba(var(--bs-body-bg-rgb), 0.75);
|
||||
border: solid 1px var(--bs-border-color);
|
||||
color: var(--bs-body-color);
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-family: arial;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "code";
|
||||
src: url(dos.ttf);
|
||||
}
|
||||
|
||||
.navbar {
|
||||
background-color: #1678b2;
|
||||
}
|
||||
|
||||
.navbar-brand span {
|
||||
margin-top: 10px;
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.terminal-prompt {
|
||||
background-image: url(/prosperon_orb_horizontal.gif);
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.wm-page-toc-tree li:first-of-type{display:none}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user