• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSColor colorWithPatternImage: texture origin?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSColor colorWithPatternImage: texture origin?


  • Subject: NSColor colorWithPatternImage: texture origin?
  • From: email@hidden
  • Date: Mon, 21 Jan 2002 18:16:33 -0800

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


  • Prev by Date: Re: Custom View Class
  • Next by Date: problems with Objective-C++
  • Previous by thread: Is dataWithContentsOfURL: thread-safe?
  • Next by thread: problems with Objective-C++
  • Index(es):
    • Date
    • Thread