Giter Site home page Giter Site logo

andrews54757 / svg-daltonizer Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 44 KB

Generate SVG filters for color vision deficiency simulation and correction

License: MIT License

JavaScript 100.00%
colorblind colorblindness-simulator daltonization-algorithm deuteranopia protanopia svg tritanopia

svg-daltonizer's Introduction

SVG-Daltonizer

Generate SVG filters for color vision deficiency simulation and correction. These filters can then be applied using CSS.

Developed for use in FastStream, a browser extension for better video playback.

Available CVD types:

  1. Protanomaly
  2. Dueteranomaly
  3. Tritanomaly

Uses the LMS daltonization algorithm.

Usage

Demo available in ./demo/ Live on Github Pages. Use SVGDaltonizer.mjs to generate new svg filters.

import { DaltonizerTypes, SVGDaltonizer } from "./SVGDaltonizer.mjs";

let svgobj;
let simulate = false;
let useMachado = true;
let type = DaltonizerTypes.PROTANOMALY;
let strengthValue = 1.0;
if (simulate) {
    svgobj = SVGDaltonizer.makeCVDSimulatorFilter(type, strengthValue, useMachado);
    svgobj.filter.id = 'simulate-' + type + '-' + strengthValue;
} else {
    svgobj = SVGDaltonizer.makeLMSDaltonizerFilter(type, strengthValue, useMachado);
    svgobj.filter.id = 'daltonize-' + type + '-' + strengthValue;
}

targetElement.style.filter = `url(#${svgobj.filter.id})`;
document.head.appendChild(svgobj.svg);

Pregenerated SVG filters are also available in ./pregenerated/

Helpful Resources

http://www.daltonize.org/2010/05/lms-daltonization-algorithm.html

https://ixora.io/projects/colorblindness/color-blindness-simulation-research/

https://www.inf.ufrgs.br/~oliveira/pubs_files/CVD_Simulation/CVD_Simulation.html

License

Available for use under the MIT license. See LICENSE.md for more information.

svg-daltonizer's People

Contributors

andrews54757 avatar

Stargazers

 avatar Rob Kittinger, PhD avatar

Watchers

 avatar  avatar

Forkers

luckymeef

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.