定制 fruit/convas 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fruit/convas

最新稳定版本:0.0.4

Composer 安装命令:

composer require fruit/convas

包简介

canvas for console

README 文档

README

This package is part of Fruit Framework.

Convas is a console drawing library. Currently it supports only UTF-8 encoding.

Build Status

Synopsis

$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

Wide characters

Convas detect wide characters (characters occupied two cells in console, most are CJK characters) using unicode blocks. Feel free to file an issue if any wide character is missing.

Algorithms, PR Plz!

The algorithms used to draw lines and ellipses are too simple to mark as stable. We need your help!

See Issue#2 and Issue#3.

License

Any version of MIT, GPL or LGPL.

统计信息

  • 总下载量: 66
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-10-30