From e7771be15707376a54879737c0a940077daf31c5 Mon Sep 17 00:00:00 2001 From: kojima Date: Sun, 21 May 2000 15:33:27 +0000 Subject: [PATCH] added interwoven gradient --- wrlib/context.c | 1 - wrlib/gradient.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- wrlib/view.c | 4 +-- wrlib/wraster.h | 8 +++-- 4 files changed, 97 insertions(+), 7 deletions(-) diff --git a/wrlib/context.c b/wrlib/context.c index 657ebe01..d58882b0 100644 --- a/wrlib/context.c +++ b/wrlib/context.c @@ -560,7 +560,6 @@ getColormap(RContext *context, int screen_number) &cmaps, &ncmaps, XA_RGB_DEFAULT_MAP)) { for (i=0; ivisual->visualid) { - puts("ACHOU"); cmap = cmaps[i].colormap; break; } diff --git a/wrlib/gradient.c b/wrlib/gradient.c index dd7c2cd4..2232f2f4 100644 --- a/wrlib/gradient.c +++ b/wrlib/gradient.c @@ -478,10 +478,97 @@ renderMDGradient(unsigned width, unsigned height, RColor **colors, int count) width = width * 3; /* copy the first line to the other lines with corresponding offset */ - for (j=0, offset=0; jdata[j]), &ptr[3*(int)offset], width); + for (offset=0; jdata[0]), &ptr[3*(int)offset], width); offset += a; } RDestroyImage(tmp); return image; } + + + + +RImage *RRenderInterwovenGradient(unsigned width, unsigned height, + RColor colors1[2], int thickness1, + RColor colors2[2], int thickness2) +{ + int i, j, k, l, ll; + unsigned long r1, g1, b1, dr1, dg1, db1; + unsigned long r2, g2, b2, dr2, dg2, db2; + RImage *image; + unsigned char *ptr; + unsigned char rr, gg, bb; + + image = RCreateImage(width, height, False); + if (!image) { + return NULL; + } + ptr = image->data; + + r1 = colors1[0].red<<16; + g1 = colors1[0].green<<16; + b1 = colors1[0].blue<<16; + + r2 = colors2[0].red<<16; + g2 = colors2[0].green<<16; + b2 = colors2[0].blue<<16; + + dr1 = ((colors1[1].red-colors1[0].red)<<16)/(int)height; + dg1 = ((colors1[1].green-colors1[0].green)<<16)/(int)height; + db1 = ((colors1[1].blue-colors1[0].blue)<<16)/(int)height; + + dr2 = ((colors2[1].red-colors2[0].red)<<16)/(int)height; + dg2 = ((colors2[1].green-colors2[0].green)<<16)/(int)height; + db2 = ((colors2[1].blue-colors2[0].blue)<<16)/(int)height; + + for (i=0,k=0,l=0,ll=thickness1; i>16; + gg = g1>>16; + bb = b1>>16; + } else { + rr = r2>>16; + gg = g2>>16; + bb = b2>>16; + } + for (j=0; j 2) { img = RScaleImage(img, img->width*atof(argv[2]), img->height*atof(argv[2])); @@ -64,7 +64,7 @@ int main(int argc, char **argv) RCombineArea(tmp, img, 0, 0, 20, 20, 10, 10); img = tmp; } - +#endif if (!RConvertImage(ctx, img, &pix)) { puts(RMessageForError(RErrorCode)); diff --git a/wrlib/wraster.h b/wrlib/wraster.h index 4e398631..7933ea60 100644 --- a/wrlib/wraster.h +++ b/wrlib/wraster.h @@ -39,8 +39,8 @@ #define RLRASTER_H_ -/* version of the header for the library: 0.20 */ -#define WRASTER_HEADER_VERSION 20 +/* version of the header for the library: 0.21 */ +#define WRASTER_HEADER_VERSION 21 #include @@ -418,6 +418,10 @@ RImage *RRenderMultiGradient(unsigned width, unsigned height, RColor **colors, int style); +RImage *RRenderInterwovenGradient(unsigned width, unsigned height, + RColor colors1[2], int thickness1, + RColor colors2[2], int thickness2); + /* * Convertion into X Pixmaps -- 2.11.4.GIT