Ollin

Marks

On this page

Stroke dynamics drive width and opacity from how a mark is being made, rather than from where you are along it.

strokeProfile shapes a stroke by its shape. It reads the fraction along a finished path and answers with a width. That is the right tool for a designed mark, such as a taper you decided on in advance. It is the wrong tool for a mark someone is drawing right now. The path has no length yet, so there is no fraction to read.

The same S-curve drawn three ways at one stroke weight: an even line, a taper that swells in the middle and vanishes at both ends, and a calligraphic nib that thickens and thins as the curve turns

A StrokeMark is the other half. It records a path as it happens, and it measures how fast the pointer is traveling and how hard it is pressed. It then keeps the width and opacity the hand asked for at every point.

var mark = StrokeMark(.speed(fast: 0.15))

override func draw() {
    background(.white)
    if mouseIsPressed { record(into: &mark) }
    stroke(.black)
    strokeWeight(24)
    drawMark(mark)
}

Drag, and the mark comes out full where you moved slowly and thin where you hurried.

One S-curve drawn three times at one stroke weight by a hand that is slow at the ends and fast through the middle: ignoring the pace it is an even line, letting the pace drive width it swells at the ends and narrows to a hairline in the middle, letting the pace drive opacity it stays the same width but fades

Contents: The pieces · StrokeInput · StrokeResponse · StrokeDynamics · StrokeMark · drawMark · Pressure · Building a mark by hand · Brushes · Stroke media · Fill media · What exports

The pieces

A mark is built from four types, each doing one thing:

TypeWhat it is
StrokeInputWhat was measured at one point: speed, pressure, direction, and distance so far.
StrokeResponseHow one axis answers that measurement, as a multiplier.
StrokeDynamicsA response for width and a response for opacity, which together make the brush.
StrokeMarkThe recorded path, with the width and opacity at every point of it.
Four boxes joined by arrows: the hand moving 25 points in a sixtieth of a second while pressing at 0.4, measured into a StrokeInput of speed 1500 points per second and pressure 0.4, answered by StrokeDynamics with width from pressure and opacity from speed, landing in the mark as width 0.62 and opacity 0.40 at that point

StrokeInput

struct StrokeInput {
    init(speed: Double = 0, pressure: Double = 0.5,
         direction: Vector2 = Vector2(1, 0), distance: Double = 0)
    var speed: Double        // canvas points per second, smoothed
    var pressure: Double     // 0...1, smoothed
    var direction: Vector2   // unit heading
    var distance: Double     // points traveled so far
}

speed runs around 200 for a careful hand, and past 1500 for a flick across a 1080-point canvas. distance is a distance rather than a fraction, because a mark in progress has no known length. There is nothing to take a fraction of, so dynamics only sees what has already happened.

StrokeResponse

StrokeResponse.speed(reference: 1200, slow: 1, fast: 0.1)
StrokeResponse.pressure(light: 0.1, heavy: 1)
StrokeResponse.unchanged
StrokeResponse { input in ... }

A StrokeResponse is one axis's answer, given as a multiplier.

ResponseWhat drives it
.speed(reference:slow:fast:)Pace. slow is the multiplier at rest, and fast is the multiplier at reference points per second and beyond. Works on any device.
.pressure(light:heavy:)Press force. light applies at the faintest touch, and heavy at full force. Needs a device that measures it, see Pressure.
.unchangedNothing drives it. This axis keeps the stroke's own weight or alpha. It is the default.
StrokeResponse { ... }Anything else you write, computed from the whole StrokeInput.

Pass a fast larger than slow to reverse the mapping, so the mark swells as it speeds up. reference is in canvas points per second, so on a much larger or smaller canvas pass 1200 * scale.

StrokeDynamics

StrokeDynamics(width: StrokeResponse = .unchanged,
               opacity: StrokeResponse = .unchanged)

StrokeDynamics.speed(reference: 1200, fast: 0.1)   // width only
StrokeDynamics.pressure(light: 0.1)                // width only
StrokeDynamics.uniform                             // neither

