Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

drawing NSImage tiles

how do i draw an NSImage into a view in a manner that it is tiled in a single line (there are no incomplete images drawn, and assuming that the image height is equal to the view's height)?

like image 638
earl Avatar asked Feb 11 '26 08:02

earl


1 Answers

If the image was the same size as the view, you wouldn't need to tile, so I don't quite understand.

However, take a look at NSDrawThreePartImage. On 10.6 you can pass nil for the caps if all you want is a single image tiled either horizontally or vertically.

The other option is to use something along the lines of

[[NSColor colorWithPatternImage:] set];
NSRectFill(rectToBeTiled);

but the phase and scale may not be what you want if you do it this way. Colors draw in what CG calls 'base space' which is kind of like drawing in the coordinate system of the window's content view. So basically, use NSDrawThreePartImage if you can.

like image 158
Ken Avatar answered Feb 14 '26 18:02

Ken



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!