• 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
Pattern colors and alpha
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pattern colors and alpha


  • Subject: Pattern colors and alpha
  • From: Luke Evans <email@hidden>
  • Date: Sun, 13 Jan 2008 15:12:48 -0800

I'm trying to create a hatch pattern to be drawn over some other graphics in a custom view.

Researching how to draw hatches (at least in Cocoa, not the underlying Quartz 2D), suggested that the way to go was to create an appropriate image and then use NSColor's colorWithPatternImage: to generate a color that can be use to fill out the required area e.g. with NSRectFill.

In my code, I draw the background, and some other objects, then I do the NSRectFill having set this color. Indeed, the result is that my hatch appears in the correct place, but unfortunately the bits between the black bars of the hatch (which I'd left fully transparent in my source image driving the color) renders as completely transparent through the window. Stuff that is beneath the window (i.e. other applications and the desktop) show right through.

Now, I've experimented a bit with different compositing modes in the active NSGraphicsContext, but the NSRectFill with the pattern color seems to completely ignore this (in contrast to other drawing that I can see is respecting the asserted composition mode).

Could it be that pattern colors NEVER respect the composition mode? If so, how is one supposed to draw a hatch over other graphics? Presumably one could simply render the pattern image over the graphics (I know that will work), but AFAIK this would mean doing any tiling myself, which is the whole point of a pattern IMHO. Another option might be to use the color to paint into an image (getting the alpha there), then painting the appropriately sized image over the rest off my graphics - this offends my developer's sense of frugality.

Anyway, there's every chance I'm just being dumb - which is easily overcome by somebody telling me my glaring oversight and I'll be on my way ;-)

-- Lwe




_______________________________________________


Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • [RESOLVED] Re: Pattern colors and alpha
      • From: Luke Evans <email@hidden>
  • Prev by Date: Re: Trying to use NSStream -another question
  • Next by Date: [RESOLVED] Re: Curious about copyWithZone message from NSArrayController in "GC required" project
  • Previous by thread: Re: Crash in lockFocus?
  • Next by thread: [RESOLVED] Re: Pattern colors and alpha
  • Index(es):
    • Date
    • Thread