CocoaDev

Edit AllPages

I am having some trouble setting the background picture of my screensaver. I have an image (.pdf) in a known path that I want to set to the background when my screensaver starts. Also, I am guessing it is quite possible to draw on top of that with bezier paths. Correct? Thanks for your help. (XCode, 10.3). -Zac


If you are to redraw the entire background picture every frame, you will end with an ugly framerate, unless you use something faster like openGL. So if you want to animate, you’ll probably need to redraw the screen partially, every frame. If you don’t want to animate, it’s not a problem. You just draw everything you want on top of your background and the screensaver engine will do the rest. You usually execute the preliminary drawings in the drawRect: method, which is called only once, when the screensaver starts…

NSImage *myImage = [NSImage initWithContentsOfFile:@”myPath”]; [myImage compositeToPoint:NSMakePoint(x,y) operation:NSCompositeCopy]; // x and y == 0, I guess…

– Trax


Display Image in center of ScreenSaver