28 virtual void draw(
PNMImage &,
int,
int,
float) {
31 virtual void fill(
PNMImage &,
int,
int,
int,
int,
int) {
49 virtual void draw(
PNMImage &image,
int x,
int y,
float pixel_scale) {
57 virtual void fill(
PNMImage &image,
int xfrom,
int xto,
int y,
60 xfrom = max(xfrom, 0);
62 for (
int x = xfrom; x <= xto; ++x) {
74 virtual void draw(
PNMImage &image,
int x,
int y,
float pixel_scale) {
77 image.
blend(x, y, _color[0], _color[1], _color[2], _color[3] * pixel_scale);
81 virtual void fill(
PNMImage &image,
int xfrom,
int xto,
int y,
84 xfrom = max(xfrom, 0);
86 for (
int x = xfrom; x <= xto; ++x) {
87 image.
blend(x, y, _color[0], _color[1], _color[2], _color[3]);
98 virtual void draw(
PNMImage &image,
int x,
int y,
float pixel_scale) {
102 LColorf p = (_color - 1.0f) * pixel_scale + 1.0f;
107 virtual void fill(
PNMImage &image,
int xfrom,
int xto,
int y,
110 xfrom = max(xfrom, 0);
112 for (
int x = xfrom; x <= xto; ++x) {
124 virtual void draw(
PNMImage &image,
int x,
int y,
float pixel_scale) {
128 image.
get_xel_a(x, y).fmax(_color * pixel_scale));
132 virtual void fill(
PNMImage &image,
int xfrom,
int xto,
int y,
135 xfrom = max(xfrom, 0);
137 for (
int x = xfrom; x <= xto; ++x) {
154 virtual void fill(
PNMImage &image,
int xfrom,
int xto,
int y,
157 xfrom = max(xfrom, 0);
160 int x_pat = (xfrom + xo) % _image.get_x_size();
161 int y_pat = (y + yo) % _image.get_y_size();
165 do_scanline(image, x, y, x_pat, y_pat, xto - x + 1, 1);
167 x += _image.get_x_size() - x_pat;
169 do_scanline(image, x, y, 0, y_pat, xto - x + 1, 1);
170 x += _image.get_x_size();
175 virtual void do_scanline(
PNMImage &image,
int xto,
int yto,
176 int xfrom,
int yfrom,
int x_size,
int y_size)=0;
187 virtual void draw(
PNMImage &image,
int x,
int y,
float pixel_scale) {
188 if (pixel_scale >= 0.5) {
193 virtual void do_scanline(
PNMImage &image,
int xto,
int yto,
194 int xfrom,
int yfrom,
int x_size,
int y_size) {
195 image.
copy_sub_image(_image, xto, yto, xfrom, yfrom, x_size, y_size);
205 virtual void draw(
PNMImage &image,
int x,
int y,
float pixel_scale) {
209 virtual void do_scanline(
PNMImage &image,
int xto,
int yto,
210 int xfrom,
int yfrom,
int x_size,
int y_size) {
221 virtual void draw(
PNMImage &image,
int x,
int y,
float pixel_scale) {
225 virtual void do_scanline(
PNMImage &image,
int xto,
int yto,
226 int xfrom,
int yfrom,
int x_size,
int y_size) {
237 virtual void draw(
PNMImage &image,
int x,
int y,
float pixel_scale) {
241 virtual void do_scanline(
PNMImage &image,
int xto,
int yto,
242 int xfrom,
int yfrom,
int x_size,
int y_size) {
268 make_pixel(
const LColorf &
color, PNMBrush::BrushEffect effect) {
284 <<
"**Invalid BrushEffect (" << (int)effect <<
")**\n";
293 make_spot(
const LColorf &
color,
float radius,
bool fuzzy,
294 BrushEffect effect) {
316 <<
"**Invalid BrushEffect (" << (int)effect <<
")**\n";
319 int size = (int)cceil(radius * 2.0f);
320 float half_size = (float)size * 0.5f;
322 float r = half_size / radius;
325 spot.render_spot(
color, bg, 0.0f, r);
327 spot.render_spot(
color, bg, r, r);
329 return make_image(spot, half_size, half_size, effect);
340 make_image(
const PNMImage &image,
float xc,
float yc,
341 PNMBrush::BrushEffect effect) {
357 <<
"**Invalid BrushEffect (" << (int)effect <<
")**\n";
void copy_sub_image(const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1)
Copies a rectangular area of another image into a rectangular area of this image. ...
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void blend(int x, int y, const LRGBColorf &val, float alpha)
Smoothly blends the indicated pixel value in with whatever was already in the image, based on the given alpha value.
void blend_sub_image(const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, float pixel_scale=1.0)
Behaves like copy_sub_image(), except the alpha channel of the copy is used to blend the copy into th...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
LColorf get_xel_a(int x, int y) const
Returns the RGBA color at the indicated pixel.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void lighten_sub_image(const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, float pixel_scale=1.0)
Behaves like copy_sub_image(), but the resulting color will be the lighter of the source and destinat...
PT(PNMBrush) PNMBrush
Returns a new brush that does not paint anything.
void set_xel_a(int x, int y, const LColorf &value)
Changes the RGBA color at the indicated pixel.
void darken_sub_image(const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, float pixel_scale=1.0)
Behaves like copy_sub_image(), but the resulting color will be the darker of the source and destinati...
This class is used to control the shape and color of the drawing operations performed by a PNMPainter...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.