Panda3D
Public Member Functions | List of all members
PNMPainter Class Reference

This class provides a number of convenient methods for painting drawings directly into a PNMImage. More...

#include "pnmPainter.h"

Public Member Functions

 PNMPainter (PNMImage &image, int xo=0, int yo=0)
 The constructor stores a pointer to the PNMImage you pass it, but it does not take ownership of the object; you are responsible for ensuring that the PNMImage does not destruct during the lifetime of the PNMPainter object. More...
 
void draw_line (float xa, float ya, float xb, float yb)
 Draws an antialiased line on the PNMImage, using the current pen. More...
 
void draw_point (float x, float y)
 Draws an antialiased point on the PNMImage, using the current pen. More...
 
void draw_rectangle (float xa, float ya, float xb, float yb)
 Draws a filled rectangule on the PNMImage, using the current pen for the outline, and the current fill brush for the interior. More...
 
PNMBrushget_fill () const
 Returns the current fill brush. More...
 
PNMBrushget_pen () const
 Returns the current pen. More...
 
void set_fill (PNMBrush *fill)
 Specifies a PNMBrush that will be used for filling in the interiors of objects. More...
 
void set_pen (PNMBrush *pen)
 Specifies a PNMBrush that will be used for drawing lines and edges. More...
 

Detailed Description

This class provides a number of convenient methods for painting drawings directly into a PNMImage.

It stores a pointer to the PNMImage you pass it, but it does not take ownership of the object; you are responsible for ensuring that the PNMImage does not destruct during the lifetime of the PNMPainter object.

Definition at line 34 of file pnmPainter.h.

Constructor & Destructor Documentation

◆ PNMPainter()

PNMPainter::PNMPainter ( PNMImage image,
int  xo = 0,
int  yo = 0 
)

The constructor stores a pointer to the PNMImage you pass it, but it does not take ownership of the object; you are responsible for ensuring that the PNMImage does not destruct during the lifetime of the PNMPainter object.

The xo, yo coordinates specify an optional offset for fill coordinates. If you are painting with a pattern fill, these specify the virtual coordinates of the upper-left corner of the image, which can allow you to adjust the pattern to line up with nested images, if necessary.

Definition at line 34 of file pnmPainter.cxx.

References draw_line().

Member Function Documentation

◆ draw_line()

void PNMPainter::draw_line ( float  xa,
float  ya,
float  xb,
float  yb 
)

Draws an antialiased line on the PNMImage, using the current pen.

Definition at line 49 of file pnmPainter.cxx.

References draw_rectangle().

Referenced by draw_point(), draw_rectangle(), and PNMPainter().

◆ draw_point()

void PNMPainter::draw_point ( float  x,
float  y 
)
inline

Draws an antialiased point on the PNMImage, using the current pen.

Definition at line 85 of file pnmPainter.I.

References draw_line().

Referenced by get_fill().

◆ draw_rectangle()

void PNMPainter::draw_rectangle ( float  xa,
float  ya,
float  xb,
float  yb 
)

Draws a filled rectangule on the PNMImage, using the current pen for the outline, and the current fill brush for the interior.

The two coordinates specify any two diagonally opposite corners.

Definition at line 157 of file pnmPainter.cxx.

References draw_line().

Referenced by draw_line().

◆ get_fill()

PNMBrush * PNMPainter::get_fill ( ) const
inline

Returns the current fill brush.

See set_fill().

Definition at line 74 of file pnmPainter.I.

References draw_point().

Referenced by set_fill().

◆ get_pen()

PNMBrush * PNMPainter::get_pen ( ) const
inline

Returns the current pen.

See set_pen().

Definition at line 47 of file pnmPainter.I.

References set_fill().

Referenced by set_pen().

◆ set_fill()

void PNMPainter::set_fill ( PNMBrush fill)
inline

Specifies a PNMBrush that will be used for filling in the interiors of objects.

If the brush is a bitmap brush, its image will be tiled throughout the space.

Unlike the PNMImage passed to the constructor, the PNMPainter will take ownership of the fill brush. It is not necessary to keep a separate pointer to it.

Definition at line 64 of file pnmPainter.I.

References get_fill().

Referenced by get_pen().

◆ set_pen()

void PNMPainter::set_pen ( PNMBrush pen)
inline

Specifies a PNMBrush that will be used for drawing lines and edges.

If the brush is a bitmap brush, its image will be smeared pixelwise along the line.

Unlike the PNMImage passed to the constructor, the PNMPainter will take ownership of the pen. It is not necessary to keep a separate pointer to it.

Definition at line 37 of file pnmPainter.I.

References get_pen().


The documentation for this class was generated from the following files: