Skip to content

Reference

Devices

Screens, computers, peripherals, network gear and simple solids.

import { ... } from 'cseen/devices';

An antenna: a whip on a base, a parabolic dish on a mount, or a lattice tower. Has a signal anchor at the feed that waves attach to.

function antenna(o?: AntennaOpts): Antenna
ParameterType
o?AntennaOpts

Returns Antenna

Options: AntennaOpts

Example

import { Scene, ground } from 'cseen';
import { antenna } from 'cseen/devices';
const s = new Scene();
s.add(ground(), antenna({ at: [0, 0, 0], kind: 'dish', height: 2 }));
Run it in the playground →

See it in the gallery.

A browser window. The page is empty unless you give content (any SVG) or use write / code.

function browser(o?: BrowserOpts): Device
ParameterType
o?BrowserOpts

Returns Device

Options: BrowserOpts

Example

import { Scene, ground } from 'cseen';
import { browser } from 'cseen/devices';
const s = new Scene();
s.add(ground(), browser({ at: [0, 0, 0], width: 4, url: 'example.com' }));
Run it in the playground →

See it in the gallery.

A cloud made of overlapping balls. Put it up in the air with at: [x, y, z].

function cloud(o?: CloudOpts): Spheres
ParameterType
o?CloudOpts

Returns Spheres

Options: CloudOpts

Example

import { Scene, ground } from 'cseen';
import { cloud } from 'cseen/devices';
const s = new Scene();
s.add(ground(), cloud({ at: [0, 0, 1.5], size: 2.4 }));
Run it in the playground →

See it in the gallery.

A cylinder standing on the point at.

function cylinder(o?: CylinderOpts): Group
ParameterType
o?CylinderOpts

Returns Group

Options: CylinderOpts

Example

import { Scene, ground } from 'cseen';
import { cylinder } from 'cseen/devices';
const s = new Scene();
s.add(ground(), cylinder({ at: [0, 0, 0], r: 0.8, h: 1.2 }));
Run it in the playground →

See it in the gallery.

The classic database icon: stacked discs.

function database(o?: DatabaseOpts): Group
ParameterType
o?DatabaseOpts

Returns Group

Options: DatabaseOpts

Example

import { Scene, ground } from 'cseen';
import { database } from 'cseen/devices';
const s = new Scene();
s.add(ground(), database({ at: [0, 0, 0], r: 0.9, layers: 3 }));
Run it in the playground →

See it in the gallery.

A sheet of paper with a folded corner and lines of text. Stands facing the viewer; rotate it with rot.

function document(o?: DocumentOpts): Plane
ParameterType
o?DocumentOpts

Returns Plane

Options: DocumentOpts

Example

import { Scene, ground } from 'cseen';
import { document } from 'cseen/devices';
const s = new Scene();
s.add(ground(), document({ at: [0, 0, 0], width: 1.6, title: 'notes' }));
Run it in the playground →

See it in the gallery.

A keyboard. keyboard({ layout: 'tkl' }), then kb.press('A') or kb.type('hello') to animate it.

function keyboard(o?: KeyboardOpts): Keyboard
ParameterType
o?KeyboardOpts

Returns Keyboard

Options: KeyboardOpts

Example

import { Scene, ground } from 'cseen';
import { keyboard } from 'cseen/devices';
const s = new Scene();
s.add(ground(), keyboard({ at: [0, 0, 0], layout: 'tkl' }));
Run it in the playground →

See it in the gallery.

Every key of a layout, with its place. Exported so a layout can be inspected, tested or drawn some other way.

function keyboardLayout(layout?: KeyboardLayout, iso?: boolean): { keys: KeyDef[]; width: number; depth: number; }
ParameterType
layout?KeyboardLayout
iso?boolean

Returns { keys: KeyDef[]; width: number; depth: number; }

A laptop, open. lean is how far the lid leans back from upright, in degrees.

function laptop(o?: LaptopOpts): Device
ParameterType
o?LaptopOpts

Returns Device

Options: LaptopOpts

Example

import { Scene, ground } from 'cseen';
import { laptop } from 'cseen/devices';
const s = new Scene();
s.add(ground(), laptop({ at: [0, 0, 0], width: 3.2, lean: 16 }));
Run it in the playground →

See it in the gallery.

A handheld microphone, lying upright with its head on top. Pick it up with moveTo and rotateTo. at is the bottom of the handle.

function micHand(o?: MicOpts): Group
ParameterType
o?MicOpts

Returns Group

Options: MicOpts

Example

import { Scene, ground } from 'cseen';
import { micHand } from 'cseen/devices';
const s = new Scene();
s.add(ground(), micHand({ at: [0, 0, 0], height: 1.4 }));
Run it in the playground →

