This image was generated with the following program:
from direct.directbase.DirectStart import *
from pandac.PandaModules import *
# How much bigger to render the images onscreen, for antialiasing?
renderFactor = 5
# How much to scale the resulting image from what I originally had in
# mind?
outputFactor = 1.5
def saveImage(basename, color = 0):
base.graphicsEngine.renderFrame()
image = PNMImage()
base.win.getScreenshot(image)
if color:
image.setColorType(PNMImage.CTColor)
else:
image.setColorType(PNMImage.CTGrayscale)
filename = Filename('%s.png' % (basename))
scale = float(outputFactor) / float(renderFactor)
if scale != 1:
reduced = PNMImage(int(image.getXSize() * scale),
int(image.getYSize() * scale),
image.getNumChannels())
reduced.gaussianFilterFrom(0.5, image)
reduced.write(filename)
else:
image.write(filename)
print "wrote %s" % (filename.getFullpath())
base.setBackgroundColor(1, 1, 1, 1)
base.setFrameRateMeter(0)
wp = WindowProperties()
wp.setSize(250 * renderFactor, 25 * renderFactor)
base.win.requestProperties(wp)
base.aspect2d.setScale(1.0, 1.0, 250./25.)
base.graphicsEngine.openWindows()
text = TextNode('node name')
textNodePath = aspect2d.attachNewNode(text)
text.setTextColor(0, 0, 0, 1)
textNodePath.setPos(-.95, 0, -0.02)
textNodePath.setScale(0.095)
tpRed = TextProperties()
tpRed.setTextColor(1, 0, 0, 1)
tpSlant = TextProperties()
tpSlant.setSlant(0.3)
tpRoman = TextProperties()
cmr12 = loader.loadFont('cmr12.egg')
tpRoman.setFont(cmr12)
tpMgr = TextPropertiesManager.getGlobalPtr()
tpMgr.setProperties("red", tpRed)
tpMgr.setProperties("slant", tpSlant)
tpMgr.setProperties("roman", tpRoman)
text.setText("Every day in \1slant\1every way\2 I'm \1red\1getting \1roman\1better \1slant\1and\2 better.\2\2")
saveImage('Text_attrib', color = 1)
|
Click on a date/time to view the file as it appeared at that time.
| Date/Time | Thumbnail | Dimensions | User | Comment |
current | 10:03, 13 January 2006 |  | 375 × 37 (8 KB) | Drwr (Talk | contribs) | |
The following page links to this file: