Drawing with Quartz - overlap problems

Discussion in 'iOS Programming' started by Jokode, Jan 26, 2009.

  1. Jokode macrumors newbie

    Dec 14, 2008
    I am not new to iphone coding as I have one app out in the store, so I'm not a complete noob - however please forgive this question as it might be very silly...

    How can I prevent a partially transparent circle and a rectangle that I have drawn in quartz which overlap from 'double' drawing?

    By double drawing I mean the areas which overlap are shaded darker than the areas that dont overlap - because that area has been draw into twice. This wouldnt be a problem if everything is solid color, but I am trying to draw partially transparent and having areas that overlap go dark just makes no sense for my app!

    I really don't know a lot about drawing with a technology such as quartz as I have never really done it before - but I feel like is probably a common problem.

    Is there a function or concept in quartz that I should be using to do this?

    Any help would be very appreciated!

  2. Delirium39 macrumors regular

    May 19, 2008
    It's not double drawing. If you draw two shadows on top of each other, you get a darker shadow. Your first image is drawn on a background color. Your second image is drawn on the background color plus the first image. Adding 50% black to 50% black does not equal 50% black. Make sense?
  3. detz macrumors 65816

    Jun 29, 2007
    Transparent images will show what's behind them, that's what transparency is. I'm not sure what the issue is, if yo make the image in the front semi-transparent it will merge with the colors behind it.
  4. Jokode thread starter macrumors newbie

    Dec 14, 2008
    Thanks for the feedback - after looking over the responses and code again, I think the problem is in my approach.. I'll go back to the drawing board :)
  5. jnic macrumors 6502a

    Oct 24, 2008
    Yes; clipping.
  6. CommanderData macrumors regular

    Dec 1, 2007
    Yep, try to set a clipping area up so that you only draw the half of the circle that does *not* overlap the rectangle. Don't forget to save/restore your context's original state as well!

Share This Page