Line Styles for Affinity

dailyRushes Scripts for Affinity

Line Styles turns any selected line, curve or shape into a decorative line, with a live preview while you adjust it. It can also make the stroke solid, dotted or dashed, and any stroke works with any line style.

Before you start

  1. Add line-styles.js to your Script Library, with the name Line Styles. See Installing Scripts for Affinity.
  2. The script works on curves. Convert shapes drawn with the shape tools, and text, first: Vector > Convert to Curves.

Using Line Styles

  1. Choose Window > Scripting > Script Library.
  2. Select one or more lines, curves or closed shapes, or a group of them.
  3. Click Line Styles in the Script Library. The window opens and your selection changes straight away to show the default style, Curvy.
  4. Adjust the controls. The preview updates as you go.
  5. Click OK to keep the result, or Cancel to put everything back as it was.

Everything is worked out from the selection as it was when the window opened, so you can try styles and settings in any order without the changes piling up on each other.

Controls that have no effect with the current settings are greyed out.

What gets styled

Curves inside a selected group are included. Anything else in the selection is left out, and the window tells you how many objects that was.

Undo

One Undo reverses the whole change. With Apply to a copy on and Stroke set to Solid, Dotted or Dashed, it takes two: one for the stroke and one for the copy.

Running it again

Running the script on a line that is already styled styles the styled line again. To change your mind later, undo back to the plain line first, or work on copies with Apply to a copy.

If something looks wrong

What you see Fix
“Select one or more lines or curves first” Nothing usable was selected. Convert shapes and text first: Vector > Convert to Curves.
Dotted or Dashed shows nothing, or the line disappears The object has no stroke, or a stroke of zero weight. Give it a stroke weight in the Stroke panel and run the script again.
The pattern points inward on a closed shape Which side is “out” depends on the direction the shape was drawn. Turn on Flip side.
The corners of a shape moved Keep corners is off, or the corners are gentler than 20°. The script flows through anything gentler.
The ridge count is not exactly what I typed in Ridges With Keep corners on, Ridges is shared between the sides and rounded to a whole number per side (odd for alternating styles). On smooth closed shapes, alternating styles round up to an even number so the pattern joins up. Varied makes at least 4, one for each section. This keeps the corners and joins clean.
Spirals look like solid blobs The curls are too tight for the stroke weight. Lower Loop size or Height, use fewer Ridges, or use a thinner stroke.
Running it twice made the line strange The second run styled the already-styled line. Undo back to the plain line, then run it again with the settings you want.

Two dropdowns set the look: Line changes the path’s shape, and Stroke changes how it is drawn. Any line works with any stroke.

Line

The default is Curvy.

Straight

Leaves the path’s shape alone. Use it with Stroke to make a line dotted or dashed without changing its shape.

Curvy

A smooth sine wave either side of the line.

Wavy

A row of scoops hanging below the line, meeting in sharp points on top.

Scalloped

A row of round arches above the line, meeting in sharp points on it: the classic scalloped edge.

Zig Zag

Straight lines to sharp peaks, alternating sides.

Castle

Square-cut steps alternating sides, like battlements.

Loopy

A row of little loops, like joined-up handwriting. Loop size sets how much they curl.

Spiral

A curl on each ridge, alternating sides, joined by the line. Loop size sets how many times they wind.

Bumpy

An irregular, hand-drawn wobble. Roughness % adds finer jitter, and Seed picks a different random wobble.

Scribbly

Loops of random size, height and lean, like a quick scribble. Roughness % sets how uneven they are, and Seed picks a different scribble.

Varied

A mix: Curvy, then Zig Zag, then Loopy, then Castle.

  • On a line or smooth shape, the path is cut into four sections, one of each, sharing out Ridges. Each section gets at least one, so Ridges below 4 gives 4.
  • On a shape with corners, with Keep corners on, each side gets the next style in turn.

Stroke

The default is Keep as is.

Keep as is

Leaves the stroke alone, so only the shape changes.

Solid

Makes the stroke a solid line, which is handy for turning a dashed line back to solid. The line ends stay as they are, so a line that was Dotted keeps its round ends.

Dotted

Round dots. Gap sets the spacing.

Dashed

Square-ended dashes. Dash length and Gap set them.

Dots and dashes are part of the stroke, so the object needs a stroke with a weight for them to show. They go round corners and curves like any Affinity dashed line, and can be fine-tuned later in the Stroke panel.

