Permalink
Browse files

Merge pull request #162 from victsou/examples

Fix RenderExample
  • Loading branch information...
2 parents d845270 + 3e7ea35 commit 9f3232e38aeaa8846f244102463e452073e3510c Anthony Oliver committed Jul 18, 2012
View
@@ -517,6 +517,10 @@ def sprite(self,img,pos=(0,0),scale=1.0,rot=0.0,alpha=255):
alpha = an alpha value 255=opaque 0=transparent.
"""
+
+ if( not pg.display.get_init() ):
+ pg.display.init()
+
if(img.__class__.__name__=='str'):
image = pg.image.load(img, "RGB")
elif(img.__class__.__name__=='Image' ):
@@ -1,8 +1,9 @@
-#!/usr/bin/python
+#!/usr/bin/python
from SimpleCV import *
from SimpleCV.DrawingLayer import DrawingLayer
+import os
-img = Image("../sampleimages/color.jpg")
+img = Image("../../sampleimages/color.jpg")
lineL = DrawingLayer((img.width,img.height))
a = (20,20)
b = (20,100)
@@ -16,7 +17,7 @@
lineL.line(b,d,width=5)
img.addDrawingLayer(lineL)
temp = img.applyLayers()
-temp.save('../sampleimages/line.png')
+print "line: %s" % temp.save(temp=True)
img.clearLayers()
linesL = DrawingLayer((img.width,img.height))
@@ -34,7 +35,7 @@
linesL.lines(pts,antialias=True)
img.addDrawingLayer(linesL)
temp = img.applyLayers()
-temp.save('../sampleimages/lines.png')
+print "lines: %s" % temp.save(temp=True)
img.clearLayers()
rectTR = DrawingLayer((img.width,img.height))
@@ -49,7 +50,7 @@
rectTR.rectangle(tr,wh,color=Color.GREEN,filled=True)
img.addDrawingLayer(rectTR)
temp = img.applyLayers()
-temp.save('../sampleimages/rectTR.png')
+print "rectTR: %s" % temp.save(temp=True)
img.clearLayers()
rectC = DrawingLayer((img.width,img.height))
@@ -64,7 +65,7 @@
rectC.centeredRectangle(cxy,wh,color=Color.GREEN,filled=True)
img.addDrawingLayer(rectC)
temp = img.applyLayers()
-temp.save('../sampleimages/rectC.png')
+print "rectC: %s" % temp.save(temp=True)
img.clearLayers()
polyL = DrawingLayer((img.width,img.height))
@@ -83,7 +84,7 @@
polyL.polygon(pts,antialias=True,width=3,alpha=210)
img.addDrawingLayer(polyL)
temp = img.applyLayers()
-temp.save('../sampleimages/poly.png')
+print "poly: %s" % temp.save(temp=True)
img.clearLayers()
circleL = DrawingLayer((img.width,img.height))
@@ -100,7 +101,7 @@
circleL.circle(c,r,color=Color.BLUE,alpha=172)
img.addDrawingLayer(circleL)
temp = img.applyLayers()
-temp.save('../sampleimages/circle.png')
+print "circle: %s" % temp.save(temp=True)
img.clearLayers()
ellipseL = DrawingLayer((img.width,img.height))
@@ -115,7 +116,7 @@
ellipseL.ellipse(cxy,wh,color=Color.GREEN,filled=True)
img.addDrawingLayer(ellipseL)
temp = img.applyLayers()
-temp.save('../sampleimages/ellipse.png')
+print "ellipse: %s" % temp.save(temp=True)
img.clearLayers()
bez = DrawingLayer((img.width,img.height))
@@ -135,7 +136,7 @@
bez.bezier(pts,30,color=Color.GREEN, alpha=128)
img.addDrawingLayer(bez)
temp = img.applyLayers()
-temp.save('../sampleimages/bez.png')
+print "bez: %s" % temp.save(temp=True)
img.clearLayers()
words = DrawingLayer((img.width,img.height))
@@ -169,7 +170,7 @@
words.ezViewText("Can you read this better?",pos)
img.addDrawingLayer(words)
temp = img.applyLayers()
-temp.save('../sampleimages/words.png')
+print "words: %s" % temp.save(temp=True)
img.clearLayers()
#Now lets do some layer stuff
@@ -178,7 +179,7 @@
img.addDrawingLayer(bez)
img.addDrawingLayer(words)
temp = img.applyLayers([0,2,3])
-temp.save('../sampleimages/layers.png')
+print "layers: %s" % temp.save(temp=True)
img.clearLayers()
#now lets do some blanket alpha work
@@ -191,16 +192,16 @@
img.addDrawingLayer(bez)
img.addDrawingLayer(words)
temp = img.applyLayers()
-temp.save('../sampleimages/flatlayers.png')
+print "flatlayers: %s" % temp.save(temp=True)
img.clearLayers()
sprites = DrawingLayer((img.width,img.height))
-sprites.sprite("../sampleimages/logo.png",(0,0),alpha=128, rot=45,scale=1.5)
-mySprite = Image("../sampleimages/logo.png").toPygameSurface()
+sprites.sprite("../../sampleimages/logo.png",(0,0),alpha=128, rot=45,scale=1.5)
+mySprite = Image("../../sampleimages/logo.png").toPygameSurface()
sprites.sprite(mySprite,(100,100),alpha=128, rot=45,scale=1.5)
sprites.sprite(mySprite,(200,0))
sprites.sprite(mySprite,(0,200), rot=45,scale=1)
img.addDrawingLayer(sprites)
temp = img.applyLayers()
-temp.save('../sampleimages/sprites.png')
+print "sprites: %s" % temp.save(temp=True)
img.clearLayers()
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9f3232e

Please sign in to comment.