bobzhang/p5/webgl does not have a README file

    BoundingBox

    pub struct BoundingBox {
    min : Vec3
    max : Vec3
    size : Vec3
    offset : Vec3
    } derive(
    Debug
    )

    A geometry's axis-aligned bounds (calculateBoundingBox).

    Camera

    pub struct Camera {
    width : Double
    height : Double
    camera_type_default : Bool
    use_line_perspective : Bool
    camera_matrix :
    Matrix

    proj_matrix :
    Matrix

    y_scale : Double
    eye_x : Double
    eye_y : Double
    eye_z : Double
    center_x : Double
    center_y : Double
    center_z : Double
    up_x : Double
    up_y : Double
    up_z : Double
    camera_fov : Double
    aspect_ratio : Double
    camera_near : Double
    camera_far : Double
    default_aspect_ratio : Double
    default_eye_z : Double
    default_camera_fov : Double
    default_camera_near : Double
    default_camera_far : Double
    }

    A camera: eye, center and up vectors plus a projection.

    Camera::axes

    fn Camera::axes(self : Camera) -> ((Double, Double, Double), (Double, Double, Double), (Double, Double, Double))

    The camera's local axes (x, y, z), each as a tuple.

    Camera::camera

    fn Camera::camera(self : Camera, eye? : (Double, Double, Double), center? : (Double, Double, Double), up? : (Double, Double, Double)) -> Unit

    Places the camera; with no arguments, the default camera.

    Camera::copy

    fn Camera::copy(self : Camera) -> Camera

    Camera::frustum

    fn Camera::frustum(self : Camera, left? : Double, right? : Double, bottom? : Double, top? : Double, near? : Double, far? : Double) -> Unit

    A frustum projection; omitted values use p5's defaults.

    Camera::look_at

    fn Camera::look_at(self : Camera, x : Double, y : Double, z : Double) -> Unit

    Points the camera at (x, y, z).

    Camera::move_by

    fn Camera::move_by(self : Camera, x : Double, y : Double, z : Double) -> Unit

    Moves the camera along its own axes.

    Camera::new

    fn Camera::new(width : Double, height : Double) -> Camera

    A camera for a width × height view with p5's default settings.

    Camera::orbit

    fn Camera::orbit(self : Camera, d_theta : Double, d_phi : Double, d_radius : Double) -> Unit

    Orbits around the center (_orbit): azimuth, polar change, and a log10 zoom factor.

    Camera::ortho

    fn Camera::ortho(self : Camera, left? : Double, right? : Double, bottom? : Double, top? : Double, near? : Double, far? : Double) -> Unit

    An orthographic projection; omitted values fit the canvas.

    Camera::pan

    fn Camera::pan(self : Camera, angle : Double) -> Unit

    Rotates the view left/right (radians) about the camera's y-axis.

    Camera::perspective

    fn Camera::perspective(self : Camera, fovy? : Double, aspect? : Double, near? : Double, far? : Double) -> Unit

    A perspective projection; omitted values use the defaults.

    Camera::resize

    fn Camera::resize(self : Camera, width : Double, height : Double) -> Unit

    Re-derives the default projection after a canvas resize.

    Camera::roll

    fn Camera::roll(self : Camera, angle : Double) -> Unit

    Rotates the camera about its own z-axis (the viewing direction) by angle radians.

    Camera::set_position

    fn Camera::set_position(self : Camera, x : Double, y : Double, z : Double) -> Unit

    Moves the eye to (x, y, z) keeping the view direction.

    Camera::tilt

    fn Camera::tilt(self : Camera, angle : Double) -> Unit

    Rotates the view up/down (radians) about the camera's x-axis.

    Camera::zoom_projection

    fn Camera::zoom_projection(self : Camera, factor : Double) -> Unit

    Scales the projection's x/y focal terms (perspective zoom in orbitControl).

    DrawMode

    pub(all) enum DrawMode {
    Triangles
    TriangleStrip
    TriangleFan
    }

    Draw modes for geometry without faces.

    Filter2D

    pub struct Filter2D {
    // private fields
    }

    Runs p5's filter shaders over a 2D canvas on a helper WebGL canvas.

    Filter2D::new

    fn Filter2D::new(w : Double, h : Double) -> Filter2D

    A helper of w × h pixels (p5 sizes it in CSS pixels).

    Filter2D::pass

    fn Filter2D::pass(self : Filter2D, op : String, param : Double?, direction : (Double, Double), src :
    ImageElement
    , w : Double, h : Double, density : Double, user? : Shader) ->
    ImageElement
    ?

    One render pass: the filtered src (a w × h canvas at density) into the helper canvas, which is returned as an image source.

    Framebuffer

    pub struct Framebuffer {
    width : Double
    height : Double
    density : Double
    antialias : Bool
    default_camera : Camera
    // private fields
    }

    An offscreen drawing surface that can be used as a texture.

    Framebuffer::auto_sized

    fn Framebuffer::auto_sized(self : Framebuffer) -> Bool

    Whether the framebuffer follows the canvas size (autoSized()).

    Framebuffer::begin

    fn Framebuffer::begin(self : Framebuffer) -> Unit

    Starts drawing into the framebuffer.

    Framebuffer::canvas_resized

    fn Framebuffer::canvas_resized(self : Framebuffer) -> Unit

    Follows the canvas size when the canvas is resized.

    Framebuffer::draw

    fn Framebuffer::draw(self : Framebuffer, f : () -> Unit) -> Unit

    Draws into the framebuffer with f between begin() and end().

    Framebuffer::end

    fn Framebuffer::end(self : Framebuffer) -> Unit

    Stops drawing into the framebuffer.

    Framebuffer::pixel_density

    fn Framebuffer::pixel_density(self : Framebuffer, d : Double) -> Unit

    Sets the pixel density.

    Framebuffer::read_pixels

    fn Framebuffer::read_pixels(self : Framebuffer) -> FixedArray[Byte]

    Reads the framebuffer's pixels (RGBA, top row first, device pixels).

    Framebuffer::remove

    fn Framebuffer::remove(self : Framebuffer) -> Unit

    Deletes the framebuffer's GL resources.

    Framebuffer::resize

    fn Framebuffer::resize(self : Framebuffer, w : Double, h : Double) -> Unit

    Resizes the framebuffer (contents are cleared).

    Framebuffer::set_auto_sized

    fn Framebuffer::set_auto_sized(self : Framebuffer, on : Bool) -> Unit

    Makes the framebuffer follow the canvas size, or keep its own (autoSized(bool)); following resizes it to the canvas right away.

    Framebuffer::source

    fn Framebuffer::source(self : Framebuffer) -> TexSource

    The framebuffer as a texture source.

    FramebufferOptions

    pub(all) struct FramebufferOptions {
    width : Double?
    height : Double?
    density : Double?
    antialias : Int?
    depth : Bool
    stencil : Bool
    depth_float : Bool
    alpha : Bool?
    linear : Bool
    }

    Options for create_framebuffer.

    FramebufferOptions::default

    p5's defaults.

    GLState

    pub struct GLState {
    model :
    Matrix

    view :
    Matrix

    proj :
    Matrix

    camera : Camera
    normal_material : Bool
    enable_lighting : Bool
    ambient_light_colors : Array[Double]
    specular_colors : Array[Double]
    directional_directions : Array[Double]
    directional_diffuse : Array[Double]
    directional_specular : Array[Double]
    point_positions : Array[Double]
    point_diffuse : Array[Double]
    point_specular : Array[Double]
    spot_positions : Array[Double]
    spot_directions : Array[Double]
    spot_diffuse : Array[Double]
    spot_specular : Array[Double]
    spot_angle : Array[Double]
    spot_conc : Array[Double]
    constant_attenuation : Double
    linear_attenuation : Double
    quadratic_attenuation : Double
    ambient_color : FixedArray[Double]
    specular_color : FixedArray[Double]
    emissive_color : FixedArray[Double]
    has_set_ambient : Bool
    use_specular : Bool
    use_emissive : Bool
    shininess : Double
    metalness : Double
    tint : FixedArray[Double]
    fill_shader : Shader?
    stroke_shader : Shader?
    tex : TexSource?
    image_shader : Shader?
    texture_mode_normal : Bool
    wrap_x : String
    wrap_y : String
    image_light : TexSource?
    specular_tex : TexSource?
    ambient_tex : TexSource?
    shininess_tex : TexSource?
    normal_tex : TexSource?
    normal_scale : Double
    normal_map_mode : Int
    }

    Renderer state saved by push()/pop() (p5's states).

    Geometry

    pub struct Geometry {
    gid : String
    detail_x : Int
    detail_y : Int
    vertices : Array[Vec3]
    vertex_normals : Array[Vec3]
    uvs : Array[Double]
    faces : Array[(Int, Int, Int)]
    edges : Array[(Int, Int)]
    vertex_colors : Array[Double]
    vertex_stroke_colors : Array[Double]
    line_vertices : Array[Double]
    line_tangents_in : Array[Double]
    line_tangents_out : Array[Double]
    line_sides : Array[Double]
    line_vertex_colors : Array[Double]
    vertex_tangents : Array[Double]
    user_props : Array[VertexProperty]
    parts : Array[Geometry]
    part_state : PartState?
    // private fields
    }

    A mesh: p5.Geometry.

    Geometry::assign

    fn Geometry::assign(self : Geometry, other : Geometry) -> Unit

    Copies another geometry's contents into this one (used when a model finishes loading into a geometry handed out earlier).

    Geometry::average_normals

    fn Geometry::average_normals(self : Geometry) -> Geometry

    For grid meshes whose first and last columns meet (like a sphere's seam): averages their normals so no seam shows (averageNormals).

    Geometry::average_pole_normals

    fn Geometry::average_pole_normals(self : Geometry) -> Geometry

    For grid meshes with poles: averages the normals of the first and last rows (averagePoleNormals).

    Geometry::calculate_bounding_box

    fn Geometry::calculate_bounding_box(self : Geometry) -> BoundingBox

    The smallest box containing every vertex. Like p5, the starting maximum is the smallest positive number, so a mesh entirely below zero on an axis reports a maximum of about 5e-324 there.

    Geometry::clear_colors

    fn Geometry::clear_colors(self : Geometry) -> Geometry

    Removes the per-vertex fill colors, so the fill color is used (clearColors).

    Geometry::compute_faces

    fn Geometry::compute_faces(self : Geometry) -> Geometry

    Grid faces for a (detail_x + 1) × (detail_y + 1) vertex grid.

    Geometry::compute_normals

    fn Geometry::compute_normals(self : Geometry, mode? : NormalMode, round_to_precision? : Int) -> Geometry

    Computes vertex normals from the faces.

    Geometry::compute_tangents

    fn Geometry::compute_tangents(self : Geometry) -> Geometry

    Computes per-vertex surface tangents from the uvs and normals, needed for normal maps (computeTangents). Without uvs or normals the tangents are cleared.

    Geometry::edges_to_vertices

    fn Geometry::edges_to_vertices(self : Geometry, simple_lines? : Bool) -> Geometry

    Builds the stroke triangles' attributes from edges (_edgesToVertices): a quad per segment plus caps and joins unless simple_lines.

    Geometry::flip_u

    fn Geometry::flip_u(self : Geometry) -> Unit

    Mirrors texture coordinates horizontally.

    Geometry::flip_v

    fn Geometry::flip_v(self : Geometry) -> Unit

    Mirrors texture coordinates vertically.

    Geometry::get_vertex_property

    fn Geometry::get_vertex_property(self : Geometry, name : String) -> VertexProperty?

    The data of a custom vertex attribute, if the geometry has it.

    Geometry::has_fill_transparency

    fn Geometry::has_fill_transparency(self : Geometry) -> Bool

    Whether any vertex color has alpha below 1.

    Geometry::has_stroke_transparency

    fn Geometry::has_stroke_transparency(self : Geometry) -> Bool

    Geometry::make_edges_from_faces

    fn Geometry::make_edges_from_faces(self : Geometry) -> Geometry

    Builds stroke edges from the triangle faces (makeEdgesFromFaces).

    Geometry::make_triangle_edges

    fn Geometry::make_triangle_edges(self : Geometry) -> Geometry

    Edges around every triangle (_makeTriangleEdges).

    Geometry::mark_dirty

    fn Geometry::mark_dirty(self : Geometry) -> Unit

    Marks the GPU copy as stale after editing the arrays.

    Geometry::new

    fn Geometry::new(detail_x? : Int, detail_y? : Int) -> Geometry

    Geometry::normalize

    fn Geometry::normalize(self : Geometry) -> Geometry

    Scales and centers the model to fit 200 units (normalize).

    Geometry::save_obj

    fn Geometry::save_obj(self : Geometry, filename? : String) -> Unit

    Downloads the geometry as an OBJ file (saveObj).

    Geometry::save_stl

    fn Geometry::save_stl(self : Geometry, filename? : String, binary? : Bool) -> Unit

    Downloads the geometry as an STL file, ASCII by default (saveStl).

    Geometry::set_gid

    fn Geometry::set_gid(self : Geometry, gid : String) -> Unit

    Sets the cache id of the geometry.

    Geometry::to_obj

    fn Geometry::to_obj(self : Geometry) -> String

    The geometry as a Wavefront OBJ file (vertices, uvs, normals and faces).

    Geometry::to_stl

    fn Geometry::to_stl(self : Geometry, name? : String) -> String

    The geometry as an ASCII STL file; name goes on the solid line.

    Geometry::to_stl_binary

    fn Geometry::to_stl_binary(self : Geometry) -> FixedArray[Byte]

    The geometry as a binary STL file.

    Geometry::vertex_property

    fn Geometry::vertex_property(self : Geometry, name : String, data : ArrayView[Double], size? : Int) -> Unit

    Adds data for a custom vertex attribute named name, read in shaders as in/attribute of that name (vertexProperty). Without size, data is the value of the next vertex; with size, data holds values for many vertices, size numbers each.

    Material

    pub struct Material {
    diffuse : (Double, Double, Double)?
    ambient : (Double, Double, Double)?
    specular : (Double, Double, Double)?
    shininess : Double?
    opacity : Double?
    illumination : Int?
    texture_path : String?
    ambient_texture_path : String?
    specular_texture_path : String?
    shininess_texture_path : String?
    bump_texture_path : String?
    normal_texture_path : String?
    bump_scale : Double?
    texture : TexSource?
    ambient_texture : TexSource?
    specular_texture : TexSource?
    shininess_texture : TexSource?
    bump_texture : TexSource?
    normal_texture : TexSource?
    }

    A material from an MTL file. Texture paths are relative to the model; the loaded textures are filled in by the loader.

    Material::texture_maps

    fn Material::texture_maps(self : Material) -> Array[(String, (TexSource) -> Unit)]

    The texture maps of a material: its path and a setter for the loaded texture (p5's MATERIAL_TEXTURE_MAPS).

    Material::to_part_state

    fn Material::to_part_state(self : Material) -> PartState

    p5's mtlToPartState.

    NormalMode

    pub(all) enum NormalMode {
    KeepConnections
    Smooth
    }

    How compute_normals shares normals between faces.

    PartState

    pub struct PartState {
    fill : FixedArray[Double]?
    ambient : FixedArray[Double]?
    specular : FixedArray[Double]?
    shininess : Double?
    texture : TexSource?
    specular_texture : TexSource?
    ambient_texture : TexSource?
    shininess_texture : TexSource?
    normal_texture : TexSource?
    normal_scale : Double
    normal_map_mode : Int
    }

    The material of one part of a model (p5's part state). None fields leave the sketch's current material in place.

    Quat

    pub struct Quat {
    w : Double
    vec : Vec3
    } derive(
    Debug
    )

    A quaternion w + xi + yj + zk.

    Quat::conjugate

    fn Quat::conjugate(self : Quat) -> Quat

    Quat::from_axis_angle

    fn Quat::from_axis_angle(angle : Double, x : Double, y : Double, z : Double) -> Quat

    The rotation by angle radians about the axis (x, y, z).

    Quat::multiply

    fn Quat::multiply(self : Quat, q : Quat) -> Quat

    The product self × q.

    Quat::new

    fn Quat::new(w : Double, x : Double, y : Double, z : Double) -> Quat

    Quat::rotate_by

    fn Quat::rotate_by(self : Quat, axes : Quat) -> Vec3

    The vector part of axes × self × axes⁻¹ (p5's rotateBy).

    Quat::rotate_vector

    fn Quat::rotate_vector(self : Quat, p : Vec3) -> Vec3

    Rotates p by this (unit) quaternion.

    Renderer3D

    pub struct Renderer3D {
    gl :
    GL

    width : Double
    height : Double
    density : Double
    state : GLState
    main_camera : Camera
    canvas :
    ImageElement

    antialias : Bool
    curve_detail : Double
    simple_lines : Bool
    instance_count : Int
    // private fields
    }

    The WEBGL renderer of a sketch.

    Renderer3D::ambient_light

    fn Renderer3D::ambient_light(self : Renderer3D, r : Double, g : Double, b : Double) -> Unit

    Renderer3D::ambient_material

    fn Renderer3D::ambient_material(self : Renderer3D, rgba : FixedArray[Double]) -> Unit

    Renderer3D::apply_matrix

    fn Renderer3D::apply_matrix(self : Renderer3D, m : ArrayView[Double]) -> Unit

    Multiplies the model matrix by 16 column-major entries (applyMatrix).

    Renderer3D::apply_stencil_if_clipping

    fn Renderer3D::apply_stencil_if_clipping(self : Renderer3D) -> Unit

    p5's _applyStencilTestIfClipping: the stencil test follows the clip state of the current draw target.

    Renderer3D::base_shader

    fn Renderer3D::base_shader(self : Renderer3D, kind : String) -> Shader

    One of p5's default shaders: "color", "normal", "light" or "line".

    Renderer3D::begin_geometry

    fn Renderer3D::begin_geometry(self : Renderer3D) -> Unit

    Starts collecting drawn shapes into a geometry (beginGeometry).

    Renderer3D::cached_geometry

    fn Renderer3D::cached_geometry(self : Renderer3D, gid : String, make : () -> Geometry) -> Geometry

    The cached geometry gid, building it with make the first time.

    Renderer3D::camera

    fn Renderer3D::camera(self : Renderer3D, eye? : (Double, Double, Double), center? : (Double, Double, Double), up? : (Double, Double, Double)) -> Unit

    Renderer3D::clear

    fn Renderer3D::clear(self : Renderer3D, r : Double, g : Double, b : Double, a : Double) -> Unit

    Clears to a color with components in [0, 1] (clear(r, g, b, a)).

    Renderer3D::clear_depth

    fn Renderer3D::clear_depth(self : Renderer3D, depth? : Double) -> Unit

    Clears the depth buffer.

    Renderer3D::create_camera

    fn Renderer3D::create_camera(self : Renderer3D) -> Camera

    A new camera with the default settings (createCamera).

    Renderer3D::create_framebuffer

    fn Renderer3D::create_framebuffer(self : Renderer3D, options : FramebufferOptions, default_antialias : Bool) -> Framebuffer

    Creates a framebuffer (createFramebuffer).

    Renderer3D::current_camera

    fn Renderer3D::current_camera(self : Renderer3D) -> Camera

    The active camera.

    Renderer3D::directional_light

    fn Renderer3D::directional_light(self : Renderer3D, r : Double, g : Double, b : Double, x : Double, y : Double, z : Double) -> Unit

    Renderer3D::draw_geometry

    fn Renderer3D::draw_geometry(self : Renderer3D, g : Geometry, style : Style, mode? : DrawMode, count? : Int, skip_fill? : Bool) -> Unit

    Draws a geometry with the current state (_drawGeometry).

    Renderer3D::draw_scaled

    fn Renderer3D::draw_scaled(self : Renderer3D, g : Geometry, sx : Double, sy : Double, sz : Double, style : Style) -> Unit

    Draws a cached unit geometry scaled by (sx, sy, sz) (_drawGeometryScaled).

    Renderer3D::draw_shape

    fn Renderer3D::draw_shape(self : Renderer3D, kind :
    ShapeKind
    , contours : Array[Array[
    Pt
    ]], style : Style, count? : Int, user_layout? : Array[(String, Int)]) -> Unit

    Draws a shape given as vertex lists (drawShape with the ShapeBuilder): PATH shapes are tessellated; strokes follow the edges.

    Renderer3D::emissive_material

    fn Renderer3D::emissive_material(self : Renderer3D, rgba : FixedArray[Double]) -> Unit

    Renderer3D::end_geometry

    fn Renderer3D::end_geometry(self : Renderer3D) -> Geometry

    Finishes collecting and returns the geometry (endGeometry).

    Renderer3D::filter

    fn Renderer3D::filter(self : Renderer3D, op : String, param : Double?, style : Style, user : Shader?) -> Unit

    Applies a built-in filter to the canvas or active framebuffer (filter() in WEBGL). style is the sketch's current style (its fill decides whether the filter quad is drawn, as in p5).

    Renderer3D::free_geometry

    fn Renderer3D::free_geometry(self : Renderer3D, g : Geometry) -> Unit

    Releases the GPU buffers of a geometry (freeGeometry).

    Renderer3D::frustum

    fn Renderer3D::frustum(self : Renderer3D, left? : Double, right? : Double, bottom? : Double, top? : Double, near? : Double, far? : Double) -> Unit

    Renderer3D::geometry

    fn Renderer3D::geometry(self : Renderer3D, gid : String) -> Geometry?

    The cached geometry with this id.

    Renderer3D::has_geometry

    fn Renderer3D::has_geometry(self : Renderer3D, gid : String) -> Bool

    Whether a geometry with this id is cached (geometryInHash).

    Renderer3D::image

    fn Renderer3D::image(self : Renderer3D, src : TexSource, sx : Double, sy : Double, sw : Double, sh : Double, dx : Double, dy : Double, dw : Double, dh : Double, style : Style) -> Unit

    Draws an image source into the rectangle (dx, dy, dw, dh) taking the region (sx, sy, sw, sh) (image() in WEBGL): a textured quad.

    Renderer3D::image_light

    fn Renderer3D::image_light(self : Renderer3D, src : TexSource) -> Unit

    Lights the scene with an image of its surroundings from every direction (imageLight): an equirectangular (360°) image works best. Shiny materials (specular_material, shininess, metalness) reflect it.

    Renderer3D::light_falloff

    fn Renderer3D::light_falloff(self : Renderer3D, constant : Double, linear : Double, quadratic : Double) -> Unit

    Renderer3D::lights

    fn Renderer3D::lights(self : Renderer3D) -> Unit

    Gray ambient light plus a gray directional light from the front.

    Renderer3D::line_perspective

    fn Renderer3D::line_perspective(self : Renderer3D, on : Bool) -> Unit

    Turns line perspective (strokes thinning with distance) on or off.

    Renderer3D::metalness

    fn Renderer3D::metalness(self : Renderer3D, metallic : Double) -> Unit

    Renderer3D::model_matrix

    The current model matrix.

    Renderer3D::new

    fn Renderer3D::new(gl :
    GL
    , canvas :
    ImageElement
    , antialias : Bool, width : Double, height : Double, density : Double) -> Renderer3D

    A renderer drawing into gl for a width × height canvas.

    Renderer3D::no_lights

    fn Renderer3D::no_lights(self : Renderer3D) -> Unit

    Renderer3D::on_fill

    fn Renderer3D::on_fill(self : Renderer3D) -> Unit

    Called by the sketch's fill(): back to a plain fill color.

    Renderer3D::on_shader

    fn Renderer3D::on_shader(self : Renderer3D) -> Unit

    Called when a user fill shader is set (shader() turns off normalMaterial).

    Renderer3D::ortho

    fn Renderer3D::ortho(self : Renderer3D, left? : Double, right? : Double, bottom? : Double, top? : Double, near? : Double, far? : Double) -> Unit

    Renderer3D::panorama

    fn Renderer3D::panorama(self : Renderer3D, src : TexSource, style : Style) -> Unit

    Draws a 360° equirectangular image as the background, seen through the active camera (panorama). Call it first in draw.

    Renderer3D::perspective

    fn Renderer3D::perspective(self : Renderer3D, fovy? : Double, aspect? : Double, near? : Double, far? : Double) -> Unit

    Renderer3D::point_light

    fn Renderer3D::point_light(self : Renderer3D, r : Double, g : Double, b : Double, x : Double, y : Double, z : Double) -> Unit

    Renderer3D::pop

    fn Renderer3D::pop(self : Renderer3D) -> Unit

    Restores the renderer state (pop()).

    Renderer3D::push

    fn Renderer3D::push(self : Renderer3D) -> Unit

    Saves the renderer state (push()).

    Renderer3D::read_pixels

    fn Renderer3D::read_pixels(self : Renderer3D, x : Int, y : Int, w : Int, h : Int) -> FixedArray[Byte]

    Reads RGBA pixels (top row first) from the drawing buffer.

    Renderer3D::render_text

    fn Renderer3D::render_text(self : Renderer3D, font_key : String, data :
    FontData
    , line : String, x : Double, y : Double, size : Double, fill : FixedArray[Double], style : Style) -> Unit

    Draws one line of text at (x, y) with a loaded font (p5's _renderText in WEBGL). fill is the text color (RGBA in [0, 1]).

    Renderer3D::reset_matrix

    fn Renderer3D::reset_matrix(self : Renderer3D) -> Unit

    Renderer3D::resize

    fn Renderer3D::resize(self : Renderer3D, w : Double, h : Double, density : Double) -> Unit

    Resizes the drawing buffer's viewport and the default camera.

    Renderer3D::rotate

    fn Renderer3D::rotate(self : Renderer3D, angle : Double, x : Double, y : Double, z : Double) -> Unit

    Rotates by angle radians about (x, y, z).

    Renderer3D::scale

    fn Renderer3D::scale(self : Renderer3D, x : Double, y : Double, z : Double) -> Unit

    Renderer3D::set_camera

    fn Renderer3D::set_camera(self : Renderer3D, cam : Camera) -> Unit

    Makes cam the active camera (setCamera).

    Renderer3D::set_clip_applied

    fn Renderer3D::set_clip_applied(self : Renderer3D, on : Bool) -> Unit

    Marks whether a clip applies to the current draw target (the canvas or the active framebuffer), turning the stencil test on or off.

    Renderer3D::set_curve_detail

    fn Renderer3D::set_curve_detail(self : Renderer3D, d : Double) -> Unit

    Sets how many points per unit length curves are sampled with.

    Renderer3D::set_fill_shader

    fn Renderer3D::set_fill_shader(self : Renderer3D, s : Shader?) -> Unit

    Sets a user fill shader (shader()), or None (resetShader()).

    Renderer3D::set_has_ambient

    fn Renderer3D::set_has_ambient(self : Renderer3D) -> Unit

    Marks the ambient material color as set (by ambient_texture).

    Renderer3D::set_image_shader

    fn Renderer3D::set_image_shader(self : Renderer3D, s : Shader?) -> Unit

    Sets a user shader for image() (imageShader), or None.

    Renderer3D::set_instance_count

    fn Renderer3D::set_instance_count(self : Renderer3D, n : Int) -> Unit

    Sets how many instances each primitive draws.

    Renderer3D::set_model_matrix

    fn Renderer3D::set_model_matrix(self : Renderer3D, m :
    Matrix
    ) -> Unit

    Replaces the model matrix.

    Renderer3D::set_simple_lines

    fn Renderer3D::set_simple_lines(self : Renderer3D, on : Bool) -> Unit

    Plain GL lines (true) or full strokes with caps and joins.

    Renderer3D::set_stroke_shader

    fn Renderer3D::set_stroke_shader(self : Renderer3D, s : Shader?) -> Unit

    Renderer3D::set_tint

    fn Renderer3D::set_tint(self : Renderer3D, rgba : FixedArray[Double]) -> Unit

    Sets the tint used for textures (0-255 RGBA).

    Renderer3D::shininess

    fn Renderer3D::shininess(self : Renderer3D, shine : Double) -> Unit

    Renderer3D::specular_color

    fn Renderer3D::specular_color(self : Renderer3D, r : Double, g : Double, b : Double) -> Unit

    The specular color of lights created after this call.

    Renderer3D::specular_material

    fn Renderer3D::specular_material(self : Renderer3D, rgba : FixedArray[Double]) -> Unit

    Renderer3D::spot_light

    fn Renderer3D::spot_light(self : Renderer3D, r : Double, g : Double, b : Double, position : (Double, Double, Double), direction : (Double, Double, Double), angle? : Double, concentration? : Double) -> Unit

    A spot light; at most 4. angle is the cone angle in radians (default π/3), concentration at least 1 (default 100).

    Renderer3D::sync_camera

    fn Renderer3D::sync_camera(self : Renderer3D) -> Unit

    After changing the active camera in place, re-reads its matrices.

    Renderer3D::texture

    fn Renderer3D::texture(self : Renderer3D, src : TexSource) -> Unit

    Textures subsequent shapes (texture()).

    Renderer3D::texture_filter

    fn Renderer3D::texture_filter(self : Renderer3D, src : TexSource, downscale : String, upscale : String) -> Unit

    Sets how a texture is sampled when drawn smaller and larger: "nearest" (blocky) or "linear" (smooth, the default).

    Renderer3D::texture_map

    fn Renderer3D::texture_map(self : Renderer3D, which : TextureMap, src : TexSource?, scale? : Double) -> Unit

    Sets (or with None clears) a texture map of the material. Normal and bump maps need geometry with uvs and tangents (compute_tangents).

    Renderer3D::texture_mode

    fn Renderer3D::texture_mode(self : Renderer3D, normal : Bool) -> Unit

    Texture coordinates in pixels (IMAGE, false) or in [0, 1] (NORMAL).

    Renderer3D::texture_wrap

    fn Renderer3D::texture_wrap(self : Renderer3D, x : String, y : String) -> Unit

    Wrap modes: "clamp", "repeat" or "mirror".

    Renderer3D::translate

    fn Renderer3D::translate(self : Renderer3D, x : Double, y : Double, z : Double) -> Unit

    Renderer3D::update

    fn Renderer3D::update(self : Renderer3D) -> Unit

    Per-frame reset before draw() (p5's _update).

    Renderer3D::use_normal_material

    fn Renderer3D::use_normal_material(self : Renderer3D) -> Unit

    normalMaterial(): also resets specular/emissive use.

    Renderer3D::use_specular_material

    fn Renderer3D::use_specular_material(self : Renderer3D) -> Unit

    Turns on the specular material term (set by specular_texture).

    Shader

    pub struct Shader {
    vert : String
    frag : String
    vertex_hooks : Array[(String, String)]
    fragment_hooks : Array[(String, String)]
    modified : Array[String]
    declarations : String
    vertex_declarations : String
    fragment_declarations : String
    // private fields
    }

    A shader program: vertex and fragment sources with hooks.

    Shader::copy

    fn Shader::copy(self : Shader) -> Shader

    A copy with the same sources, hooks and uniforms that compiles its own program, e.g. for use on another WebGL context (copyToContext).

    Shader::filter

    fn Shader::filter(frag : String) -> Shader

    A filter shader from a fragment shader that reads tex0 at vTexCoord (createFilterShader). It also receives texelSize and canvasSize.

    Shader::frag_src

    fn Shader::frag_src(self : Shader) -> String

    The fragment source with hooks filled in.

    Shader::inspect_hooks

    fn Shader::inspect_hooks(self : Shader) -> String

    A description of the hooks this shader has, with their current bodies (inspectHooks prints the same information).

    Shader::modify

    fn Shader::modify(self : Shader, vertex? : Array[(String, String)], fragment? : Array[(String, String)], declarations? : String, vertex_declarations? : String, fragment_declarations? : String) -> Shader

    A copy whose hooks are replaced by vertex/fragment entries (keys as "type name"), like shader.modify({...}) with string hooks. declarations (both stages), vertex_declarations and fragment_declarations add GLSL such as uniforms and helper functions before the hooks.

    Shader::new

    fn Shader::new(vert : String, frag : String) -> Shader

    A shader from GLSL sources (no hooks).

    Shader::set_sources

    fn Shader::set_sources(self : Shader, vert : String, frag : String) -> Unit

    Replaces the sources (the program is rebuilt on next use); used when a shader's files finish loading.

    Shader::set_uniform

    fn Shader::set_uniform(self : Shader, name : String, value : UniformValue) -> Unit

    Sets a uniform; it is uploaded when the shader is next used.

    Shader::vert_src

    fn Shader::vert_src(self : Shader) -> String

    The vertex source with hooks filled in.

    ShapeMode

    pub(all) enum ShapeMode {
    PathMode
    PointsMode
    LinesMode
    TrianglesMode
    TriangleFanMode
    TriangleStripMode
    QuadsMode
    QuadStripMode
    }

    How the vertices of an immediate geometry are drawn.

    Style

    pub(all) struct Style {
    fill : FixedArray[Double]?
    stroke : FixedArray[Double]?
    stroke_weight : Double
    stroke_cap : Int
    stroke_join : Int
    blend_mode : String
    erasing : Bool
    }

    Fill/stroke style passed in from the sketch for each draw.

    TexSource

    pub(all) struct TexSource {
    elt :
    ImageElement
    ?
    fb : Framebuffer?
    width : Double
    height : Double
    }

    An image source used as a texture: the element and its logical size.

    TextureMap

    pub(all) enum TextureMap {
    SpecularMap
    AmbientMap
    ShininessMap
    NormalMap
    BumpMap
    }

    Which material map a texture is used as.

    UniformValue

    pub(all) enum UniformValue {
    Floats(FixedArray[Double])
    Tex(TexSource)
    }

    A uniform value set with set_uniform.

    Vec3

    pub struct Vec3 {
    x : Double
    y : Double
    z : Double
    } derive(
    Debug
    )

    A mutable 3D vector.

    Vec3::copy

    fn Vec3::copy(self : Vec3) -> Vec3

    Vec3::new

    fn Vec3::new(x : Double, y : Double, z : Double) -> Vec3

    VertexProperty

    pub struct VertexProperty {
    name : String
    size : Int
    data : Array[Double]
    }

    A custom per-vertex attribute: size numbers per vertex in data.

    arc_geometry

    fn arc_geometry(start : Double, stop : Double, mode : String, detail : Int) -> Geometry

    p5's arc|start|stop|mode|detail| / ellipse|detail| unit geometry in [0, 1]²; mode is "pie", "chord", "open" or "undefined".

    box_geometry

    fn box_geometry(detail_x : Int, detail_y : Int) -> Geometry

    box|dx|dy: a unit cube.

    build_immediate

    fn build_immediate(g : Geometry, kind :
    ShapeKind
    , contours : Array[Array[
    Pt
    ]], has_fill : Bool, has_stroke : Bool, simple_lines : Bool, building? : Bool, user_layout? : Array[(String, Int)]) -> ShapeMode

    Builds the immediate geometry for contours (constructFromContours). Returns the draw mode after tessellation/conversion.

    cone_geometry

    fn cone_geometry(detail_x : Int, detail_y : Int, cap : Bool) -> Geometry

    cone|dx|dy|cap: radius 1, height 1.

    cylinder_geometry

    fn cylinder_geometry(detail_x : Int, detail_y : Int, bottom_cap : Bool, top_cap : Bool) -> Geometry

    cylinder|dx|dy|bottom|top: radius 1, height 1.

    ellipsoid_geometry

    fn ellipsoid_geometry(detail_x : Int, detail_y : Int) -> Geometry

    ellipsoid|dx|dy: a unit sphere.

    extra_fill

    let extra_fill : Int

    extra_normal

    let extra_normal : Int

    extra_size

    let extra_size : Int

    The number of extra values per WEBGL vertex.

    extra_stroke

    let extra_stroke : Int

    extra_u

    let extra_u : Int

    Layout of Pt.extra for WEBGL vertices.

    filter_default_param

    fn filter_default_param(op : String) -> Double?

    p5's filterParamDefaults.

    filter_vertex_source

    fn filter_vertex_source(frag : String) -> String

    p5's default vertex shader for filter shaders (createFilterShader), GLSL ES 3.00 when the fragment shader is.

    js_string

    fn js_string(x : Double) -> String

    JavaScript's String(x), used in p5's geometry cache keys.

    libtess_triangulate

    fn libtess_triangulate(contours : Array[Array[FixedArray[Double]]], stride : Int) -> Array[Double]

    Tessellates contours of p5 vertex arrays (x, y, z first) like p5's _triangulate with libtess (nonzero winding, triangles). Returns the flattened triangle vertex data.

    parse_mtl

    fn parse_mtl(text : String) -> Map[String, Material]

    Parses an MTL file into materials by name (p5's parseMtlData).

    parse_obj

    fn parse_obj(text : String, materials? : Map[String, Material]) -> Geometry

    Parses an OBJ file (vertices, texture coordinates, normals, faces). With materials (from the MTL files it names), faces get their material's diffuse color, and a model using several materials is split into parts.

    parse_stl

    fn parse_stl(data : FixedArray[Byte]) -> Geometry

    Parses an STL file (binary or ASCII).

    plane_geometry

    fn plane_geometry(detail_x : Int, detail_y : Int) -> Geometry

    plane|dx|dy: a unit square in the XY plane.

    quad_geometry

    fn quad_geometry(p1 : (Double, Double, Double), p2 : (Double, Double, Double), p3 : (Double, Double, Double), p4 : (Double, Double, Double), detail_x : Int, detail_y : Int) -> Geometry

    p5's quad geometry for four corners with a detail_x × detail_y grid.

    rect_geometry

    fn rect_geometry(detail_x : Int, detail_y : Int) -> Geometry

    p5's rect|dx|dy unit geometry.

    torus_geometry

    fn torus_geometry(tube_ratio : Double, detail_x : Int, detail_y : Int) -> Geometry

    torus|ratio|dx|dy: ring radius 1, tube radius tube_ratio (rounded to 4 significant digits like p5).

    triangle_geometry

    fn triangle_geometry() -> Geometry

    p5's tri unit triangle.