-
Notifications
You must be signed in to change notification settings - Fork 0
createCaptcha
This function lets you create a captcha.
ALL arguments are optional but they can personalize the result captcha!
Example:
const captcha = await createCaptcha({
length: 5,
bgColor: "#00000000",
bgColorDiff: {R: 20, G: 20, B: 20},
decoys: {amount: 40, sizeMin: 10, sizeMax: 25},
randomCharOrder: true,
characters: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()",
width: 600,
height: 400,
minCharacterSize: 30,
maxCharacterSize: 100,
characterColor: "#FF0000",
lineColor: "#00FF00",
decoyColor: "#0000FF"
});- length
- bgColor
- bgColorDiff
- decoys
- characters
- randomCharOrder
- width
- height
- minCharacterSize
- maxCharacterSize
- characterColor
- lineColor
- decoyColor
Name: length
Type: Number
Default: 5
Description: how many characters the captcha should have
Name: bgColor
Type: String
Default: random (could be bad for people with colorblindness)
Description: Background color of the captcha
Name: bgColorDiff
Type: Object
Default: {R: 20, G: 20, B: 20}
| Sub-Option | Type | Description | Default (value if you don't give any) |
|---|---|---|---|
| R | Number | the minimum difference between Red in the colorcode of the characters | 20 |
| G | Number | the minimum difference between Green in the colorcode of the characters | 20 |
| B | Number | the minimum difference between Blue in the colorcode of the characters | 20 |
Name: decoys
Type: Object
Default: {amount: 40, sizeMin: 10, sizeMax: 25}
| Sub-Option | Type | Description | Default (value if you don't give any) |
|---|---|---|---|
| amount | Number | the amount of decoys to add | 40 |
| sizeMin | Number | the minimum of the random character size for the decoys | 10 |
| sizeMax | Number | the maximum of the random character size for the decoys | 10 |
Name: characters
Type: String
Default: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()'
Description: the characters that the image is allowed to include
Name: randomCharOrder
Type: Boolean
Default: true
Description: if it should pick random characters out of the provided string. If you want a custom, non-random string, the length should be equal to the string argument length
Name: width
Type: Integer
Default: 600
Description: sets the minimum size of the canvas in the X direction
Name: height
Type: Integer
Default: 400
Description: sets the minimum size of the canvas in the Y direction
Name: minCharacterSize
Type: Integer
Default: 30
Description: sets the minimum size of each character. Sometimes if the length value is too high the characters can be too small to read
Name: maxCharacterSize
Type: Integer
Default: undefined
Description: sets the maximum size of each character. Recommended to set if length is small.
Name: characterColor
Type: String
Default: undefined
Description: sets the character color for each character to the specified hex code. Use undefined to use a randomly generated color for each character
Name: lineColor
Type: String
Default: undefined
Description: sets the line color for to the specified hex code. Use undefined to use a randomly generated color
Name: decoyColor
Type: String
Default: undefined
Description: sets the decoy color for to the specified hex code. Use undefined to use the lineColor
