Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8097907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:54:36+00:00 2026-06-05T21:54:36+00:00

I have the following drawing code: [[NSColor redColor] set]; NSRect fillRect = NSMakeRect(bounds.size.width –

  • 0

I have the following drawing code:

[[NSColor redColor] set];
NSRect fillRect = NSMakeRect(bounds.size.width - 20.0f, 0.0f, 20.0f, 20.0f);
NSBezierPath *bezier1 = [NSBezierPath bezierPathWithRoundedRect:fillRect xRadius:10.0f yRadius:10.0f];

[bezier1 fill];

NSRect fill2 = fillRect;
fill2.origin.x += 5;
fill2.origin.y += 5;

fill2.size.width -= 10.0f;
fill2.size.height -= 10.0f;

NSBezierPath *bezier2 = [NSBezierPath bezierPathWithRoundedRect:fill2 xRadius:5.0f yRadius:5.0f];
[[NSColor greenColor] set];

[bezier2 fill];

Which result in this:

Screenshot

How do I reach that the inner green circle is transparent? Replacing the green NSColor with a transparent color doesn’t work, logical 😉

Is there a way to intersect instances of NSBezierPath or solve this with another approach?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:54:37+00:00Added an answer on June 5, 2026 at 9:54 pm

    I think what you’re looking for is a bezier path for a ring, you can do that by creating a single NSBezierPath and setting the winding rule:

    [[NSColor redColor] set];
    NSRect fillRect = NSMakeRect(bounds.size.width - 20.0f, 0.0f, 20.0f, 20.0f);
    NSBezierPath *bezier1 = [NSBezierPath new];
    [bezier1 setWindingRule:NSEvenOddWindingRule];   // set the winding rule for filling
    [bezier1 appendBezierPathWithRoundedRect:fillRect xRadius:10.0f yRadius:10.0f];
    
    NSRect innerRect = NSInsetRect(fillRect, 5, 5);  // the bounding rect for the hole
    [bezier1 appendBezierPathWithRoundedRect:innerRect xRadius:5.0f yRadius:5.0f];
    
    [bezier1 fill];
    

    The NSEvenOddWindingRule rule determines whether to fill a particular point by considering a line from that point to outside the overall path bounds; if that line crosses an even number of paths it is not filled, otherwise it is. So any point in the inner circle will not be filled, while points between the two will be – result a ring.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code : System.Drawing.Rectangle desktop_Rectangle = System.Windows.Forms.Screen.PrimaryScreen.Bounds which gives me the
I have a simple drawing program, I set my Jframe's size with the following
I have written the following IronPython code: import clr clr.AddReference(System.Drawing) from System import *
I have been developing the application for drawing, and there is the following code
I have the following code for drawing a circle : #include<stdio.h> #include<conio.h> #include<graphics.h> #include<math.h>
I have been developing the application for drawing. I have following code for main
I have the following paint event (form) that is drawing the rectangle: void LogicSimulationViewerForm_Paint(object
I have the following MonoTouch program: using System.Drawing; using MonoTouch.Foundation; using MonoTouch.UIKit; using System;
I am making a drawing app for iOS and I have the following classes:
i have the following code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.