void c_plscmap1l(PLINT itype, PLINT npts, PLFLT *pos, PLFLT *coord1, PLFLT *coord2, PLFLT *coord3, PLINT *rev) { int n; PLFLT h, l, s, r, g, b; if (npts < 2) { plabort("plscmap1l: Must specify at least two control points"); return; } if ( (pos[0] != 0) || (pos[npts-1] != 1)) { plabort("plscmap1l: First, last control points must lie on boundary"); return; } if ( npts > PL_MAX_CMAP1CP ) { plabort("plscmap1l: exceeded maximum number of control points"); return; } /* Allocate if not done yet */ if (plsc->cmap1 == NULL) plscmap1n(0); /* Save control points */ plsc->ncp1 = npts; for (n = 0; n < npts; n++) { if (itype == 0) { h = coord1[n]; l = coord2[n]; s = coord3[n]; } else { r = coord1[n]; g = coord2[n]; b = coord3[n]; c_plrgbhls(r, g, b, &h, &l, &s); } plsc->cmap1cp[n].h = h; plsc->cmap1cp[n].l = l; plsc->cmap1cp[n].s = s; plsc->cmap1cp[n].p = pos[n]; if (rev == NULL) plsc->cmap1cp[n].rev = 0; else plsc->cmap1cp[n].rev = rev[n]; } /* Calculate and set color map */ plcmap1_calc(); }
MZ_DLLEXPORT void c_plscmap1n(PLINT ncol1) { int ncol, size; /* No change */ if (ncol1 > 0 && plsc->ncol1 == ncol1) return; /* Handle all possible startup conditions */ if (plsc->ncol1 <= 0 && ncol1 <= 0) ncol = 128; else if (ncol1 <= 0) ncol = plsc->ncol1; else ncol = ncol1; size = ncol * sizeof(PLColor); /* Allocate the space */ if (plsc->ncol1 > 0) plsc->cmap1 = (PLColor *) realloc(plsc->cmap1, size); else plsc->cmap1 = (PLColor *) calloc(ncol, sizeof(PLColor)); /* Fill in default entries */ plsc->ncol1 = ncol; if (plsc->ncp1 == 0) plcmap1_def(); else plcmap1_calc(); }