File:Text plain.png

Don't mind the mess!

We're currently in the process of migrating the Panda3D Manual to a new service. This is a temporary layout in the meantime.

Top
Python C++
Text_plain.png(375 × 37 pixels, file size: 3 KB, MIME type: image/png)

The following program was used to generate this texture image (as well as all of the other text samples on this page):

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.1)

text.setText("Every day in every way I'm getting better and better.")
saveImage('Text_plain')

cmr12 = loader.loadFont('cmr12.egg')
text.setFont(cmr12)
textNodePath.setScale(0.085)
saveImage('Text_font')
text.setFont(text.getDefaultFont())
textNodePath.setScale(0.1)

text.setSmallCaps(1)
textNodePath.setScale(0.09)
saveImage('Text_smallcaps')

text.setSmallCapsScale(0.4)
saveImage('Text_smallcaps_scale')
text.setSmallCaps(0)
textNodePath.setScale(0.1)

text.setSlant(0.3)
saveImage('Text_slant')
text.setSlant(0)

text.setTextColor(1, 0.5, 0.5, 1)
saveImage('Text_color', color = 1)

text.setShadow(0.05, 0.05)
text.setShadowColor(0, 0, 0, 1)
saveImage('Text_shadow', color = 1)
text.clearShadow()
text.setTextColor(0, 0, 0, 1)

wp.setSize(200 * renderFactor, 50 * renderFactor)
base.win.requestProperties(wp)
base.aspect2d.setScale(250./200., 1.0, 250./50.)
base.graphicsEngine.openWindows()

textNodePath.setPos(-0.75, 0, 0.04)
text.setWordwrap(15)
saveImage('Text_wordwrap')

text.setAlign(TextNode.ACenter)
textNodePath.setX(0)
saveImage('Text_align')

text.setFrameColor(0, 0, 1, 1)
text.setFrameAsMargin(0.2, 0.2, 0.1, 0.1)
text.setFrameLineWidth(renderFactor)
text.setFrameCorners(1)
saveImage('Text_frame', color = 1)

text.setCardColor(1, 1, 0.5, 1)
text.setCardAsMargin(0, 0, 0, 0)
saveImage('Text_card', color = 1)

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current11:11, 11 May 2005Thumbnail for version as of 11:11, 11 May 2005375 × 37 (3 KB)Drwr (Talk | contribs)TextNode initial example

The following page links to this file:

Top