A StrokeDynamics is the brush, with one response per axis, and multipliers(for:) is what a recorded mark calls for each point: both answers at once, each clamped to the range its response promises. Both responses are multipliers, matching strokeProfile. Width scales strokeWeight, opacity scales the stroke color's alpha, and 1 leaves either one as set.

Naming each axis says what each one does, and it lets the two come from different measurements:

StrokeDynamics(width: .pressure(light: 0.1),      // press for a fat mark
               opacity: .speed(fast: 0.4))        // hurry for a faint one

An axis you leave out is .unchanged, so nothing is ever driven by accident. .speed(fast:) and .pressure(light:) are shorthands for the everyday brush, and they drive width only. To fade as well, write both axes out.

A response runs where the stroke is expanded, not inside draw(). Like a profile closure it is @Sendable, so it cannot reach time or a @Param. Everything it needs is already in its StrokeInput, and the named forms take their shaping as arguments.

StrokeMark

StrokeMark(_ dynamics: StrokeDynamics = .speed(),
           smoothing: Double = 0.5,
           minSpacing: Double = 1.5)

mark.record(_ position: Vector2, deltaTime: Double, pressure: Double = 1)
mark.clear()
mark.append(_ sample: StrokeMark.Sample)

mark.samples      // [Sample], each a position + width + opacity + speed (nil without timing)
mark.positions    // just the path
mark.count / .isEmpty / .length / .bounds

mark.pressureDeadZone   // 0...1, a press at or under it counts as none
mark.pressureCurve      // the exponent a press follows, 1 linear
mark.maxWidthChange     // nil, or the most the width may change per point traveled

A StrokeMark is the recording. record adds to the live path, and Sketch.record(into:) fills its three arguments from the running sketch. That is the form you want in draw():

if mouseIsPressed { record(into: &mark) }

Three parameters:

  • dynamics can be set mid-mark, so a live parameter can change the brush while a stroke is in progress. Points already recorded keep the width and opacity they were given.
  • smoothing (0 raw to 1 heavy, default 0.5) is how much the measured speed and pressure are filtered. Raw per-frame speed is far too noisy to drive a width directly. The default sits where a mark reads as deliberate without visibly trailing the pointer.
  • minSpacing (default 1.5 points) is how far the pointer must travel before a new point is recorded. It keeps a slow hand from piling hundreds of near-identical points into one spot. Frames under that distance keep their time rather than dropping it, so the point that does land measures its speed over the whole interval.

Passing dt is what makes a mark come out the same on a 60 Hz display and a 120 Hz one. A mark measures distance per frame. Without the real elapsed time, a faster display would read every stroke as half as fast and lay down a fatter mark.

A mark is an ordinary value, so keeping a finished one is a copy:

override func mouseReleased() {
    strokes.append(mark)
    mark.clear()
}

The first recorded point is held back until a second one gives it a heading, so a direction-driven brush starts with a real direction. A one-point mark draws nothing anyway, so count is 0 until the second point lands.

Each recorded point also keeps the speed it was made at, in canvas points per second, smoothed as the dynamics read it. A point you append yourself carries whatever speed you give it, or none. The pen reads it: its ink soaks farther where the hand slowed and thins where it hurried.

drawMark

drawMark(_ mark: StrokeMark)

drawMark strokes the recorded path at the width and opacity it asked for at every point. It goes through the same fringe expander every other stroke uses. That means it honors stroke, strokeWeight, strokeJoin, strokeCap, the transform stack, clipping, symmetry, and retained batches. It needs at least two recorded points and a stroke.

A width profile already set with strokeProfile(_:) still applies, and the two multiply. That is how a dynamic mark also gets a clean lift-off:

strokeProfile(.taper(start: 1))   // ... and fade out at the end
drawMark(mark)

A mark whose dynamics ask for nothing (.uniform) draws exactly like drawPolyline of the same points, down to the pixel.

Pressure

pressure              // 0...1, 0 when nothing is held
pressureIsAvailable   // whether this device can measure it at all

Sketch.pressure is how hard the pointer is being pressed. On a pressure-sensing device, such as a Force Touch trackpad or a pen tablet, it varies continuously through a press. On a device that cannot measure pressure it is 1 while a button is down. A pressure-driven brush still draws there, at one weight throughout.