These controls set the size and spacing of the pattern, and which side of the line it sits on.

Shape controls

Height

How far the pattern reaches from the original line, measured on the page in the document’s units, which the label shows: Height (mm), for example. If the document uses another unit, such as feet, it is in pixels. It can be up to 500, and starts at the equivalent of 10 pixels.

  • Alternating styles (Curvy, Zig Zag, Castle, Bumpy, Spiral) reach this far each side of the line.
  • One-sided styles (Wavy, Scalloped, Loopy) use it as the full height.

Objects that have been resized or stretched get the same height as any other. 0 leaves the path’s shape alone, like Straight.

Ridges

How many repeats along the path: waves, arches, peaks, steps, loops or curls, from 1 to 500. The default is 12. More ridges means tighter spacing.

With Keep corners on a shape with corners, this is the total for the whole shape, shared out between the sides by length.

Flip side

Mirrors the pattern to the other side of the line. Arches hang below instead of standing on top, loops and curls swap sides, and on a closed shape the pattern points inward instead of outward, or the reverse. It is off by default.

Loop size

From 0 to 6. The default is 2.5.

  • Loopy: how far the loops curl over. 0 gives plain round arches, about 1 is where they start to cross into loops, and higher values give wider, rounder loops. Loops close to the ends of a line are eased in so they stay on it.
  • Spiral: how many times each curl winds. Higher is tighter. Turn it down if the curls fill in and look like blobs, which happens at large Heights or with a thick stroke.
  • Scribbly: the general size of the random loops.
  • Varied: affects the Loopy section.

Roughness %

From 0 to 100. The default is 50.

  • Bumpy: adds a finer jitter on top of the main wobble. 0 gives a smooth, gently undulating line.
  • Scribbly: how uneven the loops are in size, lean and jitter. 0 gives fairly regular loops.

Seed

From 1 to 9999. The default is 1. Bumpy and Scribbly are random, but the same Seed always gives the same line, so the preview doesn’t jump about as you adjust other controls. Change the Seed to get a different random version. With several objects selected, each gets its own random line.

How the pattern follows the path

Ridges are spaced evenly along the path, measured by distance, so they follow curves as well as straight lines.

Open paths (lines)

Both end points always stay exactly where they were. The pattern starts and finishes on the original line.

Closed shapes with no sharp corners

On ellipses and blobs, the pattern runs all the way round and joins up with itself. Styles that alternate sides use an even number of ridges so the join is seamless, so an odd Ridges value is rounded up by one.

Shapes with sharp corners

On squares, rectangles and polygons, see Keep corners. A direction change of more than 20° counts as a corner. Smoother nodes, such as those on an ellipse, are flowed through.

Which side is “up”

For a line drawn left to right, arches, loops and curls sit on top. On a closed shape, the side depends on which way the shape was drawn. If they point inward and you wanted outward, use Flip side.

These controls set the spacing when Stroke is Dotted or Dashed. See the Style tab for the Stroke dropdown.

Before you start

Both values are multiples of the stroke weight, as in Affinity’s own Stroke panel. A Gap of 2 on a 5 pt line is 10 pt.

Dots and dashes controls

Dash length

The length of each dash, from 0.1 to 50. The default is 3. It is used by Dashed only.

Gap

The space between dashes, or between dots, from 0.1 to 50. The default is 2.5. It is used by Dashed and Dotted.

For Dotted, a Gap below 1.2 is raised to 1.2 so the dots stay separate. At a Gap of 1 they touch.

These switches set what happens at sharp corners, and whether the script changes your object or adds a styled copy.

Options controls

Keep corners

On by default.

  • On: sharp corners stay exactly where they are. Each side is treated as its own short line pinned at both corners, with a whole number of ridges, so every corner looks the same and a square keeps its four corners. The Ridges total is shared out by side length, so a long side gets more than a short one. Alternating styles (Curvy, Zig Zag, Castle, Bumpy, Spiral) use an odd number on each side, so each side is symmetrical.
  • Off: the pattern runs continuously round the shape and ignores the corners, which then move with the pattern.

It makes no difference to lines or shapes without sharp corners.

Apply to a copy

Off by default.

  • On: leaves the original alone and adds a new, styled copy with the same fill and stroke, on top of it. The copy is left selected.
  • Off: changes the selected objects themselves.

While the window is open, the preview shows the result on the original either way. When you click OK with this on, the original goes back to how it was and the copy is added.