resolvePaperStyle changes a style id or a partial style into a full style.
Import
Example
Notes
- The built-in styles are
ISO_128,INK_SKETCH,GRAPHITEandNAPKIN. - Practice presets gives two example sets of styles and view settings, copied from two real sets of UK permit drawings.
- Your style replaces a built-in style that has the same id.
- An unknown id gives the default style, and the id appears in
unresolved. - With no input, the function returns
undefined. annotationText: { background: 'paper', paddingMm }blanks a box behind each text annotation (a note) in the paper colour, in the SVG, the PDF and the sheet on screen, so the note reads over hatches and lines. The box is the text’s estimated box (0.6 of its height for each character, from its height above the baseline to a quarter of it below, turned with the note) grown bypaddingMm(default 0.5 mm).background: 'none', the default, draws the note straight over what is under it. A bad value is listed inunresolvedand ignored.- In a section or an elevation, the outline of a cut part has the edge class
SectionCut, and the outline of a part seen beyond the cut hasVisibleOutline.SectionCutuses the cut pen until a style sets it inedgeClasses, for exampleedgeClasses: { SectionCut: { weightMm: 0.35 } }. - A cut outline has its own edge class, so a style that sets
VisibleOutlineto thin lines does not make cut lines thin. ISO 7519 draws a cut outline heavier than a seen line. - A view title uses the font of the sheet’s style,
typography.fontFamily, not the style of its viewport. To set the font of the titles, puttypographyin thestyleOverrideof the paper document or of the sheet. viewTitlesets how each view title of the sheet is drawn, and in a viewport’s ownstyleOverridehow the title of that viewport is, field by field:rule: falsedraws no rule under the title,positionputs the title at'below-left'(the default),'below-right','above-left'or'above-right'of the viewport frame, or centred on it at'below-center'or'above-center',textMmsets the height of the title in mm (1.8 to 20, the lettering heights of ISO 3098, default 5; the scale line is 0.7 of it),scaleTemplatewords the scale line with{scale}for the scale, such as'Scale {scale}'forScale 1:100, andfontWeight: 'bold'sets the title bold. A title at the right is right-aligned with the frame.title.showScale: falseon the viewport still removes the scale line. With noviewTitle, every title is the same as before.fontWeight: 'bold'on a class entry, itsbyKind.textentry, a part or a phase class sets the text of that class in the bold face, for exampleclasses: { SPACECONTAINER: { byKind: { text: { fontWeight: 'bold' } } } }for bold room labels. The SVG writesfont-weight="bold". The PDF sets the bold face of its font: Paper Mono SemiBold for Paper Mono, the default face, which it embeds like Paper Mono Regular, and Helvetica Bold, Times Bold or Courier Bold for the standard faces.classes.<type>.partsstyles one named part of a symbol. The key is the primitive’sstyle.subId, for exampleclasses: { ROOFLIGHT: { parts: { 'rooflight-opening': { dash: [3, 1.5] } } } }. A part entry has the fields of a class entry and is applied afterbyKindand before the edge class.visible: falsein a part removes only the primitives of that part. With noparts, every drawing is the same as before.- The part names below are the
subIdvalues that the plan symbols give their primitives. On a roof plan a rooflight is drawn by its roof, so its parts are styled underclasses.ROOF.parts. On a floor plan a rooflight is drawn by itself, so its parts are styled underclasses.ROOFLIGHT.parts. A style for both plans sets the parts under both classes. phases.<phase>.classes.<type>styles one element type in one phase. For example,phases: { new: { classes: { WALL: { fill: '#d9c4a0' } } } }fills the new walls and keeps the pens of new floors and rooms. The entry has the fields of a class entry,byKindandpartsincluded, and is applied after thephases.<phase>entry.visible: falsethere removes that type in that phase only:phases: { demolished: { classes: { DOOR: { visible: false } } } }removes the demolished doors from a proposed plan and keeps the demolished walls. Only a view withphaseFilter: 'proposed'gives a phase to its lines. With no phaseclasses, every drawing is the same as before.materials.<material>styles the cut of one material. The key is themateriala cut region carries: aWallMaterialsuch asWOOD, or a key ofBuildingModel.materials. An entry takesink,weightMm,fillandhatch, and is applied afterclassesandedgeClassesand beforephases, so a phase that sets a fill or a hatch still wins. For example,materials: { WOOD: { hatch: 'stud' }, INSULATION: { hatch: 'batt' } }draws timber studs as a zigzag and insulation as batt loops. Amaterialsfill or hatch replaces the hatch the material draws by itself. With nomaterials, every drawing is the same as before.roles.<role>styles one line role of a section or an elevation:cut,silhouette,projected,hidden,datum,marker,surfaceorground. An entry has the fields of a class entry exceptbyKindandedgeClasses, and is applied after the default role pen and beforeclasses. For example,roles: { silhouette: { weightMm: 0.35 } }draws the outlines of seen parts heavier and keeps the lines inside them. The default role pens are 0.5 mm forcutandground, 0.35 mm formarker, 0.25 mm forsilhouette, 0.18 mm forprojectedandsurface, and 0.13 mm forhiddenanddatum.depthBandssteps thesilhouetteandprojectedlines by their depth: the metres from the view plane to the nearest point of the face that the line belongs to. The first band whoseuntilMis at or beyond that depth adds itsladderStep. For example,depthBands: [{ untilM: 1.5, ladderStep: 1 }]draws the parts within 1.5 m of the view plane one pen heavier.surfacePatternMinGapMmsets the least paper gap, in mm, between two parallel lines of a material pattern on a seen face (style.surfacePattern) at the scale of the viewport. Of each run of parallel courses the first is kept, then each next course at least that gap from the last kept one; the others are left out. For example,surfacePatternMinGapMm: 0.6draws a plain-tile lean-to roof at 13° seen from its eave at 1:100, whose courses are 0.23 mm apart, with every third course. With nosurfacePatternMinGapMm, every course is drawn.edgeClasses.<class>.visible: falseremoves every line of that edge class. For example,edgeClasses: { VisibleCrease: { visible: false } }removes the lines where two faces of a seen part meet, such as the facets of a bay window base, and keeps the outlines. A phase entry with its ownvisiblewins over the edge class, and the edge class wins over a class entry.classes.<type>.edgeClasses.<class>styles one edge class of one element type. An entry has the fields of a class entry exceptbyKind,partsandedgeClasses, and is applied after the style-wideedgeClassesentry. For example,classes: { WALL: { edgeClasses: { VisibleCrease: { visible: false } } } }removes the crease lines of the walls and keeps the creases of roofs, fascias and bays. Itsvisiblewins over the style-wide edge class, sovisible: truedraws a crease thatedgeClassesremoves for every other type. A phase entry with its ownvisiblestill wins. An unknown edge class key changes nothing, as inedgeClasses. With noedgeClasseson a class, every drawing is the same as before.- With no
roles, nodepthBandsand no edge classvisible, every drawing is the same as before. - A literal
hatchspec of an unknownkind, or astudorbattspec with no positivepitchMm, is left out and reported inunresolved, ashatch kind '<kind>'orhatch '<kind>' needs a positive pitchMm.
Part names
A section mark draws its cut line in three pieces that meet and do not overlap at every scale: 10 mm on the paper at each head (
cut-end) and the middle between them (cut). classes: { MARKER: { parts: { cut: { visible: false } } } } draws only the ends and the heads; parts: { cut: { dash: [3, 1.5] }, 'cut-end': { weightMm: 0.5 } } dashes the middle and draws the ends heavier.
In a section or an elevation, each seen line and seen region of a door or a window carries the name of its physical part as its subId: window-frame, sash, mullion, transom, glazing-bar, window-sill and glazing for a window, door-frame, door-leaf, door-panel, rail and glazing for a door. Cut regions and cut lines, and the window of a dormer, carry no part name. A seen region (surface) takes no fill from a class or a phase, only from a part entry: phases: { new: { classes: { WINDOW: { parts: { glazing: { fill: '#cde6f7' } } } } } } fills the glass of the new windows and leaves the existing glass unfilled.
resolvePaperStyle
Flatten a style input against a registry.mergeStyle
Merge one style over another, at the depth each field means: -classes / edgeClasses / roles / phases / materials: key by key, then field by field on the class, then field by field on each byKind, parts and edgeClasses entry, and on each phase’s classes the same way — so an overlay that says { classes: { WALL: { ink } } } keeps WALL’s weight, fill and hatch.
resolveSheetPolicy
The policy a sheet renders under:deps.paperStyle (caller) → the sheet → the document.
resolveViewportPolicy
The policy one viewport renders under.documentStyleOf
A document’s style fields, forPaperRenderDeps.documentStyle.
PAPER_STYLES
The presets that ship, keyed by id.DEFAULT_PAPER_STYLE_ID
ISO_128
INK_SKETCH
Freehand ink — a drafted plan in technical pen on vellum, in the register Francis Ching teaches: a compressed four-rung hierarchy, warm near-black ink that lightens as the line thins, solid poché pulled a hair in from its line, crossed corners with a short placed start and a longer lifted finish, a second strike on the heavy lines, and upper-case lettering with a little tracking.GRAPHITE
Soft graphite on trace — a design-development plan in pencil on canary trace: every weight one rung heavier than ink (a pencil line is wider than a pen’s), warm greys that lighten as the line thins, a light warm poché with one sparse pass of scrubbed hatch over it (a tone, not a material), wider re-strike offsets than ink, longer softer tapers, a re-struck door swing, and larger upper-case lettering.NAPKIN
Napkin sketch — the parti drawing: a fineliner on a paper napkin, drawn fast.registerDrawingFont
Register a font for drawing text under its family, replacing one of the same family.Types
PaperStyleInput
ResolvedPaperStyle
PaperRenderDeps
Dependencies the emitters (and, later, the screen renderer) need that aren’t part of the serializable document: the kernel-backed drawing extractor that resolves each viewport to vector data, and (optionally) the title-block template registry used to render a sheet’s title block.(viewId: string, viewport?: import('../model/viewport').Viewport) => import('../model/raster-view').RasterDrawing | undefined
Resolve prepared named raster content; return undefined for a vector view.
Draw a named project view for
viewport, the viewport that prints it (so a plan can place its
tags for that scale); absent keeps bare paper renderers inline-only.The kind of a named project view:
plan, roof-plan, block-plan, section, elevation or
iso. The sheet editor reads it to place a north arrow on a plan view only. Absent, a viewport
with a viewId accepts a north arrow whatever its view.Degrees from project north to true north, clockwise: the site’s
trueNorthDeg. A north arrow
turns by this plus its viewport’s rotation. Absent means 0.ISO date (YYYY-MM-DD) for the title block’s
date auto-field. Absent means today, which makes a
rendered sheet non-reproducible — a batch export or a golden test pins it here.Mirrors
PaperDocument.dimensionStyles; set from it by the exporter and the renderer, for the
same reason unitSystem is.A caller’s paper style — an id or an inline overlay — for this render only. Narrower than anything
stored: it outranks the viewport’s, the sheet’s and the document’s own style.
Extra presets a host registers, resolvable by id alongside the builtins. A document’s own
paperStyles outrank these.