A pen tablet says more than how hard: stylus carries the stylus's lean, its barrel turn, which end is down, and whether it is over the tablet at all, and the lean is what a broad-edged nib is made of. pressureIsAvailable says which kind of device you have. The answer comes from the event rather than from the machine, so it is false until the first press. Read it in mousePressed() rather than in setup():

override func mousePressed() {
    mark = StrokeMark(pressureIsAvailable ? .pressure(light: 0.1)
                                          : .speed(fast: 0.15))
}

Two settings on the mark shape the press before any response reads it, the way a tablet's pressure setting does. pressureDeadZone is how hard a press has to be before it counts: a reading at or under it is no pressure, and the rest of the range is spread over 0...1, so a pen resting on the tablet does not start a mark already swollen. pressureCurve is the exponent the press is raised to. 2 asks for a firmer press before the mark responds and 0.5 answers to a lighter one. A third, maxWidthChange, limits how fast the width may change per canvas point traveled, so a sudden press swells the mark along the path rather than stepping it:

var mark = StrokeMark(.pressure(light: 0.1))
mark.pressureDeadZone = 0.08
mark.pressureCurve = 1.6
mark.maxWidthChange = 0.02     // a fiftieth of the weight per point, at most

Ollin asks the trackpad for the drawing gesture. That gesture is a single stage over the full range, so a press reads as a smooth amount. No force-click fires look-up in the middle of a stroke.

Building a mark by hand

A mark does not need a pointer. append adds a finished sample, with its width and opacity already decided. That is how you draw a mark deterministically, replay one, or feed one from some other measured signal:

var mark = StrokeMark()
for (i, p) in path.enumerated() {
    let t = Double(i) / Double(path.count - 1)
    mark.append(StrokeMark.Sample(position: p, width: 1 - t, opacity: 1))
}

record still works on a hand-built mark, and continues from the last sample.

This is also how a mark differs from StrokeProfile.values([...]), and why it is its own type. A profile's values are spread evenly along the path. A recorded hand's points are not evenly spaced. They bunch where the hand slowed and spread out where it hurried, which is the information the mark carries. Spreading its widths evenly would slide every one of them off the place it was measured. StrokeProfile.values(_:at:) is the general form, taking the fractions to place the values at, and it is what drawMark builds internally.

Brushes

A width profile and a recorded mark both shape one continuous ribbon. A Brush replaces that ribbon, and repeats a shape along the path instead.

The same S-curve stamped three ways at one stroke weight: close-packed circles reading as a solid mark, squares turning with the path like a chisel nib, and a loose spray of translucent circles thrown either side of the line
strokeWeight(20)
strokeBrush(.spray())
drawPolyline(points)

strokeBrush(_:) is style. You set it once and it is held, like strokeCap or strokeProfile, and noStrokeBrush() goes back to the ribbon. It applies wherever a path is stroked: drawLine, drawBezier, drawPolyline, drawCurve, drawArc, drawMark, and the outlines of drawShape and drawPolygon. The analytic shapes, such as drawCircle and drawRect, have no path to walk. They keep drawing a continuous outline, and they say so once.

Each named brush is a Brush(_:spacing:sizeJitter:angle:angleJitter:…) underneath, so a brush of your own is that initializer with a Brush.Tip and the jitter you want. The stamp takes its size from strokeWeight and its color from stroke. A brush decides texture, not weight or color, so you can swap brushes without re-tuning anything else.

The parameters

tipWhat gets stamped: .circle, .square, .shape(Shape), or .image(Image)
spacingGap between stamps, as a fraction of the stamp's size. 0.2 reads as one mark, and 1 as a row of beads
sizeJitterHow much each stamp's size varies, 0 to 1
angle.followPath, .fixed(radians), or .random
angleJitterA random turn on top of angle, in radians
scatterHow far stamps stray off the line, as a fraction of their size
countStamps laid down at each step. Set it above 1 together with scatter for a scatter brush
opacityJitterHow much each stamp's opacity varies, 0 to 1
seedFixes the randomness

Four presets cover the common marks: .round, .chisel(), .spray(), and .scatter().

