示例#1
0
void		kinder_bueno_mode(t_bunny_pixelarray *pix)
{
  int		i;
  t_color	*pixels;

  pixels = pix->pixels;
  i = -1;
  while (++i < pix->clipable.buffer.height * pix->clipable.buffer.width)
    pixels[i].full = ((RGBA_G(pixels[i].argb[3], pixels[i].argb[0],
			      pixels[i].argb[1], pixels[i].argb[2]) > 127) ?
		      RGBA_C(255, 255, 255, pixels[i].argb[3]) :
		      RGBA_C(0, 0, 0, pixels[i].argb[3]));
}
static void sp_ctrlrect_hline(SPCanvasBuf *buf, gint y, gint xs, gint xe, guint32 rgba, guint dashed)
{
    if (y >= buf->rect.y0 && y < buf->rect.y1) {
        guint const r = RGBA_R(rgba);
        guint const g = RGBA_G(rgba);
        guint const b = RGBA_B(rgba);
        guint const a = RGBA_A(rgba);
        gint const x0 = MAX(buf->rect.x0, xs);
        gint const x1 = MIN(buf->rect.x1, xe + 1);
        guchar *p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 4;
        for (gint x = x0; x < x1; x++) {
            if (!dashed || ((x / DASH_LENGTH) % 2)) {
                p[0] = INK_COMPOSE(r, a, p[0]);
                p[1] = INK_COMPOSE(g, a, p[1]);
                p[2] = INK_COMPOSE(b, a, p[2]);
            }
            p += 4;
        }
    }
}
/** Fills the pixels in [xs, xe)*[ys,ye) clipped to the tile with rgb * a. */
static void sp_ctrlrect_area(SPCanvasBuf *buf, gint xs, gint ys, gint xe, gint ye, guint32 rgba)
{
    guint const r = RGBA_R(rgba);
    guint const g = RGBA_G(rgba);
    guint const b = RGBA_B(rgba);
    guint const a = RGBA_A(rgba);
    gint const x0 = MAX(buf->rect.x0, xs);
    gint const x1 = MIN(buf->rect.x1, xe + 1);
    gint const y0 = MAX(buf->rect.y0, ys);
    gint const y1 = MIN(buf->rect.y1, ye + 1);
    for (gint y = y0; y < y1; y++) {
        guchar *p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 4;
        for (gint x = x0; x < x1; x++) {
            p[0] = INK_COMPOSE(r, a, p[0]);
            p[1] = INK_COMPOSE(g, a, p[1]);
            p[2] = INK_COMPOSE(b, a, p[2]);
            p += 4;
        }
    }
}
static void sp_ctrlrect_vline(SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba, guint dashed)
{
    if (x >= buf->rect.x0 && x < buf->rect.x1) {
        guint const r = RGBA_R(rgba);
        guint const g = RGBA_G(rgba);
        guint const b = RGBA_B(rgba);
        guint const a = RGBA_A(rgba);
        gint const y0 = MAX(buf->rect.y0, ys);
        gint const y1 = MIN(buf->rect.y1, ye + 1);
        guchar *p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4;
        for (gint y = y0; y < y1; y++) {
            if (!dashed || ((y / DASH_LENGTH) % 2)) {
                p[0] = INK_COMPOSE(r, a, p[0]);
                p[1] = INK_COMPOSE(g, a, p[1]);
                p[2] = INK_COMPOSE(b, a, p[2]);
            }
            p += buf->buf_rowstride;
        }
    }
}
示例#5
0
void		fox_mod_grey(t_bunny_pixelarray *pix)
{
  t_color		c;
  t_bunny_position	pos;
  int			i;

  pos.y = 0;
  while (pos.y < pix->clipable.clip_height)
    {
      pos.x = 0;
      while (pos.x < pix->clipable.clip_width)
	{
	  c = fox_getpixel(pix, &pos);
	  c.argb[0] = RGBA_G(c.argb[2], c.argb[1], c.argb[0], c.argb[3]);
	  c.full = RGBA_C(c.argb[0], c.argb[0], c.argb[0], c.argb[3]);
	  i = pos.y * pix->clipable.clip_width + pos.x;
	  ((unsigned int *)pix->pixels)[i] = c.full;
	  ++pos.x;
	}
      ++pos.y;
    }
}