Project

General

Profile

Actions

Tips and Tricks » History » Revision 6

« Previous | Revision 6/10 (diff) | Next »
Danis Freeman, 03/02/2011 10:00 AM


h1. Tips and Tricks

{{toc}}

h2. Making a hard-copy of painted graphics

The primary use for the Wt painting API is to paint on a WPaintedWidget. Internally, this uses either a VML, SVG or HTML 5 canvas painting device to deliver the painting to the browser.

It is also possible to paint directly to an SVG image, which is a standardized generic vector graphics format, and increasingly supported by various tools.

You could use the SVG image as a starting point for exporting the painted graphics to raster format. Using the "imagemagick":http://www.imagemagick.org/script/index.php or "graphicsmagick":http://www.graphicsmagick.org/ libraries, you can convert from SVG to other formats using the library API or using the command line 'convert' tool. Using "inkscape":http://www.inkscape.org/, a sophisticated SVG editor, you may get high quality SVG rendering (with, compared to imagemagick, much better font support) from the command-line (see the manpage). Another option may be "librsvg":http://librsvg.sourceforge.net.

The WSvgImage class allows you to easily create an SVG image, and save it to a (file) stream, using the following template:

WSvgImage image(400, 300);
WPainter painter(&image);

// paint things on the painter, like you normally do in WPaintedWidget::paintEvent().
//
// e.g. you could do WCartesianChart *c = ...
// c->paint(painter);

painter.end();
std::ofstream f("image.svg");
image.write(f);
f.close();

h2. Creating .CUR files

Creating .CUR files which are valid in Firefox and Chrome can be quite a pickle, especially if you want to specify a custom hotspot.
This program allows you to create such .CUR files:
http://www.rw-designer.com/cursor-maker

h2. Assert

Under some environments, when linking to the Wt library, 'assert' is removed from the code. This page shows a custom assert to be used with Wt: http://richelbilderbeek.nl/CppWtAssert.htm

"essay writing .":http://essaywritingservices.org/index.php

Updated by Danis Freeman about 13 years ago · 6 revisions