See it in the gallery.

A microphone on a stand: a round base, a pole, a boom arm and the capsule. at is the centre of the base.

function micStand(o?: MicOpts): Group
ParameterType
o?MicOpts

Returns Group

Options: MicOpts

Example

import { Scene, ground } from 'cseen';
import { micStand } from 'cseen/devices';
const s = new Scene();
s.add(ground(), micStand({ at: [0, 0, 0], height: 2.2 }));
Run it in the playground →

See it in the gallery.

A desktop monitor on a stand. at is the centre of its base.

function monitor(o?: MonitorOpts): Device
ParameterType
o?MonitorOpts

Returns Device

Options: MonitorOpts

Example

import { Scene, ground } from 'cseen';
import { monitor } from 'cseen/devices';
const s = new Scene();
s.add(ground());
const m = s.add(monitor({ at: [0, 0, 0], width: 3 }));
m.write(['hello'], { fontSize: 0.3 }); // a screen is empty until you put something on it
Run it in the playground →

See it in the gallery.

A computer mouse, pointing away from the viewer (front is -y). at is the centre of its base. Move it with moveTo.

function mouse(o?: MouseOpts): Group
ParameterType
o?MouseOpts

Returns Group

Options: MouseOpts

Example

import { Scene, ground } from 'cseen';
import { mouse } from 'cseen/devices';
const s = new Scene();
s.add(ground(), mouse({ at: [0, 0, 0], length: 1 }));
Run it in the playground →

See it in the gallery.

A phone, upright.

function phone(o?: PhoneOpts): Device
ParameterType
o?PhoneOpts

Returns Device

Options: PhoneOpts

Example

import { Scene, ground } from 'cseen';
import { phone } from 'cseen/devices';
import { notification } from 'cseen/ui';
const s = new Scene();
s.add(ground());
const p = s.add(phone({ at: [0, 0, 0], height: 2.4 }));
p.put(notification({ title: 'Deploy finished', body: 'my.app is live.' }), { at: [0.05, 0.8], width: 0.9 });
Run it in the playground →

See it in the gallery.

A photo camera with a lens, pointing at the viewer. For the abstract camera of a scene, see cameraGlyph.

function photoCamera(o?: PhotoCameraOpts): Group
ParameterType
o?PhotoCameraOpts

Returns Group

Options: PhotoCameraOpts

Example

import { Scene, ground } from 'cseen';
import { photoCamera } from 'cseen/devices';
const s = new Scene();
s.add(ground(), photoCamera({ at: [0, 0, 0], size: 1.5 }));
Run it in the playground →

See it in the gallery.

A router with antennas, status lights and ports. Has a signal anchor for waves, and leds you can animate.

function router(o?: RouterOpts): RouterDevice
ParameterType
o?RouterOpts

Returns RouterDevice

Options: RouterOpts

Example

import { Scene, ground } from 'cseen';
import { router } from 'cseen/devices';
const s = new Scene();
s.add(ground(), router({ at: [0, 0, 0], width: 1.8 }));
Run it in the playground →

See it in the gallery.

A rack of servers with indicator lights. at is the centre of its base.

function server(o?: ServerOpts): Group
ParameterType
o?ServerOpts

Returns Group

Options: ServerOpts

Example

import { Scene, ground } from 'cseen';
import { server } from 'cseen/devices';
const s = new Scene();
s.add(ground(), server({ at: [0, 0, 0], width: 1.8, units: 3 }));
Run it in the playground →

See it in the gallery.

A loudspeaker cabinet with a woofer and a tweeter, facing the viewer.

function speaker(o?: SpeakerOpts): Group
ParameterType
o?SpeakerOpts

Returns Group

Options: SpeakerOpts

Example

import { Scene, ground } from 'cseen';
import { speaker } from 'cseen/devices';
const s = new Scene();
s.add(ground(), speaker({ at: [0, 0, 0], height: 1.8 }));
Run it in the playground →

See it in the gallery.

A shaded sphere resting on the point at.

function sphere(o?: SphereOpts): Surface
ParameterType
o?SphereOpts

Returns Surface

Options: SphereOpts

Example

import { Scene, ground } from 'cseen';
import { sphere } from 'cseen/devices';
const s = new Scene();
s.add(ground(), sphere({ at: [0, 0, 0], r: 0.9 }));
Run it in the playground →

See it in the gallery.

A tablet, landscape by default, standing on its edge.

function tablet(o?: TabletOpts): Device
ParameterType
o?TabletOpts

Returns Device

Options: TabletOpts

Example

