:- all_float(_, off).				% things go faster with integers

lambda(7).					% 7 pixels

implant([X0, Y0], [X1, Y1]) :-			% implant box
	colourof(implant),
	lambda(L),
	X0a is (X0) * L,
	Y0a is (Y0) * L,
	X1a is (X1) * L,
	Y1a is (Y1) * L,
	g_line(X0a, Y0a, X0a, Y1a),
	g_line(X0a, Y0a, X1a, Y0a),
	g_line(X0a, Y1a, X1a, Y1a),
	g_line(X1a, Y0a, X1a, Y1a).

wire(Layer, From, To) :-			% minimum width
	minwidth(Layer, W),
	wire(Layer, W, From, To).

wire(Layer, Width, [FromX, Y], [ToX, Y]) :-	% horizontal
	colourof(Layer),
	lambda(L),
	X0 is (FromX) * L,
	Y0 is (Y) * L,
	X1 is (ToX) * L,
	Y1 is Y0 + Width * L,
	g_fill(X0, Y0, X1, Y1).
wire(Layer, Width, [X, FromY], [X, ToY]) :-	% vertical
	colourof(Layer),
	lambda(L),
	X0 is (X) * L,
	X1 is X0 + Width * L,
	Y0 is (FromY) * L,
	Y1 is (ToY) * L,
	g_fill(X0, Y0, X1, Y1).

minwidth(contactcut, 2).
minwidth(poly, 2).
minwidth(diffusion, 2).
minwidth(metal, 3).
%minwidth(implant, is_none!).

colourof(contactcut) :-	g_enable(7), g_colour(0).
colourof(poly) :-	g_enable(1), g_colour(1).
colourof(diffusion) :-	g_enable(2), g_colour(2).
colourof(implant) :-	g_enable(7), g_colour(3).
colourof(metal) :-	g_enable(4), g_colour(4).
