static void set_source_rgba(struct graphics_context *gc, double r, double g, double b, double a)
{
+ /*
+ * For printers, we still honor 'a', but ignore colors
+ * for now. Black is white and white is black
+ */
if (gc->printer) {
- /* Black is white and white is black */
double sum = r+g+b;
- if (sum > 2)
+ if (sum > 0.8)
r = g = b = 0;
- else if (sum < 1)
+ else
r = g = b = 1;
}
cairo_set_source_rgba(gc->cr, r, g, b, a);
static void render_depth_sample(struct graphics_context *gc, struct plot_data *entry, const text_render_options_t *tro)
{
- int sec = entry->sec;
- depth_t depth = { entry->val };
- const char *fmt;
+ int sec = entry->sec, decimals;
double d;
- switch (output_units.length) {
- case METERS:
- d = depth.mm / 1000.0;
- fmt = "%.1f";
- break;
- case FEET:
- d = to_feet(depth);
- fmt = "%.0f";
- break;
- }
- plot_text(gc, tro, sec, depth.mm, fmt, d);
+ d = get_depth_units(entry->val, &decimals, NULL);
+
+ plot_text(gc, tro, sec, entry->val, "%.*f", decimals, d);
}
static void plot_text_samples(struct graphics_context *gc, struct plot_info *pi)
int i;
struct plot_data *entry = pi->entry;
- cairo_set_source_rgba(gc->cr, 1, 0.2, 0.2, 0.20);
+ set_source_rgba(gc, 1, 0.2, 0.2, 0.20);
move_to(gc, entry->sec, entry->smoothed);
for (i = 1; i < pi->nr; i++) {
entry++;
int i;
struct plot_data *entry = pi->entry;
- cairo_set_source_rgba(gc->cr, 1, 0.2, 1, a);
+ set_source_rgba(gc, 1, 0.2, 1, a);
move_to(gc, entry->sec, entry->min[index]->val);
for (i = 1; i < pi->nr; i++) {
entry++;
for (i = 0; i < pi->nr; i++, entry++)
line_to(gc, entry->sec, entry->val);
cairo_close_path(gc->cr);
+ if (gc->printer) {
+ set_source_rgba(gc, 1, 1, 1, 0.2);
+ cairo_fill_preserve(cr);
+ set_source_rgb(gc, 1, 1, 1);
+ cairo_stroke(cr);
+ return;
+ }
cairo_fill(gc->cr);
/* Now do it again for the velocity colors */
if (output_units.temperature == FAHRENHEIT) {
deg = to_F(temperature);
- unit = "F";
+ unit = UTF8_DEGREE "F";
} else {
deg = to_C(temperature);
- unit = "C";
+ unit = UTF8_DEGREE "C";
}
- plot_text(gc, &tro, sec, temperature.mkelvin, "%d %s", deg, unit);
+ plot_text(gc, &tro, sec, temperature.mkelvin, "%d%s", deg, unit);
}
static void plot_temperature_text(struct graphics_context *gc, struct plot_info *pi)
if (!get_cylinder_pressure_range(gc, pi))
return;
- cairo_set_source_rgba(gc->cr, 0.2, 1.0, 0.2, 0.80);
+ set_source_rgba(gc, 0.2, 1.0, 0.2, 0.80);
move_to(gc, 0, pi->maxpressure);
for (i = 1; i < pi->nr; i++) {
/* if our samples are short and we aren't too FAST*/
if (entry[0].sec - entry[-1].sec < 30 && entry->velocity < FAST) {
int past = -2;
- while (pi->entry <= entry-past && entry[0].sec - entry[past].sec < 30)
+ while (i+past > 0 && entry[0].sec - entry[past].sec < 30)
past--;
entry->velocity = velocity((entry[0].val - entry[past].val) /
(entry[0].sec - entry[past].sec));
cairo_close_path(gc->cr);
cairo_stroke(gc->cr);
+ free(pi);
}