napkin-sketchdocs 1.0.0 GitHub

Working with other programs: cheatsheet#

On this page

API hub · Reference · Quickstart · Cheatsheet

Reminders for trading drawings with other editors: what the SVG carries, how an import names things, what the Illustrator script builds, what survives, and links.

What napkin's SVG carries#

AttributeOnCarries
data-namea layer's <g>, a linkThe name as typed
inkscape:label, inkscape:groupmode="layer"a layer's <g>The name, for Inkscape's Layers panel
ida layer's <g>The name for Illustrator: _xHH_ escapes, -2 for a repeat
data-generator="napkin-sketch"<svg>Who wrote the file
data-tool, data-ievery markThe tool, and the paint order
data-d, data-width, data-profilea profiled markIts centreline, width and profile
data-nib, data-ptsa Copic markIts nib and points
data-gradient, data-filla filled marknapkin's gradient and fill
data-dasha dashed markdashed or dotted
data-text, data-boxa wrapped textIts words and its box's width
href, data-link="true"a linked <image>The file's path
filter, data-effectsa mark, a layer's <g>Its effects, as a filter and as the list
data-napkin-split, data-napkin-parta mark drawn as its two partsIts fill and its stroke apart; a Splatter's hatched part carries the mark it stands for

How an import names a row#

SourceRow
data-name="Board"Board
inkscape:label="Board"Board
id="Sun_x20__x26__x20_Moon"Sun & Moon
id="outline-5"outline
id="path4521"path: an id an editor made up names nothing
An unnamed <rect>rect
An unnamed <g><Group>
A file with no groupsOne group named unnamedRootName, the file's name in the app
A first <rect> over the whole canvasThe page's background, not a row

What the Illustrator script builds#

napkin-sketchIllustrator
A pageA document, its artboard the page or the box, a pixel a point
The paperA locked Background layer
A top-level layerA Layer, hidden or locked as it is
A layer in a groupA named GroupItem
A markA PathItem on its anchors, SMOOTH where the handles are in line
Several contoursA CompoundPathItem
TextPoint text, or area text for a box
An imageAn embedded RasterItem
A linkA PlacedItem linked to the file, found from the script's folder
An effectLeft off, with a warning
A SplatterIts lines, as open PathItems
A WarpThe bent PathItem
3DA GroupItem of its faces
An eraserA stroke in the paper's color, with a warning

What survives#

WhatOut of napkin and backInto Illustrator or InkscapeInto Illustrator by its script
Layer names, tree and opacityYesYesYes
Hidden layers, locksNoNoYes
CurvesAnchor for anchorThe same BeziersAnchor for anchor
Profiles, Copic nibsYesAs filled outlinesAs filled outlines
Gradients, dashesYesYesYes
TextWith its boxAs text, in the reader's fontAs text frames
ImagesEmbeddedEmbeddedEmbedded
LinksAs linksAs linked imagesAs placed items linked to the file
EffectsYesAs SVG filtersNo
A SplatterYes, liveAs its linesAs its lines
A WarpYes, liveAs the bent shapeAs the bent paths
3DYes, liveAs its facesAs a group of its faces
LinkImportEmbed
HoldsThe pathThe contents, as layersThe bytes
RowsOneOne a group and named objectOne
The file changesThe next output shows itNothing changesNothing changes
Made withlink, { link: true }File > Import, a paste, importSvgimage with an asset

One line each#

WantWrite
An SVG for another editornapkin-sketch draw card.napkin --to svg
A drawing rebuilt in Illustratornapkin-sketch draw card.napkin --to jsx, then File > Scripts > Other Script
The same, in coderenderSketch(page, { format: 'jsx' }) or sketchesToJsx(pages)
An Illustrator script that reports with no alertSet var QUIET = true; at its top, and read its result
Another editor's SVG in the appnapkin-sketch --import art.svg
A linked file in a scriptlink "assets/logo.svg" at 20 20 size 160 80 name "Logo"
A linked file in a compositiondesign.image({ src: 'assets/logo.svg', link: true, x: 20, y: 20, width: 160, height: 80 })
Links read from another foldernapkin-sketch draw card.napkin --base brand
An SVG parsed into layers, in a browserimportSvg(svgText, { unnamedRootName: 'logo' })

Common mistakes#

WrongRightWhy
Reading a layer's name from idRead data-nameThe id is escaped and made unique.
image "assets/logo.svg" to keep a file linkedlink "assets/logo.svg" ...image embeds a named asset; a path is unknown-asset.
Expecting a hidden layer in the SVGShow it before exportingHidden layers are not written.
importSvg in plain NodeRun it in a browser or the appIt measures the document with the DOM.
Linking an SVG for the Illustrator scriptLink a PNG or a PDFIllustrator's scripting does not place an SVG by link, so it arrives as its placeholder.
Moving a .jsx away from the files it linksMove them together, or write it where it runsIt finds a link by its path from the script's own folder.