0.2.2 • Published 11 months ago

@mtillmann/ishihara v0.2.2

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

Render Process

ishihara

Generate Ishihara test plate images for color vision deficiency testing.

Installation

npm i @mtillmann/ishihara

Usage

The async ishihara function takes an options-object (see below) and returns an instance of CirclePacker from the circlepacker-package.

Use any of CirclePacker's output helper methods to render the image.

You can pass a CirclePacker-options-object inside the options.circlePackerOptions property.

Using a Bundler

import ishihara from '@mtillmann/ishihara';

const image = (await ishihara()).asCanvas();
document.body.appendChild(image);
//or
ishihara().then((image) => {
  document.body.appendChild(image.asCanvas());
});

Module Script Tag

<script type="module">
  import ishihara from '.../@mtillmann/ishihara/dist/index.bundle.js';

  const image = (await ishihara()).asCanvas();
  document.body.appendChild(image);
</script>

Classic Script Tag

<script src=".../@mtillmann/ishihara/dist/index.bundle.iife.js"></script>
<script>
  const image = (await ishihara()).asCanvas();
  document.body.appendChild(image);
</script>

Options

The ishihara function takes an options object with the following properties:

OptionTypeDefaultDescription
circlePackerOptionsPartial\<circlePackerOptions>{}Options for the CirclePacker
textColorsstring[]'#ffffff'Colors for the text
backgroundColorsstring[]'#000000'Colors for the background
textstring'8'Text to display, max 2 characters
fontstring'bold 256px sans-serif'Font for the text (see)
radiusnumber|'auto''auto'Radius of the circles, 'auto' will calculate the radius based on the text size
paddingnumber|string'20%'Padding around the text, can be a number or a percentage
marginnumber|string'10%'Margin around the image, can be a number or a percentage
debugbooleanfalserenders debug image with same output api as CirclePacker
0.2.2

11 months ago

0.2.1

11 months ago

0.2.0

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago

0.0.1

11 months ago