import { Scene, ground } from 'cseen';
import { tablet } from 'cseen/devices';
const s = new Scene();
s.add(ground(), tablet({ at: [0, 0, 0], width: 2.5 }));
Run it in the playground →

See it in the gallery.

A terminal window with an empty body. Dark in every theme unless light is set. Use write or code to put commands in it.

function terminal(o?: TerminalOpts): Device
ParameterType
o?TerminalOpts

Returns Device

Options: TerminalOpts

Example

import { Scene } from 'cseen';
import { terminal } from 'cseen/devices';
const s = new Scene({ view: 'front' });
const t = s.add(terminal({ at: [0, 0, 0], width: 4, title: 'zsh' }));
t.write(['$ npm install', 'added 1 package'], { cursor: true });
Run it in the playground →

See it in the gallery.

A flat-screen television on two feet.

function tv(o?: TvOpts): Device
ParameterType
o?TvOpts

Returns Device

Options: TvOpts

Example

import { Scene, ground } from 'cseen';
import { tv } from 'cseen/devices';
const s = new Scene();
s.add(ground(), tv({ at: [0, 0, 0], width: 4.4 }));
Run it in the playground →

See it in the gallery.

An antenna. signal is the point waves start from: the tip of a whip, the feed of a dish, the top of a tower.

new Antenna(o?: NodeOpts): Antenna

Extends Group.

MemberDescription
signal(): (): V3where a signal leaves from (and arrives at), as an anchor that follows the antenna
setFeed(p: V3): voidsets the signal point, in the antenna’s own space

A thing with a screen. Its screen starts empty. Put anything on it with write, code, or by passing an SVG as screen. write and code return the text, so you can animate it with typeOn.

new Device(o?: NodeOpts): Device

Extends Group.

MemberDescription
screen: { at: V3; size: [number, number]; }where the screen is, in the device’s own space: its bottom left corner and its size
host: Groupthe group the screen lives in (a laptop’s lid, for example)
ink?: string | undefineddefault text colour on this screen
put<T extends Node>(el: T & { size: [number, number]; }, o?: { at?: [number, number]; width?: number; }): Tputs an element (a notification, a chat, a progress bar) on the screen. at is where its bottom left corner goes and width how wide it is, both as a fraction of the screen. It keeps its own proportions.
write(text: string | string[], o?: Partial<TextBlockOpts>): TextBlockwrites text on the screen
code(src: string | string[], o?: Partial<TextBlockOpts>): TextBlockwrites coloured code on the screen

A single keycap. press (0 to 1) pushes it down, lit (0 to 1) tints it toward the accent colour.

new Key(def: KeyDef, cap: Cap, role: string, z: number): Key

Extends Node.

MemberDescription
def: KeyDefwhere this key sits on the board and what it is called
collect(out: Prim[]): voiddraws the cap as a top face and four sloped sides. Pressing shortens the cap; lit raises the fill and mixes in the accent.

A keyboard with accurate key sizes and positions and no legends. Keys are found by id: kb.key('A').

new Keyboard(o?: KeyboardOpts): Keyboard

Options: KeyboardOpts

Extends Group.

MemberDescription
keys: Map<string, Key>every key by id
size: [number, number]width and depth of the board in world units
key(id: string): Keya key by id, e.g. ‘A’, ‘Enter’, ‘Space’, ‘LShift’, ‘F5’. Throws if there is no such key.
press(id: string, hold?: number): Animpresses a key down and up again (as an animation)
type(text: string, o?: { gap?: number; hold?: number; }): Animtypes a string: one press per character, so a keyboard can drive a typing animation. Letters and digits map to keys; keys it cannot find are skipped.

A wifi router with antennas, indicator lights and ports. leds are Dots you can animate; signal is above the antennas.

new RouterDevice(o?: NodeOpts): RouterDevice

Extends Group.

MemberDescription
leds: Dot[]
signal(): (): V3where a signal leaves from (and arrives at), above the antennas, as an anchor that follows the router
setTop(p: V3): voidsets the signal point, in the router’s own space

Options of antenna.

Extends NodeOpts.

OptionTypeDefaultDescription
kind?'whip' | 'dish' | 'tower'‘whip’ (a pole), ‘dish’ (a parabolic dish on a mount) or ‘tower’ (a lattice mast)
height?numberheight in world units
tilt?numberdish only: how far the dish is tipped from pointing straight up, in degrees
yaw?numberdish only: the direction it faces, in degrees around z (0 faces -y, toward the viewer)
role?stringcolour role (ink, faint, accent, s1 to s8) or a role you define in CSS

Options of browser.

Extends ScreenOpts.

OptionTypeDefaultDescription
width?numberwidth in world units
url?stringthe address shown in the address bar
ratio?numberheight over width of the screen
content?stringtext shown inside the page

