/* Makes mapping from real 3D coordinates, passed as coords array, to 2D terminal coordinates, then draws filled polygon */ void filled_polygon_common(int points, struct coordinate GPHUGE * coords, TBOOLEAN fixed, double z) { int i; double x, y; gpiPoint *icorners; icorners = gp_alloc(points * sizeof(gpiPoint), "filled_polygon3d corners"); for (i = 0; i < points; i++) { if (fixed) z = coords[i].z; map3d_xy_double(coords[i].x, coords[i].y, z, &x, &y); icorners[i].x = x; icorners[i].y = y; } #ifdef EXTENDED_COLOR_SPECS if ((term->flags & TERM_EXTENDED_COLOR)) { icorners[0].spec.gray = -1; /* force solid color */ } #endif if (default_fillstyle.fillstyle == FS_EMPTY) icorners->style = FS_OPAQUE; else icorners->style = style_from_fill(&default_fillstyle); term->filled_polygon(points, icorners); free(icorners); }
void ifilled_quadrangle(gpiPoint* icorners) { if (default_fillstyle.fillstyle == FS_EMPTY) icorners->style = FS_OPAQUE; else icorners->style = style_from_fill(&default_fillstyle); term->filled_polygon(4, icorners); if (pm3d.hidden3d_tag) { int i; apply_pm3dcolor(&pm3d_border_lp.pm3d_color, term); term->move(icorners[0].x, icorners[0].y); for (i = 3; i >= 0; i--) { term->vector(icorners[i].x, icorners[i].y); } } }
void ifilled_quadrangle(gpiPoint* icorners) { if (default_fillstyle.fillstyle == FS_EMPTY) icorners->style = FS_OPAQUE; else icorners->style = style_from_fill(&default_fillstyle); term->filled_polygon(4, icorners); if (pm3d.border.l_type != LT_NODRAW) { int i; /* It should be sufficient to set only the color, but for some */ /* reason this causes the svg terminal to lose the fill type. */ term_apply_lp_properties(&pm3d_border_lp); term->move(icorners[0].x, icorners[0].y); for (i = 3; i >= 0; i--) { term->vector(icorners[i].x, icorners[i].y); } } }
/* Makes mapping from real 3D coordinates, passed as coords array, but at z coordinate fixed (base_z, for instance) to 2D terminal coordinates, then draws filled polygon */ void filled_polygon_3dcoords_zfixed(int points, struct coordinate GPHUGE * coords, double z) { int i; double x, y; gpiPoint *icorners; icorners = gp_alloc(points * sizeof(gpiPoint), "filled_polygon_zfix corners"); for (i = 0; i < points; i++) { map3d_xy_double(coords[i].x, coords[i].y, z, &x, &y); icorners[i].x = x; icorners[i].y = y; } #ifdef EXTENDED_COLOR_SPECS if (supply_extended_color_specs) { icorners[0].spec.gray = -1; /* force solid color */ } #endif if (default_fillstyle.fillstyle == FS_EMPTY) icorners->style = FS_OPAQUE; else icorners->style = style_from_fill(&default_fillstyle); term->filled_polygon(points, icorners); free(icorners); }
/* plot a colour smooth box bounded by the terminal's integer coordinates [x_from,y_from] to [x_to,y_to]. This routine is for non-postscript files, as it does an explicit loop over all thin rectangles */ static void draw_inside_color_smooth_box_bitmap(FILE * out) { int steps = 128; /* I think that nobody can distinguish more colours drawn in the palette */ int i, j, xy, xy2, xy_from, xy_to; int jmin = 0; double xy_step, gray, range; gpiPoint corners[4]; (void) out; /* to avoid "unused parameter" warning */ if (color_box.rotation == 'v') { corners[0].x = corners[3].x = color_box.bounds.xleft; corners[1].x = corners[2].x = color_box.bounds.xright; xy_from = color_box.bounds.ybot; xy_to = color_box.bounds.ytop; xy_step = (color_box.bounds.ytop - color_box.bounds.ybot) / (double)steps; } else { corners[0].y = corners[1].y = color_box.bounds.ybot; corners[2].y = corners[3].y = color_box.bounds.ytop; xy_from = color_box.bounds.xleft; xy_to = color_box.bounds.xright; xy_step = (color_box.bounds.xright - color_box.bounds.xleft) / (double)steps; } range = (xy_to - xy_from); for (i = 0, xy2 = xy_from; i < steps; i++) { /* Start from one pixel beyond the previous box */ xy = xy2; xy2 = xy_from + (int) (xy_step * (i + 1)); /* Set the colour for the next range increment */ /* FIXME - The "1 +" seems wrong, yet it improves the placement in gd */ gray = (double)(1 + xy - xy_from) / range; if (sm_palette.positive == SMPAL_NEGATIVE) gray = 1 - gray; set_color(gray); /* If this is a defined palette, make sure that the range increment */ /* does not straddle a palette segment boundary. If it does, split */ /* it into two parts. */ if (sm_palette.colorMode == SMPAL_COLOR_MODE_GRADIENT) for (j=jmin; j<sm_palette.gradient_num; j++) { int boundary = xy_from + (int)(sm_palette.gradient[j].pos * range); if (xy >= boundary) { jmin = j; } else { if (xy2 > boundary) { xy2 = boundary; i--; break; } } if (xy2 < boundary) break; } if (color_box.rotation == 'v') { corners[0].y = corners[1].y = xy; corners[2].y = corners[3].y = GPMIN(xy_to,xy2+1); } else { corners[0].x = corners[3].x = xy; corners[1].x = corners[2].x = GPMIN(xy_to,xy2+1); } #ifdef EXTENDED_COLOR_SPECS if (supply_extended_color_specs) corners[0].spec.gray = -1; /* force solid color */ #endif /* print the rectangle with the given colour */ if (default_fillstyle.fillstyle == FS_EMPTY) corners->style = FS_OPAQUE; else corners->style = style_from_fill(&default_fillstyle); term->filled_polygon(4, corners); } }