captcha-canvas.js.org Open in urlscan Pro
2606:4700:20::681a:954  Public Scan

URL: https://captcha-canvas.js.org/
Submission: On July 04 via api from US — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

API Documentation


DOCUMENTATION


CLASSES

 * CaptchaGenerator


GLOBAL

 * defaultCaptchaOptions
 * defaultDecoyOptions
 * defaultTraceOptions
 * getRandom


HOME




> Note: for v3 (skia-canvas) doumentation click here.


GETTING STARTED

To start using this npm module. We first need to install it from npm by using
command npm install captcha-canvas.

Now require this package in your file where you want to create captcha.

const { CaptchaGenerator } = require("captcha-canvas");

We can see here we get CaptchaGenerator class from the module. Now initiate the
constructor to start using it.

const { CaptchaGenerator } = require("captcha-canvas");
const captcha = new CaptchaGenerator();

Now we can use all the methods documented here to customize captcha according to
our need.

Like if we want to use different dimension. We can use setDimension method.

const { CaptchaGenerator } = require("captcha-canvas");
const captcha = new CaptchaGenerator()
.setDimension(150, 450) 

If we want to change captcha text or its appearance, then we can use setCaptcha
method.

const { CaptchaGenerator } = require("captcha-canvas");
const captcha = new CaptchaGenerator()
.setDimension(150, 450) 
.setCaptcha({text: "CUSTOM05", size: 60, color: "deeppink"})

If we want to change appearance of background text (i.e decoy). We can do that
easily by using setDecoy method.

const { CaptchaGenerator } = require("captcha-canvas");
const captcha = new CaptchaGenerator()
.setDimension(150, 450) 
.setCaptcha({text: "CUSTOM05", size: 60, color: "deeppink"})
.setDecoy({opacity: 0.5})

You can also customise trace line and add background by using setTrace and
setBackground method.

Once you customised everything according to your need then just you can get
buffer from generateSync method. And use that buffer to display image in your
project.

const { CaptchaGenerator } = require("captcha-canvas");
const captcha = new CaptchaGenerator()
.setDimension(150, 450) 
.setCaptcha({text: "CUSTOM05", size: 60, color: "deeppink"})
.setDecoy({opacity: 0.5})
.setTrace({color: "deeppink"});
const buffer = captcha.generateSync();

FINAL OUTPUT




SUPPORT

To get help related to this module open an issue in the github repository.

Documentation generated by JSDoc 3.6.7

BetterDocs theme provided with by SoftwareBrothers - JavaScript Development
Agency