Home    Features    Download    Screenshots    Manual    Reference    Forums    License    Contact   
 
  Panda3D Manual: Text attrib.png

Text_attrib.png (8KB, MIME type: image/png)

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)

File history

Legend: (cur) = this is the current file, (del) = delete this old version, (rev) = revert to this old version.
Click on date to see the file uploaded on that date.


The following pages link to this file:

Back to the Manual   
.
screenshot
Flight Simulator, created by Carnegie-Mellon students
screenshot
Student Recreation of "Colossus"
screenshot
Disney Pinball: real physics and cool settings