Options of cloud.

Extends NodeOpts.

OptionTypeDefaultDescription
size?numberwidth in world units
role?stringcolour role (ink, faint, accent, s1 to s8) or a role you define in CSS
fill?numbercolour strength, 0 to 1
alpha?numbersee-through amount, 0 to 1

Options of cylinder.

Extends NodeOpts.

OptionTypeDefaultDescription
r?numberradius
h?numberheight
res?numbernumber of sides
fill?numbercolour strength, 0 to 1
alpha?numbersee-through amount, 0 to 1
role?stringcolour role (ink, faint, accent, s1 to s8) or a role you define in CSS

Options of database.

Extends NodeOpts.

OptionTypeDefaultDescription
r?numberradius
layers?numbernumber of stacked discs
role?stringcolour role (ink, faint, accent, s1 to s8) or a role you define in CSS

Options of document.

Extends NodeOpts.

OptionTypeDefaultDescription
width?numberwidth in world units
ratio?numberheight over width
title?stringa heading line
lines?numbernumber of lines of text
seed?numberchanges the lengths of the lines of text

A keyboard layout: full (104 keys), tkl (87), 75 or 60.

type KeyboardLayout = 'full' | 'tkl' | '75' | '60'

Options of keyboard.

Extends NodeOpts.

OptionTypeDefaultDescription
layout?KeyboardLayout‘full’ (104 keys), ‘tkl’ (87), ‘75’ or ‘60’
iso?booleanthe ISO shape for the left shift and the enter key
width?numbertotal width in world units. Default is 0.18 per key unit.
tilt?numberhow far the back of the board is raised, in degrees. Desk keyboards have a little.
role?stringcolour role (ink, faint, accent, s1 to s8) or a role you define in CSS

One key: its place on the board in key units (1 is a standard key), measured from the top left.

OptionTypeDefaultDescription
idstringthe key’s name, for press and lit
xnumberdistance from the left edge in key units
ynumberdistance from the top edge in key units
wnumberwidth in key units
hnumberheight in key units
rownumberthe row it belongs to

Options of laptop.

Extends ScreenOpts.

OptionTypeDefaultDescription
width?numberwidth in world units
lean?numberhow far the lid leans back from upright, in degrees

Options of micStand and micHand.

Extends NodeOpts.

OptionTypeDefaultDescription
height?numberheight in world units
role?stringcolour role (ink, faint, accent, s1 to s8) or a role you define in CSS

Options of monitor.

Extends ScreenOpts.

OptionTypeDefaultDescription
width?numberwidth in world units
ratio?numberheight over width of the screen

Options of mouse.

Extends NodeOpts.

OptionTypeDefaultDescription
length?numberlength in world units
role?stringcolour role (ink, faint, accent, s1 to s8) or a role you define in CSS
cable?booleandraw a cable

Options of phone.

Extends ScreenOpts.

OptionTypeDefaultDescription
height?numberheight in world units

Options of photoCamera.

Extends NodeOpts.

OptionTypeDefaultDescription
size?numbersize in world units
role?stringcolour role (ink, faint, accent, s1 to s8) or a role you define in CSS

Options of router.

Extends NodeOpts.

OptionTypeDefaultDescription
width?numberwidth in world units
antennas?numbernumber of antennas
leds?numbernumber of status lights
ports?numbernumber of ports
role?stringcolour role (ink, faint, accent, s1 to s8) or a role you define in CSS

Options of server.

Extends NodeOpts.

OptionTypeDefaultDescription
width?numberwidth in world units
units?numbernumber of rack units
role?stringcolour role (ink, faint, accent, s1 to s8) or a role you define in CSS

Options of speaker.

Extends NodeOpts.

OptionTypeDefaultDescription
height?numberheight in world units
role?stringcolour role (ink, faint, accent, s1 to s8) or a role you define in CSS

Options of sphere.

Extends NodeOpts.

OptionTypeDefaultDescription
r?numberradius
res?numbernumber of segments around
fill?numbercolour strength, 0 to 1
alpha?numbersee-through amount, 0 to 1
role?stringcolour role (ink, faint, accent, s1 to s8) or a role you define in CSS

Options of tablet.

Extends ScreenOpts.

OptionTypeDefaultDescription
width?numberwidth in world units
ratio?numberheight over width of the screen

Options of terminal.

Extends ScreenOpts.

OptionTypeDefaultDescription
width?numberwidth in world units
title?stringtext in the title bar
ratio?numberheight over width of the screen
light?booleana light terminal that follows the theme. By default a terminal stays dark in every theme.

Options of tv.

Extends ScreenOpts.

OptionTypeDefaultDescription
width?numberwidth in world units