Skip to content

Commit

Permalink
improvement in code #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Shashank3736 committed Sep 5, 2020
1 parent 8142125 commit 2090fcd
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions examples/example.js
Expand Up @@ -5,27 +5,29 @@ const fs = require("fs");
* we will use the default value without any update
*/

new Promise(async (resolve, reject) => {
new Promise(async (_resolve, _reject) => {
const captcha = new CaptchaGenerator();
fs.writeFileSync(`./examples/default.png`, await captcha.generate());
fs.writeFileSync("./examples/default.png", await captcha.generate());
//console text of captcha
console.log(captcha.text);
})

//with custom dimension (200, 600)
//200 is height here and 600 width

new Promise(async (resolve, reject) => {
new Promise(async (_resolve, _reject) => {
const captcha = new CaptchaGenerator()
.setDimension(200, 600)
fs.writeFileSync(`./examples/dimension.png`, await captcha.generate());
fs.writeFileSync("./examples/dimension.png", await captcha.generate());
//console text of captcha
console.log(captcha.text);
})

/**
* with custom font
*
*/
new Promise(async (resolve, reject) => {
new Promise(async (_resolve, _reject) => {
const options = {
color: "deeppink",
font: 'Candara',
Expand All @@ -34,18 +36,20 @@ new Promise(async (resolve, reject) => {
const captcha = new CaptchaGenerator()
.setCaptcha(options)
.setDimension(150, 450)
fs.writeFileSync(`./examples/captcha.png`, await captcha.generate());
fs.writeFileSync("./examples/captcha.png", await captcha.generate());
//console text of captcha
console.log(captcha.text);
})

//using all config

new Promise(async (resolve, reject) => {
new Promise(async (_resolve, _reject) => {
const captcha = new CaptchaGenerator()
.setDimension(150, 450)
.setCaptcha({color: "deeppink", size: 60, text: "CUSTOM05"})
.setDecoy({opacity: 0.5})
.setTrace({color: "deeppink", size: 5});
fs.writeFileSync(`./examples/all.png`, await captcha.generate());
fs.writeFileSync("./examples/all.png", await captcha.generate());
//console text of captcha
console.log(captcha.text);
})

0 comments on commit 2090fcd

Please sign in to comment.