Re: Filling View With Pattern Image
Re: Filling View With Pattern Image
- Subject: Re: Filling View With Pattern Image
- From: Florian Soenens <email@hidden>
- Date: Fri, 19 Jun 2009 10:27:30 +0200
You will have to do it programmatically but it's pretty easy stuff.
This should do the trick nicely:
-(void)drawBackgroundPattern
{
// Suppose backgroundPatternImage is a valid reference to your
pattern image
NSRect rect = [self frame];
float width = rect.size.width;
float height = rect.size.height;
float bgWidth = [backgroundPatternImage size].width;
float bgHeight = [backgroundPatternImage size].height;
float xPos = 0;
float yPos = height - bgHeight;
while(yPos >= 0 - bgHeight)
{
while (xPos < width)
{
NSRect drawRect = NSMakeRect(xPos, yPos, bgWidth, bgHeight);
[backgroundPatternImage drawInRect:drawRect fromRect:NSZeroRect
operation:NSCompositeSourceOver fraction:1.0];
xPos += bgWidth;
}
xPos = 0;
yPos -= bgHeight;
}
}
-(void)drawRect:(NSRect)aRect
{
[self drawBackgroundPattern];
}
hth,
Florian.
On 19 Jun 2009, at 10:14, Chunk 1978 wrote:
i have this image ("image.png") that i would like to tile throughout
the view...
i've read the Quartz 2D programming guide... ok, ok, i breezed thru
it, i admit... but i couldn't seem to find an easy way of repeating an
image through out a view without actually drawing the image
programatically...
_______________________________________________
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
Looking for Web-to-Print Solutions?
Visit our website : http://www.vit2print.com
This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information and/or information protected by intellectual property rights.
If you are not the intended recipient, please note that any review, dissemination, disclosure, alteration, printing, copying or transmission of this e-mail and/or any file transmitted with it, is strictly prohibited and may be unlawful.
If you have received this e-mail by mistake, please immediately notify the sender and permanently delete the original as well as any copy of any e-mail and any printout thereof.
We may monitor e-mail to and from our network.
NSS nv Tieltstraat 167 8740 Pittem Belgium
_______________________________________________
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