aboutsummaryrefslogtreecommitdiff
path: root/layer.c
blob: 77584bceee48f5cf6dcf9b6368e53da8a374d862 (plain)
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
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <geometry.h>
#include "dat.h"
#include "fns.h"

Layer*
newlayer(char *name, Canvas *c)
{
	Layer *l;

	l = emalloc(sizeof(Layer));
	l->p = Pt2(0,0,1);
	l->bx = c->bx;
	l->by = c->by;
	l->name = strdup(name);
	l->image = eallocimage(display, c->image->r, c->image->chan, 0, 0);
	l->prev = c->layers.prev;
	l->next = &c->layers;
	c->layers.prev->next = l;
	c->layers.prev = l;
	if(c->curlayer == nil)
		c->curlayer = l;
	return l;
}

void
rmlayer(Layer *l)
{
	l->prev->next = l->next;
	l->next->prev = l->prev;
	freeimage(l->image);
	free(l->name);
	free(l);
}