Spacing is measured in stamps, not pixels

Every distance in a brush is a fraction of the stamp's own size, so one brush keeps its texture at any weight. The same brush at twice the strokeWeight makes the same mark at twice the size, rather than a mark with a different texture.

It multiplies with a profile

strokeProfile still shapes the size along the path, so a scattered mark that tapers at both ends is one more call:

strokeBrush(.spray())
strokeProfile(.taper())
drawPolyline(points)

A drawMark's recorded widths and opacities feed in the same way, so the hand can drive a brush too.

It is stable

A stamp's randomness comes from its index along the path and from the brush's seed, never from the sketch's random. That means a brush cannot shift randomness a sketch is using elsewhere, and the same path draws the same mark every frame. Animate the path and the stamps travel with it rather than boiling in place.

Stroke media

A profile, a mark, and a brush decide how much ink lands and where. A StrokeMedium decides what the ink is made of. It shades the stroke's ribbon one pixel at a time, in the ribbon's own coordinates. Each pixel knows how far along the path it sits and where it falls across the width.

One S-curve drawn in eight media. Pencil, charcoal, pastel, and a multicolor pastel each fade from full density to a seventh along the curve by inking fewer grains of the paper, so the light end breaks into specks. A bristle brush streaks red and gold along the path, a dry brush breaks up on the paper's grain, and wet and oil strokes cross a ground half blue and half yellow, dragging the blue into the yellow behind them
var mark = StrokeMark(StrokeDynamics(opacity: .pressure(light: 0.15)))

override func draw() {
    background(.white)
    if mouseIsPressed { record(into: &mark) }
    stroke(.black)
    strokeWeight(14)
    strokeMedium(.pencil)
    drawMark(mark)
}

strokeMedium(_:) is style. You set it once and it is held, like strokeBrush, and noStrokeMedium() goes back to the plain ribbon. It applies wherever a path is stroked: drawLine, drawBezier, drawPolyline, drawCurve, drawArc, drawMark, and the outlines of drawShape and drawPolygon. The circle, ellipse, rect, triangle, ngon, star, trapezoid, and parallelogram hand their outline to the ribbon while a medium is on, as they do for a dash. The rest of the analytic family draws a plain outline and says so once. So does a brush, which replaces the ribbon, and a shader stroke, which paints it.

The stroke's color is the pigment and its alpha is the density. A mark recorded with an opacity response therefore thins the pigment where the hand did, and a dry medium breaks into specks there.

MediumWhat it does
.dry(tooth:softness:roughness:palette:seed:)Pigment catches on the paper's tooth. A dense stroke inks nearly every grain and a light one only the highest, so a light line breaks into specks rather than fading. tooth is the grain's size in canvas points, softness how gradually a speck gives way to paper, roughness how far the tooth frays the edge (a fraction of the half-width), and palette a color per grain.
.pencil, .charcoal, .pastel.dry at three settings: a fine, hard tooth; a coarse, soft one with a frayed edge; and a broad, chalky one. .pastel(palette:seed:) is the multicolor stick.
.bristles(_:streaks:amount:seed:)A brush whose bristles streak the stroke's color and a second pigment along the path, each streak its own mix. amount is the second pigment's share. Leave the second pigment out for a deeper shade of the first.
.dryBrush(grain:amount:streaks:seed:)A brush running dry. Its load falls along the mark, and where it is short the paper's grain, at three scales, decides what catches. amount sets how soon it runs out.
.wet(amount:reach:)Wet paint that drags the ground. Each pixel mixes its pigment with what lies up to reach canvas points behind it along the path, most of all toward the tail.
.oil(amount:reach:relief:streaks:seed:)Wet paint under a dominant color, its ridges lit from the upper left. relief scales their height, and 0 lies flat.
.ink(feather:pooling:amount:speed:seed:)A pen. The ink soaks feather canvas points past the nib's edge along the paper's fibers, farther where the pen moved slowly, and lies denser over the first and last pen width by pooling. amount is how much the flow thins when the pen hurries, up to a ballpoint's skips. speed is the writing speed in canvas points per second.

.bristles, .dryBrush, .wet, .oil, and .ink are also there with their default settings, as .pencil is.

