UNPKG

webopenyeye-svg-captcha

Version:

svg-captcha

26 lines (24 loc) 904 B
function create() { let str = '123456789' let one = Math.floor(Math.random() * (str.length - 1 - 0 + 1) + 0) let two = Math.floor(Math.random() * (str.length - 1 - 0 + 1) + 0) let three = Math.floor(Math.random() * (str.length - 1 - 0 + 1) + 0) let four = Math.floor(Math.random() * (str.length - 1 - 0 + 1) + 0) let text = '' + str[one] + str[two] + str[three] + str[four] return { text, data: `<svg xmlns="http://www.w3.org/2000/svg" version="1.1"> <defs> <filter id="f1" x="0" y="0"> <feGaussianBlur in="SourceGraphic" stdDeviation="18" /> </filter> </defs> <rect width="100" height="100" stroke="skyblue" stroke-width="1" fill="red" filter="url(#f1)" /> <text x="30" y="65" fill="#ff9800" font-size="30px">${text}</text> </svg>` } } module.exports = { create, }