File: texture.c

package info (click to toggle)
sam 4.3-14
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,456 kB
  • ctags: 1,673
  • sloc: ansic: 14,328; sh: 1,307; makefile: 315
file content (41 lines) | stat: -rw-r--r-- 1,032 bytes parent folder | download | duplicates (20)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Copyright (c) 1992 AT&T - All rights reserved. */
#include <libc.h>
#include <libg.h>
#include "libgint.h"

void
texture(Bitmap *d, Rectangle r, Bitmap *s, Fcode f)
{
	int x, y, w, h, bfunc;
	GC g;

	x = r.min.x;
	y = r.min.y;
	if(d->flag&SHIFT){
		x -= d->r.min.x;
		y -= d->r.min.y;
	}
	g = _getcopygc(f, d, s, &bfunc);
	if(d->flag&SHIFT){
		XSetTSOrigin(_dpy, g, -d->r.min.x, -d->r.min.y);
	}else
		XSetTSOrigin(_dpy, g, 0, 0);
	w = Dx(r);
	h = Dy(r);
	if(bfunc == UseFillRectangle){
		/* source isn't involved at all */
		XFillRectangle(_dpy, (Drawable)d->id, g, x, y, w, h);
	}else if(bfunc == UseCopyArea){
		XSetTile(_dpy, g, (Drawable)s->id);
		XSetFillStyle(_dpy, g, FillTiled);
		XFillRectangle(_dpy, (Drawable)d->id, g, x, y, w, h);
		XSetFillStyle(_dpy, g, FillSolid);
	}else{
		if(s->ldepth != 0)
			berror("unsupported texture");
		XSetStipple(_dpy, g, (Drawable)s->id);
		XSetFillStyle(_dpy, g, FillOpaqueStippled);
		XFillRectangle(_dpy, (Drawable)d->id, g, x, y, w, h);
		XSetFillStyle(_dpy, g, FillSolid);
	}
}