The tooth belongs to the paper

The dry media's tooth is fixed to the canvas, not to the stroke, and the medium's seed chooses the paper. Two strokes over one spot catch the same grains, which is how a second pass of pencil darkens what the first left. A drawing makes the same picture every frame. A brush's streaks follow each stroke instead, seeded by where the stroke starts, so a mark redrawn every frame keeps its bristles.

Wet paint drags the frame without its wet strokes

A wet stroke reads the ground under it from the frame drawn once more with every wet stroke left out. It drags whatever else the frame holds, drawn before it or after, never itself, and two runs give the same picture. On a canvas that keeps its paint (noClear()), the ground also holds everything painted on earlier frames. That second drawing is what a wet stroke costs, and a frame with none draws once. Inside a layer a wet stroke has no ground yet, so it paints its pigment alone and says so once.

One coat

A translucent medium mark lays one coat. Where it crosses itself, the crossing reads as the rest of the mark does rather than twice as dark. Each stroke claims each pixel once, then clears its claim, so a second mark still layers over the first. The pen is the exception, below.

Ink from a pen

.ink reads how fast the pen moved. A mark recorded from the pointer carries the speed of every point (StrokeMark.Sample.speed), and the medium measures each against its speed, the writing speed. Slower than that, the ink soaks farther into the paper: at rest it reaches about two and a half times feather. Faster, the flow thins by amount, and at twice the writing speed with amount at 1 the line breaks into a ballpoint's skips. A line drawn without timing, a drawLine or a mark built from positions alone, counts as written at the writing speed everywhere.

var mark = StrokeMark()

override func draw() {
    background(.white)
    if mouseIsPressed { record(into: &mark) }
    stroke(Color(hex: 0x1B2A4A))
    strokeWeight(4)
    strokeMedium(.ink(feather: 2, pooling: 0.6, amount: 0.7, speed: 900))
    drawMark(mark)
}

The feather follows the paper's fibers, long thin strands at a few angles that the medium's seed chooses, fixed to the canvas like the dry media's tooth. So the soaked edge frays along the fibers rather than evenly, and two strokes over one spot fray the same way. The nib's end keeps the stroke's cap: a .butt cap is a flat nib, .round a round one, and .square a flat nib that runs half a width past the end. The feather spreads past whichever it is.

A pen lays a second coat where it crosses itself, as a real one does, so a translucent ink reads darker at every crossing, its own or another stroke's. That is the one medium that does; the rest lay one coat.

Your own shader on the same coordinates

A shader stroke reads the ribbon's coordinates too. info.arcLength is the distance along the path in its own units. info.across is the place across the width, -1 and 1 at the edges, and info.halfWidth is the local half-width. They sit beside info.along, the fraction along, and info.distance, the signed distance from the centerline. On an analytic outline drawn under a shader, info.arcLength reads 0.

stroke(Shader("""
float4 shade(float2 uv, ShaderInfo info) {
    float band = step(0.5, fract(info.arcLength / 12.0)) * (1.0 - abs(info.across));
    return mix(float4(0.1, 0.1, 0.12, 1.0), float4(0.9, 0.3, 0.2, 1.0), band);
}
"""))
strokeWeight(18)
drawPolyline([Vector2(60, 300), Vector2(240, 160), Vector2(420, 300), Vector2(600, 160)])

Fill media

A stroke medium is what a line is made of. A FillMedium is what a filled shape is made of. Thick paint rises along the outline and levels off inside, lit as a surface. A wash darkens what lies under it, and glass bends it. Each pixel of the fill knows how far it is from the shape's own edge and which way that edge lies. The medium shades from those two facts.

One blob in ten fill media over the same blue and yellow stripes. Impasto paint rises along its outline in two colors and catches the light on its upper left, the knife lays flat passes with straight ridges, a wash glazes the stripes in violet, gouache covers them in orange, chrome reflects the stripes around its rim, plain glass shows them straight through its middle and bent at its rim, faceted glass breaks them into facets, and rock, marble, and sand are creased stone, veined stone, and grains thinning out at the edge
let blob = Shape(curveThrough: [Vector2(220, 300), Vector2(520, 220), Vector2(780, 420),
                                 Vector2(560, 780), Vector2(260, 620)])

