17 #include "config_pnmimage.h" 26 virtual void draw(
PNMImage &,
int,
int,
float) {
29 virtual void fill(
PNMImage &,
int,
int,
int,
int,
int) {
37 PNMBrush(0.5, 0.5), _color(color) { }
47 virtual void draw(
PNMImage &image,
int x,
int y,
float pixel_scale) {
55 virtual void fill(
PNMImage &image,
int xfrom,
int xto,
int y,
58 xfrom = max(xfrom, 0);
60 for (
int x = xfrom; x <= xto; ++x) {
72 virtual void draw(
PNMImage &image,
int x,
int y,
float pixel_scale) {
75 image.
blend(x, y, _color[0], _color[1], _color[2], _color[3] * pixel_scale);
79 virtual void fill(
PNMImage &image,
int xfrom,
int xto,
int y,
82 xfrom = max(xfrom, 0);
84 for (
int x = xfrom; x <= xto; ++x) {
85 image.
blend(x, y, _color[0], _color[1], _color[2], _color[3]);
96 virtual void draw(
PNMImage &image,
int x,
int y,
float pixel_scale) {
100 LColorf p = (_color - 1.0f) * pixel_scale + 1.0f;
105 virtual void fill(
PNMImage &image,
int xfrom,
int xto,
int y,
108 xfrom = max(xfrom, 0);
110 for (
int x = xfrom; x <= xto; ++x) {
122 virtual void draw(
PNMImage &image,
int x,
int y,
float pixel_scale) {
126 image.
get_xel_a(x, y).fmax(_color * pixel_scale));
130 virtual void fill(
PNMImage &image,
int xfrom,
int xto,
int y,
133 xfrom = max(xfrom, 0);
135 for (
int x = xfrom; x <= xto; ++x) {
152 virtual void fill(
PNMImage &image,
int xfrom,
int xto,
int y,
155 xfrom = max(xfrom, 0);
158 int x_pat = (xfrom + xo) % _image.get_x_size();
159 int y_pat = (y + yo) % _image.get_y_size();
163 do_scanline(image, x, y, x_pat, y_pat, xto - x + 1, 1);
165 x += _image.get_x_size() - x_pat;
167 do_scanline(image, x, y, 0, y_pat, xto - x + 1, 1);
168 x += _image.get_x_size();
173 virtual void do_scanline(
PNMImage &image,
int xto,
int yto,
174 int xfrom,
int yfrom,
int x_size,
int y_size)=0;
185 virtual void draw(
PNMImage &image,
int x,
int y,
float pixel_scale) {
186 if (pixel_scale >= 0.5) {
191 virtual void do_scanline(
PNMImage &image,
int xto,
int yto,
192 int xfrom,
int yfrom,
int x_size,
int y_size) {
193 image.
copy_sub_image(_image, xto, yto, xfrom, yfrom, x_size, y_size);
203 virtual void draw(
PNMImage &image,
int x,
int y,
float pixel_scale) {
207 virtual void do_scanline(
PNMImage &image,
int xto,
int yto,
208 int xfrom,
int yfrom,
int x_size,
int y_size) {
219 virtual void draw(
PNMImage &image,
int x,
int y,
float pixel_scale) {
223 virtual void do_scanline(
PNMImage &image,
int xto,
int yto,
224 int xfrom,
int yfrom,
int x_size,
int y_size) {
235 virtual void draw(
PNMImage &image,
int x,
int y,
float pixel_scale) {
239 virtual void do_scanline(
PNMImage &image,
int xto,
int yto,
240 int xfrom,
int yfrom,
int x_size,
int y_size) {
274 make_pixel(
const LColorf &color, PNMBrush::BrushEffect effect) {
290 <<
"**Invalid BrushEffect (" << (int)effect <<
")**\n";
302 make_spot(
const LColorf &color,
float radius,
bool fuzzy,
303 BrushEffect effect) {
312 bg.set(color[0], color[1], color[2], 0.0f);
325 <<
"**Invalid BrushEffect (" << (int)effect <<
")**\n";
328 int size = (int)cceil(radius * 2.0f);
329 float half_size = (float)size * 0.5f;
331 float r = half_size / radius;
338 return make_image(spot, half_size, half_size, effect);
353 make_image(
const PNMImage &image,
float xc,
float yc,
354 PNMBrush::BrushEffect effect) {
370 <<
"**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...
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...
LColorf get_xel_a(int x, int y) const
Returns the RGBA color at the indicated pixel.
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...
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...
This is the base class for all three-component vectors and points.
void render_spot(const LColorf &fg, const LColorf &bg, float min_radius, float max_radius)
Renders a solid-color circle, with a fuzzy edge, into the center of the PNMImage. ...