The default colours for charts in PNG format was black on black,
which wasn't very useful. This change makes the defaults black
on white.
Perhaps for png charts intended for embedding in HTML it should be
black on transparent, but this hasn't been implemented in this change.
Fixes bugs #40107 and #40208
enum emphasis_style emphasis; /* How to emphasize text. */
char *chart_file_name; /* Name of files used for charts. */
enum emphasis_style emphasis; /* How to emphasize text. */
char *chart_file_name; /* Name of files used for charts. */
+ /* Colours for charts */
+ struct xr_color fg;
+ struct xr_color bg;
+
+
int width; /* Page width. */
int length; /* Page length minus margins and header. */
bool auto_width; /* Use viewwidth as page width? */
int width; /* Page width. */
int length; /* Page length minus margins and header. */
bool auto_width; /* Use viewwidth as page width? */
a->auto_length = paper_length < 0;
a->length = paper_length - vertical_margins (a);
a->auto_length = paper_length < 0;
a->length = paper_length - vertical_margins (a);
+ parse_color (d, o, "background-color", "#FFFFFFFFFFFF", &a->bg);
+ parse_color (d, o, "foreground-color", "#000000000000", &a->fg);
+
box = parse_enum (opt (d, o, "box", "ascii"),
"ascii", BOX_ASCII,
"unicode", BOX_UNICODE,
box = parse_enum (opt (d, o, "box", "ascii"),
"ascii", BOX_ASCII,
"unicode", BOX_UNICODE,
char *file_name;
file_name = xr_draw_png_chart (chart_item, a->chart_file_name,
char *file_name;
file_name = xr_draw_png_chart (chart_item, a->chart_file_name,
+ a->chart_cnt++,
+ &a->fg,
+ &a->bg);
if (file_name != NULL)
{
struct text_item *text_item;
if (file_name != NULL)
{
struct text_item *text_item;
void (*destroy) (struct xr_render_fsm *);
};
void (*destroy) (struct xr_render_fsm *);
};
-struct xr_color
-{
- double red;
- double green;
- double blue;
-};
-
/* Cairo output driver. */
struct xr_driver
{
/* Cairo output driver. */
struct xr_driver
{
Future implementations might allow things like "yellow" and
"sky-blue-ultra-brown"
*/
Future implementations might allow things like "yellow" and
"sky-blue-ultra-brown"
*/
parse_color (struct output_driver *d, struct string_map *options,
const char *key, const char *default_value,
struct xr_color *color)
parse_color (struct output_driver *d, struct string_map *options,
const char *key, const char *default_value,
struct xr_color *color)
char *
xr_draw_png_chart (const struct chart_item *item,
char *
xr_draw_png_chart (const struct chart_item *item,
- const char *file_name_template, int number)
+ const char *file_name_template, int number,
+ const struct xr_color *fg,
+ const struct xr_color *bg
+ )
{
const int width = 640;
const int length = 480;
{
const int width = 640;
const int length = 480;
surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, length);
cr = cairo_create (surface);
surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, length);
cr = cairo_create (surface);
- cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+ cairo_set_source_rgb (cr, bg->red, bg->green, bg->blue);
+ cairo_paint (cr);
+
+ cairo_set_source_rgb (cr, fg->red, fg->green, fg->blue);
xr_draw_chart (item, cr, 0.0, 0.0, width, length);
xr_draw_chart (item, cr, 0.0, 0.0, width, length);
bool xr_driver_need_new_page (const struct xr_driver *);
bool xr_driver_is_page_blank (const struct xr_driver *);
bool xr_driver_need_new_page (const struct xr_driver *);
bool xr_driver_is_page_blank (const struct xr_driver *);
+struct xr_color
+{
+ double red;
+ double green;
+ double blue;
+};
+
+struct output_driver;
+struct string_map;
+
+void parse_color (struct output_driver *d, struct string_map *options,
+ const char *key, const char *default_value,
+ struct xr_color *color);
+
+
/* Render charts with Cairo. */
char *xr_draw_png_chart (const struct chart_item *,
/* Render charts with Cairo. */
char *xr_draw_png_chart (const struct chart_item *,
- const char *file_name_template, int number);
+ const char *file_name_template, int number,
+ const struct xr_color *fg,
+ const struct xr_color *bg);
+
{
struct output_driver driver;
{
struct output_driver driver;
+ struct xr_color fg;
+ struct xr_color bg;
+
char *file_name;
char *chart_file_name;
char *file_name;
char *chart_file_name;
html->file = NULL;
html->chart_cnt = 1;
html->file = NULL;
html->chart_cnt = 1;
+ parse_color (d, o, "background-color", "#FFFFFFFFFFFF", &html->bg);
+ parse_color (d, o, "foreground-color", "#000000000000", &html->fg);
+
html->file = fn_open (html->file_name, "w");
if (html->file == NULL)
{
html->file = fn_open (html->file_name, "w");
if (html->file == NULL)
{
char *file_name;
file_name = xr_draw_png_chart (chart_item, html->chart_file_name,
char *file_name;
file_name = xr_draw_png_chart (chart_item, html->chart_file_name,
+ html->chart_cnt++,
+ &html->fg,
+ &html->bg
+ );
if (file_name != NULL)
{
const char *title = chart_item_get_title (chart_item);
if (file_name != NULL)
{
const char *title = chart_item_get_title (chart_item);