override func draw() {
    background(.white)
    noStroke()
    fill(Color(hex: 0xC8553D))
    fillMedium(.impasto)
    drawShape(blob)
}

fillMedium(_:) is style, like fill. It is held until noFillMedium() goes back to a flat fill. It applies to drawShape and drawPolygon. The circle, ellipse, rect, triangle, ngon, star, trapezoid, and parallelogram take it too, handing their outline to the fill path while a medium is on. A shader fill paints its own way and keeps it, saying so once.

The fill's color is the pigment, and for chrome and the glasses the tint, so white is plain chrome and clear glass. Its alpha is the opacity.

MediumWhat it does
.impasto(edge:relief:swell:detail:size:second:mottle:seed:)Paint laid on thick. It rises over edge canvas points from the outline and levels off, swells inside by swell in bumps size points across, and carries fine brush texture by detail. A second color is worked in by mottle, in patches with sharp borders. Leave second out for a lighter shade of the fill.
.knife(edge:relief:cut:angle:second:mottle:seed:)Paint spread with a palette knife. Flat passes cut points long, laid at angle, each tilted its own way and scraped along its length. Where two passes meet, the later one ends in a straight ridge and the earlier one lies in its shadow.
.wash(water:flow:angle:reach:size:edge:seed:)Pigment carried in water. At water 1 it glazes what is under it: each channel the darker of the ground and the pigment, so a wash never lightens the ground, and it pools at its edge. At water 0 it covers the ground. flow drags the ground up to reach points along angle, the direction drifting with position, and streaks the pigment along it.
.gouacheThe wash at its dry end. It covers the ground and drags it the farthest.
.chrome(edge:relief:reach:)Polished metal whose rim rounds over within edge points. Facing up it reflects a studio's bright sky and dark floor; toward the rim it reflects what is drawn around it, reach points out.
.glass(edge:relief:refraction:)A clear pane. Its flat middle shows what is under it straight, its rounded rim bends it by refraction and reflects more as the surface turns away. The color tints it, more where it is thick.
.facetedGlass(facet:edge:relief:refraction:seed:)Glass cut into flat facets about facet points across, on a jittered triangle lattice. Each facet bends the ground its own way, with a bright or dark crease where two meet.
.rock(size:depth:edge:relief:second:seed:)Stone folded into valley creases size points apart, cut depth deep, the folds running with the outline near the edge. A second stone joins it in broad patches.
.marble(veins:spacing:angle:sharpness:edge:seed:)A polished slab veined by a band across it, warped by noise and drawn thin, about spacing points apart. sharpness runs from broad clouds at 1 to hairlines at 20.
.sand(grain:edge:sparkle:second:mottle:seed:)Grains grain points across, each catching the light its own way, thinning out over edge points toward the outline so the edge dissolves.

Every one is also there with its default settings, as .impasto is.

How a fill knows its edge

While a medium is on, the fill is cut into bands that follow its outline inward. An inset is the outline moved in by a fixed distance, with round corners. Each band lies between one inset and the next, about a point and a half deeper. Every corner of a band therefore sits a known distance from the edge. A point inside a band takes the blend of its corners' distances. Past the depth the medium reads, such as the relief's width, the fill is one flat piece. A shape drawn again unchanged, on this frame or the next, is not cut again.

The relief is the quintic smoothstep of that distance. The light follows its slope. The slope falls to zero where the rise meets the flat inside, and so does the rate the slope changes. The light therefore bends into the flat middle without turning a corner where the rise ends.

What reads the ground

The wash, the gouache, chrome, and both glasses read what is drawn under them. That is the frame drawn once more without them, as a wet stroke medium reads it. They see everything else the frame holds, drawn before them or after, and two runs give the same picture. A fill that reads the ground does not see another one, which is left out of that second drawing too. Inside a layer there is no ground yet, so they draw from their color alone and say so once.

The paint moves with the shape

