10print 中文文档教程

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

10print

著名的单线 Commodore 64 BASIC 程序的 Nodejs 实现:

10 PRINT CHR$(205.5+RND(1)); : GOTO 10. 

该项目的灵感来自 10 PRINT 一书 (http://10print.org/),您可以在其中找到有关原始程序的所有信息。 该脚本将在控制台上打印一个无限随机序列,该序列仅由字符 /\ 以奇特的模式组成。

Getting Started

要运行此脚本,您只需安装并导入 npm 包,然后运行 ​​goto10 函数。 当然不要忘记终止进程以中断无限循环:)

Installing

npm install 10print

Usage

对于基本用法,运行 goto10() 来打印标准模式:

let p = require("10print");
p.goto10();

如果你想创建自己的自定义模式,可以以这种方式调用printPattern(config)

p.printPattern({
    symbol1: "/", // The first symbol of your pattern
    symbol2: "\\", // The second symbol of your pattern
    weight: 0.5 // Value between 0 and 1 that tunes the probability of each symbol to be displayed
})

这是标准模式的配置。 更改 weight 值将创建一个具有不同符号频率的新符号:设置 0 意味着有 100% 的机会获得第一个符号,1 意味着 100% 的机会获得第二个。 对于 0.5,每个符号都有 50% 的机会。 您也可以更改此值和符号以创建您的自定义模式。

Developing

安装所有依赖项:

npm install

不需要构建。 运行测试:

npm test

License

该项目已获得 MIT 许可 - 请参阅 LICENSE.md 文件了解详细信息

Acknowledgments

  • 10 PRINT (http://10print.org/)

10print

Nodejs implementation of the famous one-line Commodore 64 BASIC program:

10 PRINT CHR$(205.5+RND(1)); : GOTO 10. 

This project was inspired by 10 PRINT book (http://10print.org/) where you can find all the information about the original program. This script will print on the console an infinite random sequence composed only by chars / and \ in a fancy pattern.

Getting Started

To run this script you only need to install and import the npm package, then running the goto10 function. Of course don't forget to kill the process to interrupt the infinite loop :)

Installing

npm install 10print

Usage

For a basic usage run goto10() to print the standard pattern:

let p = require("10print");
p.goto10();

If you want to create your own custom pattern it's possible to call printPattern(config) in this way:

p.printPattern({
    symbol1: "/", // The first symbol of your pattern
    symbol2: "\\", // The second symbol of your pattern
    weight: 0.5 // Value between 0 and 1 that tunes the probability of each symbol to be displayed
})

This is the configuration of the standard pattern. Changing weight value would create a new one with different symbol frequency: setting 0 means to have 100% chance to get first symbol, 1 means 100% chance to get second. With 0.5 there is 50% chance for each symbol. You can change this value and the symbols as well to create your custom pattern.

Developing

Install all the dependencies:

npm install

No build is needed. To run the tests:

npm test

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

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