forked from kornelski/ImageAlpha
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIABackgroundRenderer.py
More file actions
30 lines (24 loc) · 834 Bytes
/
IABackgroundRenderer.py
File metadata and controls
30 lines (24 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#
# IABackgroundRenderer.py
from objc import *
from Foundation import *
from AppKit import *
from IAImageView import IAImageView
from math import floor, ceil
from Quartz.CoreGraphics import *
from Quartz.QuartzCore import *
IAColorBackgroundRenderer = NSClassFromString("IAColorBackgroundRenderer");
class IAImageBackgroundRenderer(NSClassFromString("IAPatternBackgroundRenderer")):
backgroundOffset = (0,0)
def initWithImage_(self,image):
self = super(IAImageBackgroundRenderer, self).init();
if self:
self.setTileImage_(image);
self.moveBy_((0,0));
return self;
def canMove(self):
return YES
def moveBy_(self,delta):
self.backgroundOffset = ((self.backgroundOffset[0] + delta[0]),
(self.backgroundOffset[1] + delta[1]))
self.tileLayerAtX_Y_(self.backgroundOffset[0],self.backgroundOffset[1]);