JFLib

diagram_core/src/design/mod.rs#

Source: lib/diagram_core/src/design/mod.rs

design -- typed designs: a DrawingML theme with Visio's extensions (TH-01, TH-03, TH-04)

A design is what a theme part of a .vsdx holds: the DrawingML theme of ECMA-376 Part 1,
20.1.6 (colour scheme, font scheme, format scheme with fill, line, effect and background
style lists) and Visio's extensions of it ([MS-VSDX] 2.5.x, "dynamic theme"): a connector
format scheme, Visio's own line, fill and font properties of the styles, four variants
with seven colours and four styles each, the background colour, and the scheme numbers by
which a page's ThemeIndex, ColorSchemeIndex, EffectSchemeIndex, ConnectorSchemeIndex and
FontSchemeIndex cells find the parts again.

Only Visio's identifiers are taken from Visio (the user's decision of 2026-11-18): the
extension URIs, the namespace http://schemas.microsoft.com/office/visio/2012/theme and the
element and attribute names, read from the user's own files.  Every value -- colours,
fonts, widths, line ends, which style a variant uses -- is JFLib's own (catalog.rs).

  Design { name, id, colors, background, major_font, minor_font, shapes, connectors, variants }
  Design::theme_xml()         -> the theme part's bytes (xml.rs)
  catalog::all()              -> JFDiagrammer's own designs, NetLab first
  catalog::by_id(id)
  apply::*                    -> a design or a variant on a page or the document (apply.rs)

