Qtasciimage

QtAsciimage - Asciimage for Qt Applications
Alternatives To Qtasciimage
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Plotline24
7 years agogpl-3.0C++
Application for Planning, Plotting, and Writing a Novel
Omegarpg16
14 days ago1gpl-3.0C++
OmegaRPG is a free, open-source Virtual Tabletop application.
Flist Messenger16
7 years ago28C++
A multi-platform desktop client for the F-Chat protocol.
Qescpos10
4 years agoapache-2.0C++
Some classes for Qt to interact with ESC/POS printers
Qtcreator Easymotion10
8 years ago3C++
An EasyMotion plugin for Qt Creator
Qtasciimage7
8 years ago1mitC++
QtAsciimage - Asciimage for Qt Applications
Pinyin4cpp6
8 years agoC++
Pinyin4cpp is a c plus plus library supporting convertion between Chinese characters and hanyu pinyin that based on Qt.
Pattern Gen6
8 years agoC++
Pattern-Gen
Twofold Qt6
2 years agoapache-2.0C++
C++11/Qt implementation of Twofold, the universal source code generation template language
Attorney Online Client6
7 years ago1gpl-3.0C++
This is the new client project based on the Qt framework
Alternatives To Qtasciimage
Select To Compare


Alternative Project Comparisons
Readme

QtAsciimage

QtAsciimage - Asciimage for Qt Applications

This is a C++/Qt version of Charles Parnot's ASCIImage format. ASCIImage let's you specify simple images directly in your source code using 'ASCII art'.

Format Extension

QtAsciimage uses an extended format allowing for a direct styling of the individual ASCIImage shapes. The styling rules are appended to the ASCIImage, separated by a line containing three dashes --- only:

. . . . 5 . . . .
. . . . # . . . .
. . . . # . . . .
. . . . # . . . .
. . 1 . # . 3 . .
. . . # 5 # . . .
6 . . . 2 . . . 9
# . . . . . . . #
7 # # # # # # # 8
---
1 open color=#FF0000
5 color=#FF0000
6 open 

A styling rule contains of a shape identifier (the character that is used in the ASCIImage to start the corresponding shape) and a set of styling options:

ID [color=#RRGGBB] [open] [empty] [cutting]
  • ID Shape identifier. The character that is used to start the curresponding shape. E.g. in the above example the polyline made from the consecutive characters 6, 7, 8, 9 is identified by the shaped first character 6.

  • color=#RRGGBB Applicable to all shape types. The shape is drawn in the given hex-color instead of the default color (black).

  • open Applicable to polygons. The shape is not automatically closed, and thus drawn as a polyline instead of a polygon.

  • empty Applicable to ellipses and polygons. The shape is not filled; only the edge is drawn.

  • cutting Applicable to all shape types. Instead of drawing the shape, it is cut out of the previsously drawn shapes, leaving a 'hole'.

Styling rules and the styling rules section are completely optional; if there is no styling rule for a shape, it is drawn in the default style (black color, closed, and filled).

Usage

To include QtAsciimage into your QMake-based project, copy the QtAsciimage directory to your project tree and include() QtAsciimage's pri-file in you main QMake-file:

include(QtAsciimage/QtAsciimage.pri)

Of course you need to include() QtAsciimage's header files (QtAsciimage/image.h should normally suffice; you also need QtAsciimage/iconengine.h if you want to use the QIconEngine) into your C++ sources.

Rendering to QImage

#include <QtAsciimage/image.h>
// ...

asciimage::Image asciiSun({
  ". . . . 8 . . . .",
  ". 7 . . 8 . . 9 .",
  ". . 7 . . . 9 . .",
  ". . . . 1 . . . .",
  "6 6 . 1 # 1 . 2 2",
  ". . . . 1 . . . .",
  ". . 5 . . . 3 . .",
  ". 5 . . 4 . . 3 .",
  ". . . . 4 . . . ."
});

int scale = 4;
QImage result = asciiSun.render(scale);

Rendering via QIconEngine

#include <QtAsciimage/image.h>
#include <QtAsciimage/iconengine.h>
// ...

asciimage::Image asciiSaveIcon({
  ". . . . 5 . . . .",
  ". . . . # . . . .",
  ". . . . # . . . .",
  ". . . . # . . . .",
  ". . 1 . # . 3 . .",
  ". . . # 5 # . . .",
  "6 . . . 2 . . . 9",
  "# . . . . . . . #",
  "7 # # # # # # # 8",
  "---",
  "1 open",
  "6 open"
});
QIconEngine* iconEngine = new asciimage::IconEngine(asciiSaveIcon);
QAction* saveAction = new QAction("Save", this);
saveAction->setIcon(QIcon(iconEngine));
// add saveAction to a toolbar/menu to display the icon

Demo Program / QtAsciimageEditor

QtAsciimageEditor let's you edit Asciimages visually and, furthermore, demos how to use the QtAsciimage library.

Screenshot of QtAsciimageEditor

Popular Qt Projects
Popular Character Projects
Popular User Interface Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
C Plus Plus
Character
Qt
Shape
Polygon
Polyline