JFLib

diagram_core/src/render/theme.rs#

Source: lib/diagram_core/src/render/theme.rs

theme -- what the viewer needs of a DrawingML theme with Visio's extensions (JD4)

  ThemeInfo::parse(bytes)          colours (dk1, lt1, dk2, lt2, accent1-6, hlink, folHlink),
                                   the variation colours (vt:variationClrScheme, 7 each), the
                                   background (vt:bkgnd), the major and minor Latin fonts, the
                                   line widths of the format scheme, and the scheme IDs
                                   (vt:schemeID schemeEnum) a page's ThemeIndex and
                                   ColorSchemeIndex cells point at
  ThemeInfo::quick_color(index, variation)   a QuickStyle colour index -> RGB

Pages do not name their theme by a relationship: Visio keeps all themes at the document and
a page picks one by the schemeEnum of its ThemeIndex (the theme), ColorSchemeIndex (the
colours) and FontSchemeIndex (the fonts) cells (JD3, finding).  The viewer draws the cached
values; a theme is needed only where a value is literally "Themed" (the Theme style and a few
shapes) and for the theme's background.  A small tolerant scanner reads the part: elements,
attributes, nothing else; anything it does not understand is skipped.
  • struct ThemeInfo the parts of a theme the viewer uses
    • name: String -- a:theme name
    • colors: [Option<u32>; 12] -- 0xRRGGBB of dk1, lt1, dk2, lt2, accent1 .. accent6, hlink, folHlink (None: not given)
    • variations: Vec<[Option<u32>; 7]> -- the variation colour schemes, 7 colours each
    • background: Option<u32> -- vt:bkgnd
    • major_font: String -- the Latin typefaces of the major (headings) and minor (body) fonts
    • minor_font: String
    • line_widths: Vec<f64> -- a:lnStyleLst widths in inches (the line style matrix 1, 2, 3 ...)
    • scheme_ids: [Option<u32>; 4] -- the schemeEnum of the colour scheme, the font scheme, the format scheme and the theme as a whole (vt:themeScheme), in that order; every other schemeID found after them
    • other_ids: Vec<u32>

impl ThemeInfo

  • fn parse(data: &[u8]) -> Option<ThemeInfo> the theme of a theme part (None: not a theme)

  • fn has_scheme(&self, id: u32) -> bool whether the theme's own scheme (vt:themeScheme), or else any of its schemes, has this ID

  • fn color(&self, i: usize) -> u32 a scheme colour 0 .. 11 (dk1, lt1, dk2, lt2, accent1-6, hlink, folHlink)

  • fn quick_color(&self, index: u32, variation: usize) -> Option<u32> a QuickStyle colour index (QuickStyleLineColor, ...FillColor, ...FontColor): 0 dark 1, 1 light 1, 2 to 7 accent 1 to 6, 8 dark 2, 9 light 2, 100 to 106 the variation colours 1 to 7 of variation, 200 the background

  • fn no_theme_color(index: u32) -> u32 QuickStyle colours without a theme

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