How a shape uses a design (formula/theme.rs evaluates it): its QuickStyle colour cells pick
a colour (0 dark 1, 1 light 1, 2..7 accent 1..6, 8 the background, 100..106 the colours of
the page's variant), its QuickStyle matrix cells a style of the lists (1..6, or 100..103:
the fill, line, effect and font style the page's variant names for its style 1..4).  A
style's colour placeholder (Clr::ph) is the colour picked.

Scheme numbers: [MS-VSDX] CT_SchemeID calls schemeEnum the one-based index of a built-in
component, 65535 a custom colour scheme found by GUID.  Visio's own designs use small
numbers; JFLib's designs use numbers from FIRST_ID on, so that no page of ours names one of
Visio's designs by mistake.
/// the first scheme number of JFLib's own designs (far above Visio's built-in ones)
FIRST_ID: u32 = 60001
/// the Visio theme extension namespace
NS_VT: &str = "http://schemas.microsoft.com/office/visio/2012/theme"
  • enum Slot a colour of the scheme, as DrawingML names it in schemeClr
    • Dk1 -- dark 1 (text)
    • Lt1 -- light 1 (background)
    • Dk2 -- dark 2
    • Lt2 -- light 2
    • Accent(u8) -- accent 1 .. 6
    • Ph -- the placeholder a style is coloured with (the shape's QuickStyle colour)

impl Slot

  • fn name(self) -> &'static str the schemeClr value

  • enum Mod a DrawingML colour transform, in thousandths of a percent (100000 = 100 %)

    • LumMod(u32) -- luminance times
    • LumOff(u32) -- luminance plus
    • SatMod(u32) -- saturation times
    • Alpha(u32) -- opacity
  • enum Clr a colour: fixed or of the scheme, with transforms

    • Rgb(u32, Vec<Mod>) -- 0xRRGGBB
    • Scheme(Slot, Vec<Mod>) -- a colour of the scheme or the placeholder

impl Clr

  • fn ph() -> Clr the placeholder (the colour the shape picks)

  • fn slot(s: Slot) -> Clr a scheme colour

  • fn rgb(c: u32) -> Clr a fixed colour

  • fn with(mut self, m: Mod) -> Clr with one more transform

  • fn lighter(self, pct: u32) -> Clr lighter: luminance times (100 - pct) % plus pct %, toward white

  • fn darker(self, pct: u32) -> Clr darker: luminance times (100 - pct) %

  • struct Fill a fill style: its colour and Visio's fill pattern (0 no fill, 1 solid)

    • color: Clr -- the colour
    • pattern: u8 -- vt:fillProps pattern

impl Fill

  • fn solid(color: Clr) -> Fill a solid fill

  • fn none() -> Fill no fill (Visio's pattern 0; the colour still feeds FillForegnd)

  • enum Cap a line cap (DrawingML ln@cap)

    • Round -- rnd
    • Square -- sq
    • Flat -- flat
  • struct Line a line style: DrawingML's ln and Visio's vt:lineEx

    • width: u32 -- the width in EMU (12700 a point)
    • cap: Cap -- the cap
    • color: Clr -- the colour
    • pattern: u8 -- Visio's line pattern (0 none, 1 solid, 2 dashed ...)
    • rounding: u32 -- corner rounding in EMU
    • begin: u8 -- line ends (Visio's arrow numbers, 0 none) and their sizes (0 .. 6)
    • begin_size: u8
    • end: u8
    • end_size: u8
/// EMU per point
EMU_PT: u32 = 12700

impl Line

  • fn solid(centi_pt: u32, color: Clr) -> Line a solid line of pt hundredths of a point

  • fn arrow(mut self, end: u8, size: u8) -> Line with a line end at the end

  • fn rounded(mut self, emu: u32) -> Line with rounded corners (EMU)

  • fn pattern(mut self, p: u8) -> Line with a pattern

  • struct Shadow an outer shadow (DrawingML outerShdw)

    • blur: u32 -- blur radius and distance in EMU, direction in 60000ths of a degree
    • dist: u32
    • dir: u32
    • color: Clr -- the colour (with an alpha transform for its strength)
  • struct Effect an effect style: nothing or a shadow

    • shadow: Option<Shadow> -- the shadow
  • struct FontStyle a font style of Visio's extension: Char.Style bits (1 bold, 2 italic, 4 underline) and the text colour

    • style: u8 -- Char.Style
    • color: Clr -- the colour

impl FontStyle

  • fn regular(color: Clr) -> FontStyle regular text in a colour

  • fn bold(color: Clr) -> FontStyle bold text in a colour

  • struct Scheme a format scheme: the style lists a QuickStyle matrix number picks from (shapes: six of each, connectors: three)

    • name: String -- the name (fmtScheme@name)
    • fills: Vec<Fill>
    • lines: Vec<Line>
    • effects: Vec<Effect>
    • backgrounds: Vec<Fill> -- the background fills (bgFillStyleLst, three)
    • fonts: Vec<FontStyle>
  • struct VarStyle the style a variant gives its quick style 1 .. 4: one-based indices into the lists

    • fill: u8
    • line: u8
    • effect: u8
    • font: u8

impl VarStyle

  • const fn new(fill: u8, line: u8, effect: u8, font: u8) -> VarStyle fill, line, effect, font

  • struct Variant a variant (TH-04): seven colours and four quick styles

    • colors: [u32; 7] -- varColor1 .. 7 (0xRRGGBB)
    • monotone: bool -- one colour for everything (THEMEPROP("MultiFormat") false)
    • embellishment: u8 -- the embellishment level 1 .. 3 (low, medium, high)
    • styles: [VarStyle; 4] -- quick styles 1 .. 4 (QuickStyle matrices 100 .. 103)
  • struct Design a design (TH-01)

    • name: String -- the theme's name (a:theme@name; JFDiagrammer shows its own translated names)
    • id: u32 -- the scheme number of every component
    • colors: [u32; 12] -- dk1, lt1, dk2, lt2, accent1 .. 6, hlink, folHlink (0xRRGGBB)
    • background: u32 -- vt:bkgnd: the page colour themed text keeps its contrast to
    • major_font: String -- the Latin typefaces for headings and body
    • minor_font: String
    • shapes: Scheme -- the format scheme of shapes (six styles of each kind)
    • connectors: Scheme -- the connector scheme (three of each kind)
    • variants: [Variant; 4] -- the four variants

impl Design

  • fn theme_xml(&self) -> Vec<u8> the theme part's bytes
  • fn quick_color(&self, n: u32, variant: usize) -> Option<u32> the colour a QuickStyle colour number names in a variant (None: not a colour number)

mod uri

the extension URIs, as Visio names its extension elements

/// clrScheme: vt:schemeID
COLOR_ID: &str = "{2703A3B3-D2E1-43D9-8057-6E9D74E0F44A}"
/// clrScheme: vt:bkgnd
BACKGROUND: &str = "{093E89EA-6996-430E-BFF9-83A9FAAAAB73}"
/// clrScheme: vt:variationClrSchemeLst
VARIANT_COLORS: &str = "{DDD2D869-C2EF-471E-B8FA-914AFA308C9F}"
/// fontScheme: vt:schemeID
FONT_ID: &str = "{B3C0788F-89CC-4CDB-A57D-0664CFDA821B}"
/// themeElements: vt:fmtConnectorScheme
CONNECTOR_SCHEME: &str = "{1342405F-259F-4C95-8CDF-A9DCE2D418A2}"
/// themeElements: vt:themeScheme
THEME_ID: &str = "{D75FF423-9257-4291-A4FE-1B2448832E17}"
/// themeElements: vt:fmtSchemeEx
FORMAT_ID: &str = "{27CD58D4-7086-4B73-B2AB-7AEBE2148A8C}"
/// themeElements: vt:fmtConnectorSchemeEx
CONNECTOR_ID: &str = "{C6430689-8E98-42EC-ADBF-087148533A3F}"
/// themeElements: vt:fillStyles
FILL_STYLES: &str = "{56243398-1771-4C39-BF73-A5702A9C147F}"
/// themeElements: vt:lineStyles
LINE_STYLES: &str = "{6CAB99AB-0A78-4BAB-B597-526D62367CB4}"
/// themeElements: vt:fontStylesGroup
FONT_STYLES: &str = "{EBE24D50-EC5C-4D6F-A1A3-C5F0A18B936A}"
/// themeElements: vt:variationStyleSchemeLst
VARIANT_STYLES: &str = "{494CE47F-D151-47DC-95E8-85652EA8A67E}"

Source: docs/API.md in the JFLib repository.