MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / PSL_setcolor

Function PSL_setcolor

src/postscriptlight.c:4960–4986  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4958}
4959
4960int PSL_setcolor (struct PSL_CTRL *PSL, double rgb[], int mode) {
4961 /* Set the pen (PSL_IS_STROKE) color or fill (PSL_IS_FILL) color or pattern
4962 * rgb[0] = -3: set pattern, rgb[1] is pattern number setup by PSL_setpattern
4963 * rgb[0] = -2: ignore. Do not change pen color. Leave untouched.
4964 * rgb[0] = -1: ignore. Do not change pen color. Leave untouched.
4965 * rgb[0] >= 0: rgb is the color with R G B in 0-1 range.
4966 */
4967 if (!rgb) return (PSL_NO_ERROR); /* NULL args to be ignored */
4968 if (mode == PSL_IS_FONT) { /* Internally update font color but set stroke color */
4969 PSL_rgb_copy (PSL->current.rgb[mode], rgb);
4970 mode = PSL_IS_STROKE;
4971 }
4972 if (PSL_eq (rgb[0], -2.0) || PSL_eq (rgb[0], -1.0)) return (PSL_NO_ERROR); /* Settings to be ignored */
4973 if (PSL_same_rgb (rgb, PSL->current.rgb[mode])) return (PSL_NO_ERROR); /* Same color as already set */
4974
4975 /* Because psl_putcolor does not set transparency if it is 0%, we reset it here when needed */
4976 if (PSL_eq (rgb[3], 0.0) && !PSL_eq (PSL->current.rgb[mode][3], 0.0))
4977 PSL_command (PSL, "%.12g %.12g /Normal PSL_transp ", PSL->init.transparencies[PSL_FILL_TRANSP], PSL->init.transparencies[PSL_PEN_TRANSP]);
4978
4979 /* Then, finally, set the color using psl_putcolor */
4980 PSL_command (PSL, "%s\n", psl_putcolor (PSL, rgb, 0));
4981
4982 /* Update the current stroke/fill color information */
4983
4984 PSL_rgb_copy (PSL->current.rgb[mode], rgb);
4985 return (PSL_NO_ERROR);
4986}
4987
4988int PSL_setrgb (struct PSL_CTRL *PSL, double rgb[]) {
4989 /* Set the fill (PSL_IS_FILL) r/g/b color

Callers 15

gmtplot_map_boundaryFunction · 0.85
gmt_map_basemapFunction · 0.85
gmt_setfontFunction · 0.85
gmt_draw_map_panelFunction · 0.85
gmt_setpenFunction · 0.85
gmt_draw_custom_symbolFunction · 0.85

Calls 2

PSL_commandFunction · 0.85
psl_putcolorFunction · 0.85

Tested by

no test coverage detected