Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Classes | Typedefs | Functions
art_render_pattern.c File Reference
#include "scconfig.h"
#include "art_render_pattern.h"
#include <math.h>

Go to the source code of this file.

Classes

struct  _ArtImageSourcePattern

Typedefs

typedef struct _ArtImageSourcePattern

Functions

static void art_render_pattern_done (ArtRenderCallback *self, ArtRender *render)
static void art_render_pattern_render (ArtRenderCallback *self, ArtRender *render, art_u8 *dest, int y)
static void art_render_pattern_negotiate (ArtImageSource *self, ArtRender *render, ArtImageSourceFlags *p_flags, int *p_buf_depth, ArtAlphaType *p_alpha)
void art_render_pattern (ArtRender *render, const ArtPattern *pattern, ArtFilterLevel level)

Class Documentation

struct _ArtImageSourcePattern

Definition at line 32 of file art_render_pattern.c.

Class Members
const ArtPattern * pattern
ArtImageSource super

Typedef Documentation

typedef struct _ArtImageSourcePattern

Definition at line 30 of file art_render_pattern.c.


Function Documentation

void art_render_pattern ( ArtRender *  render,
const ArtPattern *  pattern,
ArtFilterLevel  level 
)

Definition at line 97 of file art_render_pattern.c.

{
  ArtImageSourcePattern *image_source = art_new (ArtImageSourcePattern, 1);

  image_source->super.super.render = NULL;
  image_source->super.super.done = art_render_pattern_done;
  image_source->super.negotiate = art_render_pattern_negotiate;

  image_source->pattern = pattern;

  art_render_add_image_source (render, &image_source->super);
}

Here is the call graph for this function:

static void art_render_pattern_done ( ArtRenderCallback *  self,
ArtRender *  render 
) [static]

Definition at line 38 of file art_render_pattern.c.

{
  art_free (self);
}

Here is the caller graph for this function:

static void art_render_pattern_negotiate ( ArtImageSource *  self,
ArtRender *  render,
ArtImageSourceFlags *  p_flags,
int p_buf_depth,
ArtAlphaType *  p_alpha 
) [static]

Definition at line 86 of file art_render_pattern.c.

{
  self->super.render = art_render_pattern_render;
  *p_flags = 0;
  *p_buf_depth = render->depth;
  *p_alpha = ART_ALPHA_SEPARATE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void art_render_pattern_render ( ArtRenderCallback *  self,
ArtRender *  render,
art_u8 *  dest,
int  y 
) [static]

Definition at line 44 of file art_render_pattern.c.

{
  ArtImageSourcePattern *z = (ArtImageSourcePattern *)self;
  const ArtPattern *pattern = z->pattern;
  int pixstride = (render->n_chan + 1) * (render->depth >> 3);
  int n_ch = render->n_chan + 1;
  int x, j, index;
  int width = render->x1 - render->x0;
  int twidth = pattern->twidth;
  int theight = pattern->theight;
  art_u8 *bufp = render->image_buf;

  double angle = pattern->angle;
  double opacity = pattern->opacity;
  double cosangle = cos(angle);
  double sinangle = sin(angle);

  y = y - render->y0;

  for (x = 0; x < width; x++)
  {
         int x0 = sinangle * y + cosangle * x;
         int y0 = -sinangle * x + cosangle * y;
         x0 = (x0 % twidth);
         if(x0 < 0) x0 += twidth;
         y0 = (y0 % theight);
         if(y0 < 0) y0 += theight;
         index = (((y0 * twidth + x0) * pixstride) % (twidth * theight * 4));
         /*for (j = 0; j < n_ch - 1; j++)
              {*/
             /* bgra -> rgba */
          bufp[0] = pattern->buffer[index + 2];
          bufp[1] = pattern->buffer[index + 1];
          bufp[2] = pattern->buffer[index + 0];
          bufp[3] = opacity;
              /*}*/
      bufp += pixstride;
  }
}

Here is the caller graph for this function: