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 Slota colour of the scheme, as DrawingML names it in schemeClrDk1-- dark 1 (text)Lt1-- light 1 (background)Dk2-- dark 2Lt2-- light 2Accent(u8)-- accent 1 .. 6Ph-- the placeholder a style is coloured with (the shape's QuickStyle colour)
impl Slot
fn name(self) -> &'static strthe schemeClr valueenum Moda DrawingML colour transform, in thousandths of a percent (100000 = 100 %)LumMod(u32)-- luminance timesLumOff(u32)-- luminance plusSatMod(u32)-- saturation timesAlpha(u32)-- opacity
enum Clra colour: fixed or of the scheme, with transformsRgb(u32, Vec<Mod>)-- 0xRRGGBBScheme(Slot, Vec<Mod>)-- a colour of the scheme or the placeholder
impl Clr
fn ph() -> Clrthe placeholder (the colour the shape picks)fn slot(s: Slot) -> Clra scheme colourfn rgb(c: u32) -> Clra fixed colourfn with(mut self, m: Mod) -> Clrwith one more transformfn lighter(self, pct: u32) -> Clrlighter: luminance times (100 - pct) % plus pct %, toward whitefn darker(self, pct: u32) -> Clrdarker: luminance times (100 - pct) %struct Filla fill style: its colour and Visio's fill pattern (0 no fill, 1 solid)color: Clr-- the colourpattern: u8-- vt:fillProps pattern
impl Fill
fn solid(color: Clr) -> Filla solid fillfn none() -> Fillno fill (Visio's pattern 0; the colour still feeds FillForegnd)enum Capa line cap (DrawingML ln@cap)Round-- rndSquare-- sqFlat-- flat
struct Linea line style: DrawingML's ln and Visio's vt:lineExwidth: u32-- the width in EMU (12700 a point)cap: Cap-- the capcolor: Clr-- the colourpattern: u8-- Visio's line pattern (0 none, 1 solid, 2 dashed ...)rounding: u32-- corner rounding in EMUbegin: u8-- line ends (Visio's arrow numbers, 0 none) and their sizes (0 .. 6)begin_size: u8end: u8end_size: u8
/// EMU per point
EMU_PT: u32 = 12700
impl Line
fn solid(centi_pt: u32, color: Clr) -> Linea solid line ofpthundredths of a pointfn arrow(mut self, end: u8, size: u8) -> Linewith a line end at the endfn rounded(mut self, emu: u32) -> Linewith rounded corners (EMU)fn pattern(mut self, p: u8) -> Linewith a patternstruct Shadowan outer shadow (DrawingML outerShdw)blur: u32-- blur radius and distance in EMU, direction in 60000ths of a degreedist: u32dir: u32color: Clr-- the colour (with an alpha transform for its strength)
struct Effectan effect style: nothing or a shadowshadow: Option<Shadow>-- the shadow
struct FontStylea font style of Visio's extension: Char.Style bits (1 bold, 2 italic, 4 underline) and the text colourstyle: u8-- Char.Stylecolor: Clr-- the colour
impl FontStyle
fn regular(color: Clr) -> FontStyleregular text in a colourfn bold(color: Clr) -> FontStylebold text in a colourstruct Schemea 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 VarStylethe style a variant gives its quick style 1 .. 4: one-based indices into the listsfill: u8line: u8effect: u8font: u8
impl VarStyle
const fn new(fill: u8, line: u8, effect: u8, font: u8) -> VarStylefill, line, effect, fontstruct Varianta variant (TH-04): seven colours and four quick stylescolors: [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 Designa 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 componentcolors: [u32; 12]-- dk1, lt1, dk2, lt2, accent1 .. 6, hlink, folHlink (0xRRGGBB)background: u32-- vt:bkgnd: the page colour themed text keeps its contrast tomajor_font: String-- the Latin typefaces for headings and bodyminor_font: Stringshapes: 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 bytesfn 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}"