@2003scape/rsc-captcha 中文文档教程

发布于 3年前 浏览 28 项目主页 更新于 3年前

rsc-captcha

生成 runescape 经典睡眠屏幕单词。 玩家将进入生成的 疲劳系统中的单词 继续积累经验。

install

$ npm install @2003scape/rsc-captcha

example

const Captcha = require('./src/index');
const captcha = new Captcha();
const fs = require('fs');

(async () => {
    await captcha.loadFonts();

    for (let i = 0; i < 10; i += 1) {
        const { word, image } = captcha.generate();

        if (process.browser) {
            document.body.appendChild(new Text(word));
            document.body.appendChild(image);
            document.body.appendChild(document.createElement('br'));
        } else {
            fs.writeFileSync(`${word}.png`, image.toBuffer());
        }
    }
})();

api

Captcha.toByteArray(canvas)

将任何画布转换为游戏客户端兼容的 RLE 字节数组。

captcha = new Captcha(words?)

创建一个新的验证码生成器实例。 words 是随机排列的单词数组 从中选择(默认为 en-uk,长度在 4-9 之间)。

async captcha.loadFonts()

加载主要字体图像 (font.png)。 在生成验证码之前运​​行。

captcha.generate()

生成一个词和与之关联的验证码。 返回:

{
    image: Canvas,
    word: String
}

captcha.getWord()

从字典中随机选择一个单词。

captcha.generateImage(word)

用指定的词创建一个画布。

license

版权所有 2020 2003Scape Team

该程序是免费软件:您可以重新分发它和/或修改它 GNU Affero 通用公共许可证的条款由 自由软件基金会,许可证的第 3 版,或(由您选择) 任何更高版本。

分发该程序是希望它有用,但没有任何 保修单; 甚至没有适销性或适用性的默示保证 特殊用途。 有关详细信息,请参阅 GNU Affero 通用公共许可证。

您应该已经收到 GNU Affero 通用公共许可证的副本 有了这个程序。 如果没有,请参阅 http://www.gnu.org/licenses/。

rsc-captcha

generate runescape classic sleep screen words. players would enter the generated word during the fatigue system to continue gaining experience.

install

$ npm install @2003scape/rsc-captcha

example

const Captcha = require('./src/index');
const captcha = new Captcha();
const fs = require('fs');

(async () => {
    await captcha.loadFonts();

    for (let i = 0; i < 10; i += 1) {
        const { word, image } = captcha.generate();

        if (process.browser) {
            document.body.appendChild(new Text(word));
            document.body.appendChild(image);
            document.body.appendChild(document.createElement('br'));
        } else {
            fs.writeFileSync(`${word}.png`, image.toBuffer());
        }
    }
})();

api

Captcha.toByteArray(canvas)

convert any canvas into a game client-compatible RLE byte array.

captcha = new Captcha(words?)

create a new captcha generator instance. words is an array of words to randomly select from (defaults to en-uk with lengths between 4-9).

async captcha.loadFonts()

load the main font image (font.png). run before generating captchas.

captcha.generate()

generate a word and captcha associated with it. returns:

{
    image: Canvas,
    word: String
}

captcha.getWord()

pick a random word from the dictionary.

captcha.generateImage(word)

create a Canvas with specified word.

license

Copyright 2020 2003Scape Team

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses/.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文