projects
/
pspp-builds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0a214c1
)
charts: Use numeric colors instead of color names.
author
Ben Pfaff
<blp@gnu.org>
Tue, 28 Jul 2009 13:41:06 +0000
(06:41 -0700)
committer
Ben Pfaff
<blp@gnu.org>
Tue, 28 Jul 2009 13:41:06 +0000
(06:41 -0700)
Cairo doesn't support color names, so this will ease the transition.
src/output/chart-provider.h
patch
|
blob
|
history
src/output/chart.c
patch
|
blob
|
history
src/output/charts/box-whisker.c
patch
|
blob
|
history
src/output/charts/piechart.c
patch
|
blob
|
history
src/output/charts/plot-chart.c
patch
|
blob
|
history
src/output/charts/plot-chart.h
patch
|
blob
|
history
src/output/charts/plot-hist.c
patch
|
blob
|
history
diff --git
a/src/output/chart-provider.h
b/src/output/chart-provider.h
index 4b36c55a145b6eed4c25d2a361e8574a519015c1..2ff4aafafddbdd6daf7039f1ec34e100debdcbc0 100644
(file)
--- a/
src/output/chart-provider.h
+++ b/
src/output/chart-provider.h
@@
-18,8
+18,16
@@
#define OUTPUT_CHART_PROVIDER_H 1
#include <stdbool.h>
#define OUTPUT_CHART_PROVIDER_H 1
#include <stdbool.h>
+#include <stdint.h>
#include <output/chart.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 *);
struct chart_class
{
void (*draw) (const struct chart *, plPlotter *);
@@
-57,7
+65,7
@@
struct chart_geometry
/* Default font size for the plot (if zero, then use plotter default) */
int font_size;
/* 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;
/* Stuff Particular to Cartesians (and Boxplots ) */
double ordinate_scale;
diff --git
a/src/output/chart.c
b/src/output/chart.c
index 2a2bc12451d8c5fc5187c4d13415c09b47f88933..8d99f41fd0194b04a25949f8b52099a9588040d0 100644
(file)
--- a/
src/output/chart.c
+++ b/
src/output/chart.c
@@
-58,7
+58,7
@@
chart_geometry_init (plPlotter *lp, struct chart_geometry *geom)
/* Set line thickness. */
pl_flinewidth_r (lp, 0.25);
/* Set line thickness. */
pl_flinewidth_r (lp, 0.25);
- pl_pencolor
name_r (lp, "black"
);
+ pl_pencolor
_r (lp, 0, 0, 0
);
/* Erase graphics display. */
pl_erase_r (lp);
/* Erase graphics display. */
pl_erase_r (lp);
@@
-77,7
+77,10
@@
chart_geometry_init (plPlotter *lp, struct chart_geometry *geom)
geom->legend_left = 810;
geom->legend_right = 1000;
geom->font_size = 0;
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)
/* Get default font size */
if (!geom->font_size)
diff --git
a/src/output/charts/box-whisker.c
b/src/output/charts/box-whisker.c
index 301d762b8b8fca1039a6ed197c30457175097f93..24b2914593b4a1a9e1f224f5d6eb4ddb401aa166 100644
(file)
--- a/
src/output/charts/box-whisker.c
+++ b/
src/output/charts/box-whisker.c
@@
-142,7
+142,10
@@
boxplot_draw_box (plPlotter *lp, const struct chart_geometry *geom,
/* Draw the box */
pl_savestate_r (lp);
/* 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,
pl_filltype_r (lp,1);
pl_fbox_r (lp,
box_left,
diff --git
a/src/output/charts/piechart.c
b/src/output/charts/piechart.c
index 4b7b1400e9c42e1bd95d1a9d4310ea9939ccc5e9..94881b417a2b7d3e4de784d67fb641156fb5489c 100644
(file)
--- a/
src/output/charts/piechart.c
+++ b/
src/output/charts/piechart.c
@@
-48,7
+48,7
@@
draw_segment(plPlotter *,
double centre_x, double centre_y,
double radius,
double start_angle, double segment_angle,
double centre_x, double centre_y,
double radius,
double start_angle, double segment_angle,
- const
char *colour
) ;
+ const
struct chart_colour *
) ;
@@
-121,7
+121,7
@@
piechart_draw (const struct chart *chart, plPlotter *lp)
draw_segment (lp,
centre_x, centre_y, radius,
angle, segment_angle,
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 )
/* Now add the labels */
if ( label_x < centre_x )
@@
-197,7
+197,7
@@
draw_segment(plPlotter *lp,
double x0, double y0,
double radius,
double start_angle, double segment_angle,
double x0, double y0,
double radius,
double start_angle, double segment_angle,
- const
cha
r *colour)
+ const
struct chart_colou
r *colour)
{
const double start_x = x0 - radius * sin(start_angle);
const double start_y = y0 + radius * cos(start_angle);
{
const double start_x = x0 - radius * sin(start_angle);
const double start_y = y0 + radius * cos(start_angle);
@@
-205,7
+205,7
@@
draw_segment(plPlotter *lp,
pl_savestate_r(lp);
pl_savestate_r(lp);
pl_savestate_r(lp);
pl_savestate_r(lp);
- pl_color
name_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);
pl_pentype_r(lp,1);
pl_filltype_r(lp,1);
diff --git
a/src/output/charts/plot-chart.c
b/src/output/charts/plot-chart.c
index 86e1c80f4456b0ef97ff3a0dcc837704f46534c2..9d298cd26ab376b8a230d4c0c4e17521b6b7095f 100644
(file)
--- a/
src/output/charts/plot-chart.c
+++ b/
src/output/charts/plot-chart.c
@@
-35,17
+35,17
@@
#include "xalloc.h"
#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 */
};
};
diff --git
a/src/output/charts/plot-chart.h
b/src/output/charts/plot-chart.h
index 59d385bb569b6c433a30a19569ec1e451717bcb0..e425987b9a5f66f1c5bd8d5327fda31e6909f43d 100644
(file)
--- a/
src/output/charts/plot-chart.h
+++ b/
src/output/charts/plot-chart.h
@@
-14,6
+14,9
@@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
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 <stdio.h>
#include <stdarg.h>
#include <string.h>
@@
-25,19
+28,15
@@
#include <math/chart-geometry.h>
#include <output/chart.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 <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
#define N_CHART_COLOURS 9
-extern const
char *const
data_colour[];
+extern const
struct chart_colour
data_colour[];
enum tick_orientation
{
enum tick_orientation
{
diff --git
a/src/output/charts/plot-hist.c
b/src/output/charts/plot-hist.c
index d647dd71fe15d1daead0d2935701c60a731f7b68..0e52889f0c7a95df5968e92a55c86dfea8819361 100644
(file)
--- a/
src/output/charts/plot-hist.c
+++ b/
src/output/charts/plot-hist.c
@@
-96,7
+96,10
@@
hist_draw_bar (plPlotter *lp, const struct chart_geometry *geom,
pl_savestate_r (lp);
pl_move_r (lp,geom->data_left, geom->data_bottom);
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);
pl_filltype_r (lp,1);