Cairo doesn't support color names, so this will ease the transition.
#define OUTPUT_CHART_PROVIDER_H 1
#include <stdbool.h>
+#include <stdint.h>
#include <output/chart.h>
+struct chart_colour
+ {
+ uint8_t red;
+ uint8_t green;
+ uint8_t blue;
+ };
+
struct chart_class
{
void (*draw) (const struct chart *, plPlotter *);
/* Default font size for the plot (if zero, then use plotter default) */
int font_size;
- char fill_colour[10];
+ struct chart_colour fill_colour;
/* Stuff Particular to Cartesians (and Boxplots ) */
double ordinate_scale;
/* Set line thickness. */
pl_flinewidth_r (lp, 0.25);
- pl_pencolorname_r (lp, "black");
+ pl_pencolor_r (lp, 0, 0, 0);
/* Erase graphics display. */
pl_erase_r (lp);
geom->legend_left = 810;
geom->legend_right = 1000;
geom->font_size = 0;
- strcpy (geom->fill_colour, "red");
+
+ geom->fill_colour.red = 255;
+ geom->fill_colour.green = 0;
+ geom->fill_colour.blue = 0;
/* Get default font size */
if (!geom->font_size)
/* Draw the box */
pl_savestate_r (lp);
- pl_fillcolorname_r (lp, geom->fill_colour);
+ pl_fillcolor_r (lp,
+ geom->fill_colour.red * 257,
+ geom->fill_colour.green * 257,
+ geom->fill_colour.blue * 257);
pl_filltype_r (lp,1);
pl_fbox_r (lp,
box_left,
double centre_x, double centre_y,
double radius,
double start_angle, double segment_angle,
- const char *colour) ;
+ const struct chart_colour *) ;
draw_segment (lp,
centre_x, centre_y, radius,
angle, segment_angle,
- data_colour[i % N_CHART_COLOURS]);
+ &data_colour[i % N_CHART_COLOURS]);
/* Now add the labels */
if ( label_x < centre_x )
double x0, double y0,
double radius,
double start_angle, double segment_angle,
- const char *colour)
+ const struct chart_colour *colour)
{
const double start_x = x0 - radius * sin(start_angle);
const double start_y = y0 + radius * cos(start_angle);
pl_savestate_r(lp);
pl_savestate_r(lp);
- pl_colorname_r(lp, colour);
+ pl_color_r(lp, colour->red * 257, colour->green * 257, colour->blue * 257);
pl_pentype_r(lp,1);
pl_filltype_r(lp,1);
#include "xalloc.h"
-const char *const data_colour[N_CHART_COLOURS] =
+const struct chart_colour data_colour[N_CHART_COLOURS] =
{
- "brown",
- "red",
- "orange",
- "yellow",
- "green",
- "blue",
- "violet",
- "grey",
- "pink"
+ { 165, 42, 42 }, /* brown */
+ { 255, 0, 0 }, /* red */
+ { 255, 165, 0 }, /* orange */
+ { 255, 255, 0 }, /* yellow */
+ { 0, 255, 0 }, /* green */
+ { 0, 0, 255 }, /* blue */
+ { 238, 130, 238 }, /* violet */
+ { 190, 190, 190 }, /* grey */
+ { 255, 192, 203 }, /* pink */
};
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#ifndef PLOT_CHART_H
+#define PLOT_CHART_H
+
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <math/chart-geometry.h>
#include <output/chart.h>
+#include <output/chart-provider.h>
#include <libpspp/compiler.h>
#include <libpspp/str.h>
#include <output/manager.h>
#include <output/output.h>
-#include "xalloc.h"
-
-#ifndef PLOT_CHART_H
-#define PLOT_CHART_H
-
#define N_CHART_COLOURS 9
-extern const char *const data_colour[];
+extern const struct chart_colour data_colour[];
enum tick_orientation
{
pl_savestate_r (lp);
pl_move_r (lp,geom->data_left, geom->data_bottom);
- pl_fillcolorname_r (lp, geom->fill_colour);
+ pl_fillcolor_r (lp,
+ geom->fill_colour.red * 257,
+ geom->fill_colour.green * 257,
+ geom->fill_colour.blue * 257);
pl_filltype_r (lp,1);