def _renderImage(self, srcBmp, node, pos, size): canvas = player.createCanvas(id="stretch_canvas", size=size) img = avg.ImageNode(pos=pos, parent=canvas.getRootNode()) img.setBitmap(srcBmp) canvas.render() node.setBitmap(canvas.screenshot()) player.deleteCanvas("stretch_canvas")
def __createImage(self, node, bmp, sizeFactor): canvas = player.createCanvas(id="keycanvas", size=self.size*sizeFactor) canvasImage = avg.ImageNode(pos=-self.pos*sizeFactor, parent=canvas.getRootNode()) canvasImage.setBitmap(bmp) canvas.render() node.setBitmap(canvas.screenshot()) player.deleteCanvas('keycanvas')
def __createImage(self, node, bmp, sizeFactor): canvas = player.createCanvas(id="keycanvas", size=self.size * sizeFactor) canvasImage = avg.ImageNode(pos=-self.pos * sizeFactor, parent=canvas.getRootNode()) canvasImage.setBitmap(bmp) canvas.render() node.setBitmap(canvas.screenshot()) player.deleteCanvas('keycanvas')
def deleteCanvases(): changeHRef("") firstNode.href = "" player.deleteCanvas("testcanvas1") # self.assertException(lambda: changeHRef("canvas:testcanvas1")) changeHRef("canvas:testcanvas2") # self.assertException(lambda: player.deleteCanvas("testcanvas2")) changeHRef("") player.deleteCanvas("testcanvas2")
def testCanvasDependencies(self): def makeCircularRef(): self.offscreen1.getElementByID( "test1").href = "canvas:offscreencanvas2" def makeSelfRef1(): avg.ImageNode(href="canvas:offscreencanvas1", parent=self.offscreen1.getRootNode()) def makeSelfRef2(): self.offscreen1.getElementByID( "test1").href = "canvas:offscreencanvas1" def createTwoCanvases(): self.offscreen1 = self.__createOffscreenCanvas( "offscreencanvas1", False) self.offscreen2 = self.__createOffscreenCanvas( "offscreencanvas2", False) self.node = avg.ImageNode(parent=root, href="canvas:offscreencanvas1") node = self.offscreen1.getElementByID("test1") node.href = "canvas:offscreencanvas2" node.size = (80, 60) def exchangeCanvases(): self.offscreen1.getElementByID("test1").href = "rgb24-65x65.png" self.offscreen2.getElementByID( "test1").href = "canvas:offscreencanvas1" self.node.href = "canvas:offscreencanvas2" def loadCanvasDepString(): player.createCanvas(id="canvas1", size=(160, 120)) canvas2 = player.createCanvas(id="canvas2", size=(160, 120)) avg.ImageNode(href="canvas:canvas1", parent=canvas2.getRootNode()) player.deleteCanvas('canvas2') player.deleteCanvas('canvas1') root = self.loadEmptyScene() createTwoCanvases() self.offscreen1.getElementByID("test1").href = "" self.offscreen1 = None self.offscreen2 = None self.node.href = "" self.node = None player.deleteCanvas("offscreencanvas1") player.deleteCanvas("offscreencanvas2") self.start(False, ( createTwoCanvases, lambda: self.compareImage("testCanvasDependencies1"), exchangeCanvases, lambda: self.compareImage("testCanvasDependencies2"), lambda: self.assertRaises(avg.Exception, makeCircularRef), lambda: self.assertRaises(avg.Exception, makeSelfRef1), lambda: self.assertRaises(avg.Exception, makeSelfRef2), loadCanvasDepString, ))
def __renderImage(self, srcBmp, node, offset): if self._orientation == Orientation.HORIZONTAL: pos = (-offset,0) else: pos = (0, -offset) canvas = player.createCanvas(id="accordion_canvas", size=node.size) img = avg.ImageNode(pos=pos, parent=canvas.getRootNode()) img.setBitmap(srcBmp) canvas.render() node.setBitmap(canvas.screenshot()) player.deleteCanvas("accordion_canvas")
def testCanvasDependencies(self): def makeCircularRef(): self.offscreen1.getElementByID("test1").href = "canvas:offscreencanvas2" def makeSelfRef1(): avg.ImageNode(href="canvas:offscreencanvas1", parent=self.offscreen1.getRootNode()) def makeSelfRef2(): self.offscreen1.getElementByID("test1").href = "canvas:offscreencanvas1" def createTwoCanvases(): self.offscreen1 = self.__createOffscreenCanvas("offscreencanvas1", False) self.offscreen2 = self.__createOffscreenCanvas("offscreencanvas2", False) self.node = avg.ImageNode(parent=root, href="canvas:offscreencanvas1") node = self.offscreen1.getElementByID("test1") node.href = "canvas:offscreencanvas2" node.size = (80, 60) def exchangeCanvases(): self.offscreen1.getElementByID("test1").href = "rgb24-65x65.png" self.offscreen2.getElementByID("test1").href = "canvas:offscreencanvas1" self.node.href = "canvas:offscreencanvas2" def loadCanvasDepString(): player.createCanvas(id="canvas1", size=(160, 120)) canvas2 = player.createCanvas(id="canvas2", size=(160, 120)) avg.ImageNode(href="canvas:canvas1", parent=canvas2.getRootNode()) player.deleteCanvas('canvas2') player.deleteCanvas('canvas1') root = self.loadEmptyScene() createTwoCanvases() self.offscreen1.getElementByID("test1").href = "" self.offscreen1 = None self.offscreen2 = None self.node.href = "" self.node = None player.deleteCanvas("offscreencanvas1") player.deleteCanvas("offscreencanvas2") self.start(False, (createTwoCanvases, lambda: self.compareImage("testCanvasDependencies1"), exchangeCanvases, lambda: self.compareImage("testCanvasDependencies2"), lambda: self.assertRaises(avg.Exception, makeCircularRef), lambda: self.assertRaises(avg.Exception, makeSelfRef1), lambda: self.assertRaises(avg.Exception, makeSelfRef2), loadCanvasDepString, ))
def deleteCanvases(): changeHRef("") firstNode.href = "" player.deleteCanvas("testcanvas1") self.assertRaises(avg.Exception, lambda: changeHRef("canvas:testcanvas1")) changeHRef("canvas:testcanvas2") self.assertRaises(avg.Exception, lambda: player.deleteCanvas("testcanvas2")) changeHRef("") player.deleteCanvas("testcanvas2") self.assertRaises(avg.Exception, lambda: player.deleteCanvas("foo"))
def deleteCanvases(): changeHRef("") firstNode.href = "" player.deleteCanvas("testcanvas1") self.assertRaises(RuntimeError, lambda: changeHRef("canvas:testcanvas1")) changeHRef("canvas:testcanvas2") self.assertRaises(RuntimeError, lambda: player.deleteCanvas("testcanvas2")) changeHRef("") player.deleteCanvas("testcanvas2") self.assertRaises(RuntimeError, lambda: player.deleteCanvas("foo"))
def deleteCanvas(): img1.unlink(True) img2.unlink(True) player.deleteCanvas("canvas")
def loadCanvasDepString(): player.createCanvas(id="canvas1", size=(160, 120)) canvas2 = player.createCanvas(id="canvas2", size=(160, 120)) avg.ImageNode(href="canvas:canvas1", parent=canvas2.getRootNode()) player.deleteCanvas('canvas2') player.deleteCanvas('canvas1')
def deleteCanvas(): player.deleteCanvas("testcanvas") self.__offscreenCanvas = None