• 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: NSAffineTransform scaleBy not scaling
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSAffineTransform scaleBy not scaling


  • Subject: Re: NSAffineTransform scaleBy not scaling
  • From: Shane <email@hidden>
  • Date: Mon, 30 Nov 2009 22:21:31 -0600

> But the order of operations you apply to the transform is the reverse of what you might think will happen. One way to simplify the maths slightly is to generate the graph path using a fixed reference bounds of 1 x 1, located at the origin. Then you can directly use your view's size and position to scale and translate.
>

I've got it down to this which actually does what I want, even when I
resize the window, with the exception that it's also scaling the
stroke path, which I don't want. I'm trying to keep the stroke path
the same size, even thought I resize and scale the entire NSBezierPath
to the view size. Having a little trouble figuring out how to do this.

- (void) drawRect:(NSRect) rect
{
	float realBoundFactor = 0.9;

	NSRect bounds = [self bounds];

	float xFactor = (bounds.size.width * realBoundFactor) / (pointCount);
	float yFactor = (bounds.size.width * realBoundFactor) / (pointCount);

	[[NSColor blackColor] setFill];
	[NSBezierPath fillRect:bounds];

	NSAffineTransform *newTransform = [NSAffineTransform transform];
	[newTransform translateXBy:20.0 yBy:20.0];
	[newTransform scaleXBy:xFactor yBy:yFactor];
	[newTransform concat];

	[self drawAxes:rect];
	[self drawError:rect];

	return;
}
_______________________________________________

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:
    • Re: NSAffineTransform scaleBy not scaling
      • From: Graham Cox <email@hidden>
    • Re: NSAffineTransform scaleBy not scaling
      • From: Shane <email@hidden>
References: 
 >NSAffineTransform scaleBy not scaling (From: Shane <email@hidden>)
 >Re: NSAffineTransform scaleBy not scaling (From: Graham Cox <email@hidden>)

  • Prev by Date: What to subclass in NSArrayController to enable immediate editing of added rows?
  • Next by Date: Re: NSAffineTransform scaleBy not scaling
  • Previous by thread: Re: NSAffineTransform scaleBy not scaling
  • Next by thread: Re: NSAffineTransform scaleBy not scaling
  • Index(es):
    • Date
    • Thread