Icons & Vector

Bring in your own icons

Nox comes with no icon set. A design uses the icons its project already has: your team's own, or an open set you have downloaded, under its own license. You bring them in once, and each file becomes a component. Every icon you place is then an instance of it, so a better drawing later changes every place it is used. To draw icons in Nox instead, see The icon grid and keylines.

The Assets panel with nine icons brought in from a folder
The Assets panel with nine icons brought in from a folder

What Nox reads#

FileWhat it becomes
SVGA component of shapes: paths, fills and strokes, sharp at any size
PDFThe same. A PDF of several pages gives a component for each page, named file/1, file/2
PNG, JPEG, WebPA component filled with the picture, for a game's sprites. [email protected] comes in at half its pixels, named coin

Use SVG or PDF for interface icons. A picture is drawn as its pixels are, and blurs when it is shown larger than it was made. Of an SVG or a PDF, text, pictures and masks are not made, and a gradient is filled with its first color. EPS and Illustrator files are not read: save them as SVG or PDF first.

Bring them in#

By hand
  1. Choose File › Import Icons…, or press Import Icons… at the top of the Assets panel on the rail.
  2. Choose files, or a folder. Folders inside it are read too.
  3. Or drop the files or the folder on the Assets panel.

What is made:

  • One component for each file, named after it. A file in a folder inside is named with its folder: arrows/left.
  • On a page of their own, Icons, made if the document has none. The page you are on stays the one shown, so no screen is covered.
  • Each at its own size, with no icon grid. Several from one folder are set out in rows in one frame named after the folder.
  • One step. One undo takes the whole import back.
  • Not twice. A file whose name a component already has is left out, and the pill says how many were there already. Bring a folder in again after it grows, and only the new icons come in.

Most icon sets leave their color to whoever uses them: currentColor, no fill color at all, or a drawing all in black. Nox draws those in black, or in near white on a dark page, so that they show. A color the file gives is kept.

With an agent

Give the folder and the color the icons are drawn in.

Bring in the icons from /Users/you/Projects/app/icons, drawn in #14171C.

The agent calls import_icons with:

{
  "paths": ["/Users/you/Projects/app/icons"],
  "color": "#14171C"
}

The reply lists each new component by name and id, and what was already there, skipped, or left_out:

{
  "components": [
    { "id": "1576165514:5", "name": "arrows/left" },
    { "id": "1576165514:8", "name": "arrows/right" },
    { "id": "1576165514:11", "name": "bell" },
    { "id": "1576165514:14", "name": "search" }
  ],
  "already": [],
  "skipped": [],
  "left_out": [],
  "page_made": true
}

size fits every icon to one size, such as 24 for a set drawn at another. page: "shown", or an x and y, puts them on the page you are on instead of Icons.

The Assets panel#

Assets is on the rail, under Components. It lists what a document is made with beside its components, one kind at a time: Icons, Images and Fonts. The field under them finds an icon by name as you type.

  • Click a tile to put an instance in the middle of the view.
  • Drag a tile to put it where you let go.
  • Right-click a tile for Place in the View, Go to Component and Delete Component. One that instances use is asked about first.

The Components panel does not list icons, so your own components stay easy to find. Insert (I) finds both by name.

An agent looks before it brings anything in again. list_assets with kind: "icons" gives each icon's name, id, size and page, and query narrows it by name:

{ "kind": "icons", "query": "arrow" }

Place and size an icon#

An instance resized is the icon scaled whole, its proportions kept. Give interface icons a size from your scale, such as 16, 20 or 24, and keep it the same for every icon in one row.

Icons brought in from SVG or PDF have Scale Strokes on: an icon placed at twice its size has lines twice as heavy, as a picture would. This keeps a set's look the same at every size. Turn it off on the component where lines must stay as drawn.

The agent places one with create_nodes, inside any frame:

{
  "parent": "1576165514:2",
  "nodes": [
    { "kind": "instance", "name": "Bell", "component": "1576165514:11", "x": 350, "y": 18, "width": 20 }
  ]
}

Recolor an instance#

An icon takes the color of what it stands for: gray in a toolbar, white on a filled button, red for an error. Change it on the instance with an override, and the component stays as it is for everyone else.

One heart as brought in, three icons recolored, and one component at four widths
One heart as brought in, three icons recolored, and one component at four widths
By hand
  1. Double-click the instance to reach the shapes inside it.
  2. Select one of its shapes and change its stroke color in the inspector, or its fill for a filled icon. Do the same for its other shapes.
With an agent

The agent gives the instance overrides, one for each shape of the icon. It reads the shapes' ids with get_tree on the component.

{
  "changes": [
    {
      "id": "1576165514:17",
      "overrides": [
        { "target": "1576165514:12", "stroke": "#5B5BF0" },
        { "target": "1576165514:13", "stroke": "#5B5BF0" }
      ]
    }
  ]
}

That is update_nodes. For a filled icon, override fill instead.

Replace a file with a newer one#

When a designer redraws an icon, bring the new file in over the old component. Every instance follows at once, at every size.

The bell redrawn: every instance follows
The bell redrawn: every instance follows

This is done through an agent. It is import_icons with existing: "replace":

{
  "paths": ["/Users/you/Projects/app/icons/bell.svg"],
  "existing": "replace",
  "color": "#14171C"
}

The reply marks the component "replaced": true. It keeps its id and name, so nothing that uses it needs to change. existing: "add" makes a second component of the same name instead.

Note

Instances keep the color they were given. Where the new drawing has as many shapes as the old, each keeps what was set on it; where it has more or fewer, an instance recolored as a whole (one fill, or one stroke, on all its shapes) has every new shape recolored, and a change made shape by shape is dropped.