• 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
Re: NSBezierPath containsPoint is buggy?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSBezierPath containsPoint is buggy?


  • Subject: Re: NSBezierPath containsPoint is buggy?
  • From: "Brian O'Brien" <email@hidden>
  • Date: Mon, 16 Jan 2006 16:47:10 -0700

Here is the complete code...
I've attached it to an interface with a single button.
(This posting should be viewed in a proportional font like courier.

- (IBAction)doIt:(id)sender
{
	int x, y, x1, y1, x2, y2, w, h;
	NSRect r;
	NSRect pathBounds;
	NSPoint pt;

    r.origin.x = 0.0;
    r.origin.y = 0.0f;
    r.size.width = 27.577164466275352f;
    r.size.height = 36.76955262170047f;

	NSBezierPath *p = [NSBezierPath bezierPathWithOvalInRect:r];

	NSAffineTransform *a = [[NSAffineTransform alloc] init];
	[a translateXBy:-13.788582233137676f yBy:-18.384776310850235f];
	[p transformUsingAffineTransform:a];
	[a release];

	NSAffineTransform *b = [[NSAffineTransform alloc] init];
	[b rotateByRadians:-0.78539816339744828f];
	[p transformUsingAffineTransform:b];
	[b release];

	NSAffineTransform *c = [[NSAffineTransform alloc] init];
	[c translateXBy:123.0 yBy:135.0];
	[p transformUsingAffineTransform:c];
	[c release];

pathBounds = [p bounds];
printf("The paths bounding box is ((%f,%f), (%f, %f))\n", pathBounds.origin.x, pathBounds.origin.y, pathBounds.size.width, pathBounds.size.height);


	x1 = fround(pathBounds.origin.x);
	y1 = fround(pathBounds.origin.y);
	w =  fround(pathBounds.size.width);
	h =  fround(pathBounds.size.height);

x2 = x1 + w + 1;
y2 = y1 + h + 1;
printf("The paths integer bounding box is ((%d,%d), (%d,%d))\n", x1, y1, w, h);


    printf("The bounds are ((%d,%d), (%d,%d))\n", x1, y1, x2, y2);
	for (y=y1; y < y2; ++y)
	{
		for (x=x1; x < x2; ++x)
		{
			pt.x = (float)x;
			pt.y = (float)y;
			if ([p containsPoint:pt])
				printf("#");
			else
				printf("-");
		}
		printf("\n");
	}
}


The paths bounding box is ((106.913322,118.913322), (32.173363, 32.173363))
The paths integer bounding box is ((107,119), (32,32))
The bounds are ((107,119), (140,152))
-------------#-------------------
-------##########----------------
-----###############-------------
-#####################-----------
---####################----------
--#######################--------
--########################-------
-##########################------
-###########################-----
-###########################-----
-############################----
-#############################---
-#############################---
###############################--
-##############################--
-##############################--
-###############################-
--##############################-
--##############################-
--###############################
---#############################-
---#############################-
----############################-
-----###########################-
-----###########################-
------##########################-
-------########################--
--------#######################--
----------####################---
-----------##############----#---
-------------###############-----
----------------##########-------
-------------------#-------------



_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >NSBezierPath containsPoint is buggy? (From: "Brian O'Brien" <email@hidden>)

  • Prev by Date: Re: [Core Data] Improve save performance ?
  • Next by Date: Re: Ligatures - or more so not ligatures
  • Previous by thread: NSBezierPath containsPoint is buggy?
  • Next by thread: NSProtocolChecker help
  • Index(es):
    • Date
    • Thread