Skip to content

mousegen

Stanimir Stamenkov edited this page Sep 13, 2024 · 3 revisions

mousegen – create mouse cursors from SVG sources

Yet another mouse cursor generator...

USAGE: mousegen render [<project-path>] OPTIONS

OPTIONS: [--source <svg-dir>]... [--name <theme-name>]... [--build-dir <dir>]
         [--animations <animations.json>]
         [--color-map <colors.json>] [--color <color>]...
         [--windows-cursors[=<win-names.json>]]
         [--linux-cursors[=<x11-names.json>]]
         [--all-cursors]
         [--pointer-shadow] [--no-shadow-also]
         [--base-stroke-width <width>] [--stroke-width=<width>[:<name>]]...
         [--min-stroke-width <pixels>] [--expand-fill[=<limit>]]
         [--thin-stroke] [--default-stroke-also]
         [--all-variants]
         [-s <size-scheme>]... [-r <target-size>]...
         [-t <theme-filter>]... [-f <cursor-filter>]...

<project-path>  directory or "render.json" (possibly with a different name).
                The directory or the "render.json" parent is used as base all
                relative paths (f.e. --source <dir>) get resolved to.
                The default is the current working directory

OPTIONS

--source <svg-dir>      one or more;  source SVG directory to process.  One level
                        of subdirectories is scanned.  Required unless "render.json"
                        configuration is explicitly specified or implicitly found
                        in the current <project-path>
--name <theme-name>     one or more;  specifies a theme name for the corresponding
                        source directory.  If no name is associated with a source
                        directory, the directory name is used
--build-dir <dir>       base directory for all build output
--animations <animations.json>
                        defines parameters for animated cursors
--color-map <colors.json>
                        defines named color mappings; see --color
--color <color>         one or more, as specified in <colors.json>.  May be
                        given as comma separated list: --color White,Black
--windows-cursors[=<win-names.json>]
                        Windows cursor output;  Optional name mapping file arg;
                        Implies -r 32,48,64,72,96,128 -s N,L,XL
--linux-cursors[=<x11-names.json>]
                        Xcursor output;  Optional name mapping file arg;
                        Implies -r 24,32,48,64,72,96
--all-cursors           Outputs all cursors, in addition to those sepcified in
                        an effective name mapping
--pointer-shadow[=<dx>,<dy>[,<blur>[,<opacity>[,<color>]]]]]
--pointer-shadow=<dy>
                        ...
--no-shadow-also        ...
--base-stroke-width <width>
                        ...
--stroke-width=<width>[:<name>]
                        ...
--min-stroke-width <pixels>
                        ...
--expand-fill[=<limit>]
                        ...
--thin-stroke           alias for --stroke-width=12
--default-stroke-also   ...
--all-variants          shorthand for --no-shadow-also --default-stroke-also
-s <size-scheme>        one or more; ...
-r <target-size>        one or more; ...
-t <theme-filter>       one or more; Filter (include-only) themes from "render.json"
-f <cursor-filter>      one or more; Include-only filter for source files

render.json

{
  "Bibata-Modern": {
    "dir": "svg/modern"
  },
  "Bibata-Original": {
    "dir": "svg/original"
  }
}

May have color mappings specified as well:

{
  "Bibata-Modern-Ice": {
    "dir": "svg/modern",
    "colors": [
      { "match": "#00FF00", "replace": "#FFFFFF" },
      { "match": "#0000FF", "replace": "#000000" },
      { "match": "#FF0000", "replace": "#FFFFFF" }
    ]
  },
  "Bibata-Modern-Classic": {
    "dir": "svg/modern",
    "colors": [
      { "match": "#00FF00", "replace": "#000000" },
      { "match": "#0000FF", "replace": "#FFFFFF" },
      { "match": "#FF0000", "replace": "#000000" }
    ]
  }
}

animations.json

animations.json is automatically looked up in the current <project-path>, unless --animations is specified explicitly.

{
  "left_ptr_watch": {
    "durationSeconds": 3,
    "frameRate": 12
  },
  "wait": {
    "durationSeconds": 3,
    "frameRate": 12
  }
}

colors.json

colors.json is automatically looked up in the current <project-path>, unless --color-map is specified explicitly.

{
  // Force source/original colors
  "Default": {},

  "Amber": {
    "#00FF00": "#FF8300",  // Base color
    "#0000FF": "#FFFFFF",  // Outline color
    "#FF0000": "#001524"   // Watch background color
  },
  "Classic": {
    "#00FF00": "#000000",
    "#0000FF": "#FFFFFF",
    "#FF0000": "#000000"
  },
  "Ice": {
    "#00FF00": "#FFFFFF",
    "#0000FF": "#000000",
    "#FF0000": "#FFFFFF"
  }
}

win-names.json, x11-names.json

{
  "bd_double_arrow": "Dgn1",
  "left_ptr": "Pointer",
  "left_ptr_watch": "Work",
  ...
}
{
  "bd_double_arrow": "bd_double_arrow",
  "left_ptr": "left_ptr",
  "left_ptr_watch": "left_ptr_watch",
  ...
}

Acts as an implicit filter – only sources with explicit mapping get output, unless --all-cursors is specified. One may force all-cursors output with the original names specifying an empty-mapping file:

all-cursors.json:

{}
> mousegen render --windows-cursors=all-cursors.json

One may still apply a process filter using:

    --windows-cursors=all-cursors.json -f left_tee

Without the all-cursors.json (empty) mapping, or --all-cursors option, -f left_tee will result in no source files to process (given the implied --windows-cursors mapping/filter).

Examples

mousegen render --source svg --name FooBar --windows-cursors

mousegen render --source svg --name FooBar --linux-cursors

mousegen render --source svg --name FooBar -r 32,48,64 # bitmaps

mousegen render --source svg --name FooBar --linux-cursors --color White,Black

mousegen render --linux-cursors -t Bibata-Modern-Ice

mousegen render --windows-cursors -f left_ptr_watch