Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

CGContext path

obaidahmedobaidahmed Posts: 18New Users
edited August 2012 in iOS SDK Development
Hi, i am drawing path using CGContext, but the problem is that when i draw lines with different colors, lines with different colors overlap each other like this:image, i want to draw both of them in a single layer so it cannot overlap.
Tagged:

Replies

  • Duncan CDuncan C Posts: 9,114Tutorial Authors, Registered Users @ @ @ @ @ @ @

    Hi, i am drawing path using CGContext, but the problem is that when i draw lines with different colors, lines with different colors overlap each other like this:image, i want to draw both of them in a single layer so it cannot overlap.

    You are drawing paths using partial opacity. When you draw lines on top of each other, the old color shows through.

    What would you want it to do instead?

    If you draw your lines fully opaque then the second line drawn would cover the first.
    Regards,
    Duncan C
    WareTo

    widehead.gif
    Animated GIF created with Face Dancer, available for free in the app store.

    I'm available for one-on-one help at CodeMentor
  • obaidahmedobaidahmed Posts: 18New Users
    Hey i am doing it with CGContextSetBlendModeDarken to show the background image too.
  • obaidahmedobaidahmed Posts: 18New Users
    I used BlendModeDarken to achieve the transparency effect.
  • Duncan CDuncan C Posts: 9,114Tutorial Authors, Registered Users @ @ @ @ @ @ @

    I used BlendModeDarken to achieve the transparency effect.

    Ok, but how do you want the result to look? It's doing what it should do, based on partial transparency and using a darken blending mode.
    Regards,
    Duncan C
    WareTo

    widehead.gif
    Animated GIF created with Face Dancer, available for free in the app store.

    I'm available for one-on-one help at CodeMentor
  • obaidahmedobaidahmed Posts: 18New Users
    In the picture, you can see that where green & red lines intersects, it forms a combination of both the colors, i dont want this ... I want only the color of line
  • Duncan CDuncan C Posts: 9,114Tutorial Authors, Registered Users @ @ @ @ @ @ @

    In the picture, you can see that where green & red lines intersects, it forms a combination of both the colors, i dont want this ... I want only the color of line

    Then draw with fully opaque colors. If you use partly transparent colors, you will get some form of blending.
    Regards,
    Duncan C
    WareTo

    widehead.gif
    Animated GIF created with Face Dancer, available for free in the app store.

    I'm available for one-on-one help at CodeMentor
Sign In or Register to comment.