const pMapper = createProjectionMapper(this);
pMapper.createQuadMap(width, height, [resolution])
20, minimum 2). QuadMap warps its content by computing a perspective (homography) transform from the four corner pins, then applying it at every point on a resolution × resolution grid; it does not warp the whole quad as a single flat shape. More grid points make that warp smoother and follow the true perspective more closely; fewer points are faster, but may not look as good when heavily keystoned.display(color) fill looks the same at any resolution since there’s no texture to warp, so low resolution (resolution = 2) is visually identical to higher resolution. Use a low value for solid color.displayTexture() / displaySketch() content benefits from a higher resolution when the surface is under strong keystone distortion.quad.setResolution(n).pMapper.createTriMap(width, height, [resolution])
pMapper.createPolyMap([numPoints])pMapper.createBezierMap([numPoints])pMapper.createLineMap([x0], [y0], [x1], [y1])Get the value of an oscillator (useful for LineMap animations):
pMapper.getOscillator(seconds, [offset])
seconds-long period and an optional phase offset (sine wave helper)pMapper.save([filename.json])pMapper.load([directory/filename.json], [callback])pMapper.load("maps/map.json", () => console.log("done loading json"));
pMapper.startCalibration()pMapper.stopCalibration()pMapper.toggleCalibration()In calibration mode, dragging can be restricted:
pMapper.moveAll()
pMapper.moveSurfaces()
pMapper.moveControlPoints()
Quads perform a perspective matrix transform of visuals (unlike the other surface objects). The following methods are available:
display([color])displayTexture(img, [x], [y], [w], [h])
p5.Image, p5.Element, or p5.TexturedisplaySketch(fn, [x], [y], [w], [h])
p5.Graphics object and draws on itA triangular surface with three control points (apex, bottom-left, bottom-right). Extends QuadMap and shares the same display interface:
display([color])displayTexture(img, [x], [y], [w], [h])displaySketch(fn, [x], [y], [w], [h])const bezMap = pMapper.createBezierMap([numPoints]);
Bezier objects have the following display methods:
bezMap.display([color])bezMap.displayTexture(img, [x], [y], [w], [h])
p5.Image, p5.Element, or p5.TexturebezMap.displaySketch(fn, [x], [y], [w], [h])
p5.Graphics object and draws on itTo add / remove points to a bezier map:
bezMap.addSegment([x], [y])
bezMap.removeSegment([x], [y])
To create a line map:
const lineMap = pMapper.createLineMap();
Initialize with explicit coordinates:
const lineMap = pMapper.createLineMap(-200, 0, 100, 100);
All accept an optional color and stroke weight:
lineMap.display([color], [strokeWeight])lineMap.displayNone()
lineMap.displayPercent(percent, [color], [strokeWeight])
p0 to a point percent of the way toward p1lineMap.displayCenterPulse(percent, [color], [strokeWeight])
lineMap.displayPercentWidth(percent, [color])
percentlineMap.displaySegment(startPercent, sizePercent, [color], [strokeWeight])
startPercent with length sizePercentlineMap.displayRainbowCycle()
frameCountlineMap.displayGradientLine(color0, color1, percent, [phase], [flip])
lineMap.displayNumber()
lineMap.setEndCapsOn() (default)lineMap.setEndCapsOff()Set the property directly:
lineMap.lineW = 20;
Useful for click interactions:
lineMap.isMouseOverCallback(callback)function mousePressed() {
for (const lineMap of lineMaps) {
lineMap.isMouseOverCallback(lineClickedCallback);
}
}
function lineClickedCallback(line) {
selectedLine = line;
}
function setLineThickness(increment) {
if (selectedLine != null) {
selectedLine.lineW += increment;
}
}