NSColor colorWithPatternImage: texture origin?
NSColor colorWithPatternImage: texture origin?
- Subject: NSColor colorWithPatternImage: texture origin?
- From: Eric Freeman <email@hidden>
- Date: Sat, 25 Oct 2003 17:39:25 -0700
Bumping up a very old question here (see below): I've seen a few post
asking how to control the origin of a color created with [NSColor
colorWithPatternImage:]. In my case I'm using this as a cell highlight
color in an attempt to replicate the blue gradients that iTunes' uses
for selections. As everyone else has found, the origin of the pattern
is always relative to the window, not the cell.
After a couple years since this original question was posted, has
anyone solved this in Cocoa?
Thanks,
Eric
FROM: Tom_waters
DATE: 2002-01-22 03:16
I am using [NSColor colorWithPatternImage:] to fill areas with a
textured pattern loaded from an image.
I am finding that no matter where I draw the rectangle, the color
pattern origin seems attached to the window origin.
I would like to make the pattern be relative to my rectangle's origin.
I've tried creating transformation matrices to translate to the origin
of my rectangles before i set the patterned color with no effect.
- (void)fill:(NSRect)r color:(NSColor *)texture
{
NSAffineTransform *ctm = [NSAffineTransform transform];
[[NSGraphicsContext currentContext] saveGraphicsState];
[ctm translateXBy:r.origin.x yBy:r.origin.y];
[ctm concat];
[texture set];
NSRectFill(NSMakeRect(0,0,r.size.width,r.size.height));
[[NSGraphicsContext currentContext] restoreGraphicsState];
}
Even more confusing is when the y origin of the pattern seems to reset
every 8 scanlines... making a rectangle's pattern seem to "jump" every
time the rectangle moves up or down 8 pixels.
Does anyone have any experience making textures start where you want
them? This seems to work for drawing the Aqua stripes in cocoa apps, so
it must be possible.
Thank you.
-tw
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.