# Textures.js — card for AI agents

JavaScript library for creating SVG patterns, built on d3.js for data visualization.

Category: Backgrounds, patterns and shapes · maker Riccardo Scalco · checked 2026-11-09

## Price
- Price: Free
- Free tier: Free open-source library under the MIT license

## License
MIT — https://github.com/riccardoscalco/textures

- commercial: **yes** (Commercial use OK)
  > ## License MIT
  (https://github.com/riccardoscalco/textures)
- attribution: **no** (No credit needed)
  > ## License MIT
  (https://github.com/riccardoscalco/textures)
- in app: **yes** (Can ship inside your app)
  > ## License MIT
  (https://github.com/riccardoscalco/textures)

## Rules to follow
- Keep the MIT license notice with the library files you ship.
- Install from npm (textures) or download textures.js locally instead of relying on a CDN at runtime.
- Use it alongside d3 to generate SVG patterns.

## Can an AI agent use it by itself?
**Yes** · package: Agent installs a package or loads it from a CDN

## How an agent gets files
- npm install textures and use it with d3 (textures.lines(), circles(), paths()); generates SVG patterns.
- Formats: js, svg

## How to connect
- Package (npm/PyPI)
- npm: `npm install textures`
- Repository: https://github.com/riccardoscalco/textures
- Website: https://riccardoscalco.it/textures/

## Notes
Last release 1.2.3 (npm, 2021-04-17).

## Numbers (AgentGid data)
- Gid Score: 37
- GitHub stars: 6,089
- Downloads last week: 8,514

## Lines to paste into your prompt or AGENTS.md

```
- Textures.js (Backgrounds, patterns and shapes). JavaScript library for creating SVG patterns, built on d3.js for data visualization. Price: free; commercial use OK; no credit needed.
  Connect: npm textures.
  Get files: npm install textures and use it with d3 (textures.lines(), circles(), paths()); generates SVG patterns (js, svg).
  Rule: Keep the MIT license notice with the library files you ship.
  Rule: Install from npm (textures) or download textures.js locally instead of relying on a CDN at runtime.
  Rule: Use it alongside d3 to generate SVG patterns.
  License: https://github.com/riccardoscalco/textures (checked 2026-11-09; details: https://agentgid.com/assets/textures-js/)
```

## Links
- AgentGid page: https://agentgid.com/assets/textures-js/
- Is it free for commercial use? https://agentgid.com/assets/textures-js/commercial-use/
- Source: https://github.com/riccardoscalco/textures


## Textures.js: striped and dotted fills for charts

Textures.js is a small free code library that fills shapes with patterns such as stripes, dots, hexagons or waves instead of flat color. It is made for charts and maps drawn with the D3 toolkit, so groups can be told apart by pattern as well as by color. The patterns are SVG drawings and stay sharp at any size.

### Where to use it
- Bars told apart by pattern: Give each group in a bar or pie chart its own stripe, dot or grid fill, so readers can tell the groups apart even when colors look alike.
- Show more and less with pattern size: Show an order, such as low, medium and high, with the same pattern in growing sizes. This works for heat levels on a map or risk levels in a table.
- More groups with color plus pattern: When a chart has more groups than you have good colors, mix a few colors with a few patterns to get many clear combinations.
- Your own pattern shape: Draw a small shape of your own, such as a zigzag or a chevron, and repeat it as a fill that matches your brand.
- Charts that print in black and white: Reports and handouts that may be printed without color keep their meaning, because each group has its own pattern. (idea, not from the official pages)
- Hatched areas on a map: Mark areas on a map, such as flood zones or regions without data, with stripes over the normal map colors. (idea, not from the official pages)

### How to start
- Install the package, or download the textures.js file into your project and load it with a script tag.

```
npm install textures
```

- Import it in your code; it needs D3 (or at least d3-selection) on the page to draw.

```
import textures from 'textures';
```

- Make a texture, add it to the svg with call(), then use its url() as the fill of a shape.

```
const svg = d3
  .select('#example')
  .append("svg");

const texture = textures
  .lines()
  .thicker();

svg.call(texture);

svg
  .append('circle')
  .style('fill', texture.url());
```


### License
MIT license: free to use in personal and paid products, and you may change and share the code. When you ship copies of the library, keep its copyright and license notice with them.

### Good to know
- The last release, 1.2.3, came out in April 2021. It still works with today's D3, but expect no new features or fixes.
- It draws with D3. Without D3 or its small selection part on the page, the patterns are not added.
- The patterns are SVG drawings, so they only fill SVG shapes. Charts drawn on a canvas, like most Chart.js charts, cannot use them.
- Everything runs in your page. No account, key or outside service is needed.

Checked 2026-11-09 against: https://github.com/riccardoscalco/textures, https://github.com/riccardoscalco/textures/blob/HEAD/README.md, https://github.com/riccardoscalco/textures/blob/HEAD/license, https://github.com/riccardoscalco/textures/blob/HEAD/src/random.js, https://github.com/riccardoscalco/textures/blob/HEAD/src/lines.js, https://riccardoscalco.it/textures/, https://registry.npmjs.org/textures

### Mistakes to avoid
- Don't: svg.append('rect').style('fill', texture.url()) without svg.call(texture) first → Do: Call svg.call(texture) on the same svg before using texture.url() as a fill (call() is what writes the <pattern> into the svg; url() only returns its address, so the shape stays empty without it.)
- Don't: Relying on the automatic pattern ids when the chart is rendered on the server or exported to files → Do: Give each texture a fixed id with .id('stripes-north') when the markup must be the same on every render (Without .id() each texture gets a random five-letter id at creation, so the markup changes on every render.)
- Don't: Trying to use textures with a canvas chart (Chart.js, ECharts canvas mode) → Do: Use a chart that draws SVG (D3, or a library's SVG renderer) (The library only makes SVG patterns, which a canvas cannot use.)
- Don't: <script src="https://unpkg.com/textures@1.2.0/dist/textures.js"> copied from the README → Do: Install textures@1.2.3 or download dist/textures.js into your project (The README link points to an older 1.2.0 build and makes every visitor load the file from an outside server.)

### Questions
- Do I need D3? Yes. The library is built on top of D3 and adds its patterns through a D3 selection; the small d3-selection part is enough.
- What kinds of patterns are there? Three families, lines, circles and paths (hexagons, crosses, caps, woven, waves, nylon, squares), plus your own path shape.
- Can I change colors and thickness? Yes. Each texture has settings such as size, strokeWidth, stroke, fill, background and orientation, and heavier, lighter, thicker and thinner.
- Can I use it in a paid product? Yes. It is MIT licensed; keep the license notice with copies of the code.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