A medium's swells, veins, grains, and facets sit in the shape's own coordinates. A shape moved or turned by translate and rotate carries its texture with it, while the light stays where it is on the canvas, so a turning blob catches the light on whichever side faces the upper left. The seed picks which swells, passes, folds, and grains.

Lines drawn by hand

handDrawn(...) makes any line look drawn by a hand. It is on Contour, on Shape, and on StrokeMark, and each returns its own type.

let frame = Contour([Vector2(100, 100), Vector2(400, 100), Vector2(400, 300), Vector2(100, 300)])
drawShape(Shape(contours: [frame]).handDrawn(wobble: 1.2, bow: 2, seed: 1))

let diagonal = Contour([Vector2(100, 300), Vector2(400, 100)], closed: false)
drawPolyline(diagonal.handDrawn(overshoot: 6, seed: 2).points)

let pen = StrokeMark(samples: diagonal.points.map { StrokeMark.Sample(position: $0) })
drawMark(pen.handDrawn(blot: 10, seed: 3))

Four things happen to the line:

  • A wobble. The line wanders off its ideal by up to wobble canvas points (default 1), by a smooth noise read along the line from its own start. The line is resampled about every three points first so it has points to move.
  • A bow. Each straight run between corners sags by up to bow points (default 1) to one side or the other, a corner being a turn of more than about 35 degrees. A closed outline keeps its corners and stays closed, so a shape still fills.
  • Ends that run short or long. An open line's two ends move along their heading by up to overshoot points (default 3), each its own way. A closed outline has no ends.
  • A blot. On a StrokeMark only, since only a mark has widths: the width swells by about half where the mark begins and settles over blot canvas points (default 0, none).

Everything is drawn from seed and measured in the line's own frame, so a line that moves across the canvas carries its wobble with it rather than boiling. Two lines with one seed wobble alike. Give each line of a family its own seed, the loop's index will do. A mark keeps its widths, opacities, and speeds through the bend, so a pen line made hand-drawn still feathers where the hand slowed.

What exports

A mark's width exports exactly. --export-svg and --export-pdf write the region it covers as a filled outline, not as a stroked path with one width. Any profiled stroke exports the same way, so a plotted or printed mark matches the screen.

A mark's opacity flattens to its average, weighted along the mark's length. A vector document draws one fill at one alpha per path, so a varying opacity has nowhere to go. Ollin says so once on the console rather than dropping it silently. For a plotter, with one pen and one ink, this costs nothing.

A medium is raster. --export-svg and --export-pdf write the stroke as the flat ribbon it would be without one, the line a plotter draws, and say so once. The web page export carries every medium, shaded on the page by the same functions; a .wet or .oil stroke there drags the canvas the page draws first without it, and an .ink stroke carries the speed of each point. It stops at a wet stroke on a canvas that keeps its paint (noClear), and names the call.

A line made hand-drawn is ordinary geometry, so it exports as what it is: the bent outline, the bent polyline, or the mark with its blot in its width.

A fill medium is raster too. A vector export writes the fill flat, in its color, and says so once. The web page export stops at a fill medium and names the call.

A brush exports as its stamps. Each stamp becomes a real circle, polygon, or path a plotter can follow. The exported document then carries the mark the screen showed, rather than the bare path running under it. Because each stamp is its own shape, a brushed mark keeps its varying opacity in vector export, where a ribbon has to flatten it. A brush cannot vary opacity over a gradient stroke, because that would mean rewriting the ramp. It says so once and stamps at the ramp's own alpha.

See also

  • Drawing for strokeProfile, which shapes a designed mark
  • Input for the rest of the pointer and keyboard surface
  • Export for the vector exporters
  • Shaders for a shader as paint, and what info carries on a stroke
  • Gesture marks for a recorded mark made into many small marks laid along it (a cloud, rows of dashes, a feather, a coil), each a shape a plotter draws
  • Color for the palette schemes that color the example's blobs
  • Example: Examples/Shapes/Brushwork (paint with it), Examples/Shapes/StrokeProfiles (the profile family), Examples/Shapes/Brushes (the brush family), Examples/Shapes/ShadedStrokes (draw in each medium), Examples/Shapes/PaintedFills (each fill medium, and drag a loop to add a blob)

↑↓ move ↩ open