gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Color handling implemented in GSGState


From: Alexander Malmberg
Subject: Re: Color handling implemented in GSGState
Date: Sun, 12 May 2002 15:06:58 +0200

> I implemented color handling in GSGState, so now subclasses don't need
> to do this. If a subclass wants to be notified of a color change, it can
> implement -setColor:(device_colort_t)color state: (color_state_t)state,

I've updated backart as well, and it seems to mostly work. I've attached
a patch that fixed two small issues:

1. sets the initial alpha to 1.0.
2. calls setColor:state: when the alpha changes. (When I tried to use
this I calculated ready-to-use values in setColor:..., ie.
red/green/blue/alpha 0-255, and this didn't work properly with alpha
changes. If I need to change this to calculate usable values later (ie.
in each function that needs the colors) I could do that, but I think
this is cleaner.)

There seems to be a few problems with color conversions and out-of-range
inputs to the color functions; I'll probably send a patch for that soon.

Since GSGState is keeping track of a bunch of state now, shouldn't it
have an implemented DPSinitgraphics that resets them? Having code to
reset the ctm, path and color in every other backend seems like a bad
idea.

- Alexander Malmberg
Index: back/Source/gsc/GSGState.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/back/Source/gsc/GSGState.m,v
retrieving revision 1.4
diff -u -r1.4 GSGState.m
--- back/Source/gsc/GSGState.m  10 May 2002 15:06:17 -0000      1.4
+++ back/Source/gsc/GSGState.m  12 May 2002 12:21:10 -0000
@@ -83,7 +83,9 @@
   fillColorS   = nil;
   strokeColorS = nil;
   fillColor    = gsMakeColor(gray_colorspace, 0, 0, 0, 0);
+  fillColor.field[AINDEX] = 1.0;
   strokeColor    = gsMakeColor(gray_colorspace, 0, 0, 0, 0);
+  strokeColor.field[AINDEX] = 1.0;
 
   charSpacing = 0;
   textMode    = GSTextFill;
@@ -239,10 +241,8 @@
 - (void) DPSsetalpha: (float)a
 {
   fillColor.field[AINDEX] = strokeColor.field[AINDEX] = a;
-  /* Is this necessary?
   [self setColor: fillColor state: COLOR_FILL];
   [self setColor: strokeColor state: COLOR_STROKE];
-  */
 }
 
 - (void) DPSsetcmykcolor: (float)c : (float)m : (float)y : (float)k

reply via email to

[Prev in Thread] Current Thread [Next in Thread]