mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-22 15:31:14 +00:00
Correct stroke colour handling.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@28948 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c172ce04b1
commit
2520a756ac
3 changed files with 58 additions and 16 deletions
|
@ -1,3 +1,9 @@
|
|||
2009-11-03 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/cairo/CairoGState.m: Set the fill or stroke colour
|
||||
immediatly before the drawing.
|
||||
* Source/art/ARTGState.m (-setColor:state:): Handle stroke colour correctly.
|
||||
|
||||
2009-11-03 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/cairo/CairoGState.m (-compositeGState:...): Use the
|
||||
|
|
|
@ -52,7 +52,8 @@ draw_info_t ART_DI;
|
|||
unsigned char r,g,b;
|
||||
|
||||
[super setColor: color state: cState];
|
||||
if (cState&(COLOR_FILL|COLOR_STROKE))
|
||||
|
||||
if (cState & COLOR_FILL)
|
||||
{
|
||||
c = fillColor;
|
||||
gsColorToRGB(&c); /* TODO: check this */
|
||||
|
@ -66,20 +67,30 @@ draw_info_t ART_DI;
|
|||
if (c.field[2] < 0.0) c.field[2] = 0.0;
|
||||
b = c.field[2] * 255;
|
||||
|
||||
if (cState & COLOR_FILL)
|
||||
{
|
||||
fill_color[0] = r;
|
||||
fill_color[1] = g;
|
||||
fill_color[2] = b;
|
||||
fill_color[3] = fillColor.field[AINDEX] * 255;
|
||||
}
|
||||
if (cState & COLOR_STROKE)
|
||||
{
|
||||
stroke_color[0] = r;
|
||||
stroke_color[1] = g;
|
||||
stroke_color[2] = b;
|
||||
stroke_color[3] = strokeColor.field[AINDEX] * 255;
|
||||
}
|
||||
fill_color[0] = r;
|
||||
fill_color[1] = g;
|
||||
fill_color[2] = b;
|
||||
fill_color[3] = fillColor.field[AINDEX] * 255;
|
||||
}
|
||||
|
||||
if (cState & COLOR_STROKE)
|
||||
{
|
||||
c = strokeColor;
|
||||
gsColorToRGB(&c); /* TODO: check this */
|
||||
if (c.field[0] > 1.0) c.field[0] = 1.0;
|
||||
if (c.field[0] < 0.0) c.field[0] = 0.0;
|
||||
r = c.field[0] * 255;
|
||||
if (c.field[1] > 1.0) c.field[1] = 1.0;
|
||||
if (c.field[1] < 0.0) c.field[1] = 0.0;
|
||||
g = c.field[1] * 255;
|
||||
if (c.field[2] > 1.0) c.field[2] = 1.0;
|
||||
if (c.field[2] < 0.0) c.field[2] = 0.0;
|
||||
b = c.field[2] * 255;
|
||||
|
||||
stroke_color[0] = r;
|
||||
stroke_color[1] = g;
|
||||
stroke_color[2] = b;
|
||||
stroke_color[3] = strokeColor.field[AINDEX] * 255;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -302,6 +302,7 @@ static float floatToUserSpace(NSAffineTransform *ctm, float f)
|
|||
device_color_t c;
|
||||
|
||||
[super setColor: color state: cState];
|
||||
/*
|
||||
if (_ct == NULL)
|
||||
{
|
||||
// Window device isn't set yet
|
||||
|
@ -311,6 +312,7 @@ static float floatToUserSpace(NSAffineTransform *ctm, float f)
|
|||
gsColorToRGB(&c);
|
||||
// The underlying concept does not allow to determine if alpha is set or not.
|
||||
cairo_set_source_rgba(_ct, c.field[0], c.field[1], c.field[2], c.field[AINDEX]);
|
||||
*/
|
||||
}
|
||||
|
||||
- (void) GSSetPatterColor: (NSImage*)image
|
||||
|
@ -499,7 +501,7 @@ static float floatToUserSpace(NSAffineTransform *ctm, float f)
|
|||
cairo_set_matrix(_ct, &local_matrix);
|
||||
|
||||
// super call did go to the old _ct, so redo it
|
||||
[self setColor: &fillColor state: COLOR_BOTH];
|
||||
//[self setColor: &fillColor state: COLOR_BOTH];
|
||||
|
||||
// Cairo's default line width is 2.0
|
||||
cairo_set_line_width(_ct, 1.0);
|
||||
|
@ -811,12 +813,18 @@ static float floatToUserSpace(NSAffineTransform *ctm, float f)
|
|||
{
|
||||
if (_ct)
|
||||
{
|
||||
device_color_t c;
|
||||
|
||||
if (pattern != nil)
|
||||
{
|
||||
[self eofillPath: path withPattern: pattern];
|
||||
return;
|
||||
}
|
||||
|
||||
c = fillColor;
|
||||
gsColorToRGB(&c);
|
||||
// The underlying concept does not allow to determine if alpha is set or not.
|
||||
cairo_set_source_rgba(_ct, c.field[0], c.field[1], c.field[2], c.field[AINDEX]);
|
||||
[self _setPath:YES];
|
||||
cairo_set_fill_rule(_ct, CAIRO_FILL_RULE_EVEN_ODD);
|
||||
cairo_fill(_ct);
|
||||
|
@ -829,12 +837,18 @@ static float floatToUserSpace(NSAffineTransform *ctm, float f)
|
|||
{
|
||||
if (_ct)
|
||||
{
|
||||
device_color_t c;
|
||||
|
||||
if (pattern != nil)
|
||||
{
|
||||
[self fillPath: path withPattern: pattern];
|
||||
return;
|
||||
}
|
||||
|
||||
c = fillColor;
|
||||
gsColorToRGB(&c);
|
||||
// The underlying concept does not allow to determine if alpha is set or not.
|
||||
cairo_set_source_rgba(_ct, c.field[0], c.field[1], c.field[2], c.field[AINDEX]);
|
||||
[self _setPath:YES];
|
||||
cairo_fill(_ct);
|
||||
}
|
||||
|
@ -853,6 +867,12 @@ static float floatToUserSpace(NSAffineTransform *ctm, float f)
|
|||
{
|
||||
if (_ct)
|
||||
{
|
||||
device_color_t c;
|
||||
|
||||
c = strokeColor;
|
||||
gsColorToRGB(&c);
|
||||
// The underlying concept does not allow to determine if alpha is set or not.
|
||||
cairo_set_source_rgba(_ct, c.field[0], c.field[1], c.field[2], c.field[AINDEX]);
|
||||
[self _setPath:NO];
|
||||
cairo_stroke(_ct);
|
||||
}
|
||||
|
@ -1224,10 +1244,15 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
|
|||
if (_ct)
|
||||
{
|
||||
NSBezierPath *oldPath = path;
|
||||
device_color_t c;
|
||||
|
||||
cairo_save(_ct);
|
||||
_set_op(_ct, op);
|
||||
|
||||
c = fillColor;
|
||||
gsColorToRGB(&c);
|
||||
// The underlying concept does not allow to determine if alpha is set or not.
|
||||
cairo_set_source_rgba(_ct, c.field[0], c.field[1], c.field[2], c.field[AINDEX]);
|
||||
// This is almost a rectclip::::, but the path stays unchanged.
|
||||
path = [NSBezierPath bezierPathWithRect: aRect];
|
||||
[path transformUsingAffineTransform: ctm];
|
||||
|
|
Loading…
Reference in a new issue