fruit/convas

该软件包最新版本(0.0.4)没有可用的许可信息。

控制台画布

0.0.4 2015-11-02 07:00 UTC

This package is auto-updated.

Last update: 2024-08-29 03:49:35 UTC


README

此软件包是 Fruit 框架的一部分。

Convas 是一个控制台绘图库。目前它仅支持 UTF-8 编码。

Build Status

概述

$buf = new Fruit\Convas\Buffer; // create a canvas, origin point is at top-left corner
$g = new Fruit\Convas\Graphics($buf); // allocate graphics object to paint on this canvas
$g
    ->transit(2, 3) // move origin to (2, 3)
    ->drawString(0, 0, 'a string')
    ->drawString(0, 1, '中文') // convas can handle (most of) CJK and graphical characters
    ->drawLine(0, 2, 55, 2) // draw a line from (0, 2) to (55, 2)
    ->drawLine(0, 2, 0, 15) // convas can handle cross point of lines and ellipses
    ->drawEllipse(2, 5, 55, 20) // draw an ellipse within the square (2, 5) (15, 20)
    ->setColor(new Fruit\Convas\Color(1, 37, 41)) // set color
    ->drawString(5, 12, 'highlighted, white text on red background');
echo implode("\n", $buf->exportAll()) . "\n";

$buf->clear(4, 8, 57, 23); // clear the area, take care of the origin point

$g->overwrite = true; // enable overwrite mode, color will always in overwrite mode.
$g->drawLine(5, 2, 5, 15); // no cross point handling

Lines, Ellipses, Wide characters Block of text

宽字符

Convas 使用 Unicode 块检测宽字符(占两个控制台单元格的字符,大多是 CJK 字符)。如果缺少任何宽字符,请随时提交问题。

算法,请提交 PR!

用于绘制线条和椭圆的算法过于简单,无法标记为稳定。我们需要您的帮助!

参见 问题#2问题#3

许可

任何版本的 MIT、GPL 或 LGPL 许可。