Polygons cleared properly, only thermals need drawing.
Polygons cleared properly, only thermals need drawing.

--- a/src/js/circuit/PCB/Element.js
+++ b/src/js/circuit/PCB/Element.js
@@ -152,6 +152,8 @@
 
 		}
 
+		Element.prototype.clearGL = function(gl, shaderProgram){};
+
 		Element.prototype.cleanupGL = function(gl){
 
 			var i;

--- a/src/js/circuit/PCB/ElementArc.js
+++ b/src/js/circuit/PCB/ElementArc.js
@@ -69,6 +69,8 @@
 	
 		}
 
+		ElementArc.prototype.clearGL = function(gl, shaderProgram){};
+
 		ElementArc.prototype.cleanupGL = function(gl){
 
 			if(this.pointBuffer){

--- a/src/js/circuit/PCB/ElementLine.js
+++ b/src/js/circuit/PCB/ElementLine.js
@@ -45,6 +45,8 @@
 
 	};
 
+	ElementLine.prototype.clearGL = function(gl, shaderProgram){};
+
 	ElementLine.prototype.cleanupGL = function(gl){
 
 		if(this.vertexBuffer){
@@ -63,7 +65,7 @@
 
 	};
 
-	ElementLine.prototype.setup3DArrayBuffer = function(gl, x, y){
+	ElementLine.prototype.generateLineBuffer = function(gl, thickness){
 
 		var vBuffer, ox1, oy1, ox2, oy2, x1, x2, x3, x4, y1, y2, y3, y4;
 
@@ -79,8 +81,8 @@
 		var run = ox2 - ox1;
 		var magnitude = Math.sqrt(rise * rise + run * run);
 
-		var xshift = rise / magnitude * (this.thick / 2);
-		var yshift = run / magnitude * (this.thick / 2);
+		var xshift = rise / magnitude * (thickness / 2);
+		var yshift = run / magnitude * (thickness / 2);
 
 		if(this.parent){
 			ox1 += this.parent.mx;
@@ -110,7 +112,27 @@
 		vBuffer.itemSize = 3;
 		vBuffer.numItems = 4;
 
-		this.vertexBuffer = vBuffer;
+		return vBuffer;
+
+	}
+
+	ElementLine.prototype.setup3DArrayBuffer = function(gl, x, y){
+
+		var vBuffer, ox1, oy1, ox2, oy2;
+
+		ox1 = this.x1;
+		oy1 = this.y1;
+		ox2 = this.x2;
+		oy2 = this.y2;
+
+		if(this.parent){
+			ox1 += this.parent.mx;
+			oy1 += this.parent.my;
+			ox2 += this.parent.mx;
+			oy2 += this.parent.my;
+		}
+
+		this.vertexBuffer = this.generateLineBuffer(gl, this.thick);
 
 		vBuffer = gl.createBuffer();
 		gl.bindBuffer(gl.ARRAY_BUFFER, vBuffer);

--- a/src/js/circuit/PCB/Layer.js
+++ b/src/js/circuit/PCB/Layer.js
@@ -1,118 +1,147 @@
-define(function(){
+define(
+	[
+	 	"./Polygon"
+	],
+	function(
+		Polygon
+	){
 
-	var Layer = function(pcbv, number, name, parts){
+		var Layer = function(pcbv, number, name, parts){
+	
+			this.pcbv = pcbv;
+	
+			this.number = number;
+			this.name = name;
+	
+			this.visible = true;
+	
+			if(parts) this.parts = parts;
+			else this.parts = [];
+	
+		};
+	
+		Layer.SOLDER = 0;
+		Layer.TOP = 1;
+	
+		Layer.prototype.addPart = function(part){
+	
+			this.parts.push(part);
+	
+		};
+	
+		Layer.prototype.render = function(ctx, color){
+	
+			if(!color) color = this.pcbv.getLayerColors()[this.number-1];
+	
+			for(var p = 0; p < this.parts.length; p++)
+				this.parts[p].render(ctx, color);
+	
+		};
+	
+		Layer.prototype.renderGL = function(gl, shaderProgram, oMatrix, mvMatrix, color, pins, elements){
+	
+			gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer);
+	
+			gl.viewport(0, 0, this.framebuffer.width, this.framebuffer.height);
+			gl.clearColor(0.0, 0.0, 0.0, 0.0);
+			gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+	
+			// render clear polygons first
+			// render alpha of pins, same layer pads, and other clearing objects
+			// render non clear polygons
+			// render rest like normal
+	
+			gl.uniform4f(shaderProgram.vColorUniform, color.r, color.g, color.b, 1.0);
+	
+			var i;
 
-		this.pcbv = pcbv;
+			for(i = 0; i < this.parts.length; i++)
+				if(this.parts[i] instanceof Polygon)
+					this.parts[i].renderGL(gl, shaderProgram);
 
-		this.number = number;
-		this.name = name;
+			gl.uniform4f(shaderProgram.vColorUniform, 0.0, 0.0, 0.0, 0.0);
+			for(i = 0; i < this.parts.length; i++)
+				if(!(this.parts[i] instanceof Polygon))
+					this.parts[i].clearGL(gl, shaderProgram);
 
-		this.visible = true;
+			if(pins){
+				for(i = 0; i < pins.parts.length; i++)
+					pins.parts[i].clearGL(gl, shaderProgram);
+			}
+			if(elements){
+				for(i = 0; i < elements.parts.length; i++)
+					elements.parts[i].clearGL(gl, shaderProgram);
+			}
 
-		if(parts) this.parts = parts;
-		else this.parts = [];
+			gl.uniform4f(shaderProgram.vColorUniform, color.r, color.g, color.b, 1.0);
 
-	};
+			for(i = 0; i < this.parts.length; i++)
+				if(!(this.parts[i] instanceof Polygon))
+					this.parts[i].renderGL(gl, shaderProgram);
 
-	Layer.SOLDER = 0;
-	Layer.TOP = 1;
-
-	Layer.prototype.addPart = function(part){
-
-		this.parts.push(part);
-
-	};
-
-	Layer.prototype.render = function(ctx, color){
-
-		if(!color) color = this.pcbv.getLayerColors()[this.number-1];
-
-		for(var p = 0; p < this.parts.length; p++)
-			this.parts[p].render(ctx, color);
-
-	};
-
-	Layer.prototype.renderGL = function(gl, shaderProgram, oMatrix, mvMatrix, color){
-
-		gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer);
-
-		gl.viewport(0, 0, this.framebuffer.width, this.framebuffer.height);
-		gl.clearColor(0.0, 0.0, 0.0, 0.0);
-		gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
-
-		gl.uniform4f(shaderProgram.vColorUniform, color.r, color.g, color.b, 1.0);
-
-		var i;
-		for(i = 0; i < this.parts.length; i++)
-			this.parts[i].renderGL(gl, shaderProgram);
+		}
+	
+		Layer.prototype.cleanupGL = function(gl){
+	
+			var i;
+			for(i = 0; i < this.parts.length; i++)
+				this.parts[i].cleanupGL(gl);
+	
+			gl.deleteTexture(this.texture);
+			gl.deleteRenderbuffer(this.renderbuffer);
+			gl.deleteFramebuffer(this.framebuffer);
+	
+		}
+	
+		Layer.prototype.init3DArrays = function(gl){
+	
+			var i;
+			for(i = 0; i < this.parts.length; i++)
+				this.parts[i].setup3DArrayBuffer(gl, 0, 0);
+	
+		}
+	
+		Layer.prototype.resizeFrameBuffer = function(gl){
+	
+	        this.framebuffer.width = gl.viewportWidth;
+	        this.framebuffer.height = gl.viewportHeight;
+	
+	        gl.bindTexture(gl.TEXTURE_2D, this.texture);
+	        gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.framebuffer.width, this.framebuffer.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+	        gl.bindRenderbuffer(gl.RENDERBUFFER, this.renderbuffer);
+	        gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, this.framebuffer.width, this.framebuffer.height);
+	
+		}
+	
+		Layer.prototype.setupFramebuffer = function(gl){
+	
+	        this.framebuffer = gl.createFramebuffer();
+	        gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer);
+	        this.framebuffer.width = gl.viewportWidth;
+	        this.framebuffer.height = gl.viewportHeight;
+	
+	        this.texture = gl.createTexture();
+	        gl.bindTexture(gl.TEXTURE_2D, this.texture);
+	        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+	        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+	        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+	
+	        gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.framebuffer.width, this.framebuffer.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+	
+	        this.renderbuffer = gl.createRenderbuffer();
+	        gl.bindRenderbuffer(gl.RENDERBUFFER, this.renderbuffer);
+	        gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, this.framebuffer.width, this.framebuffer.height);
+	
+	        gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0);
+	        gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this.renderbuffer);
+	
+	        gl.bindTexture(gl.TEXTURE_2D, null);
+	        gl.bindRenderbuffer(gl.RENDERBUFFER, null);
+	        gl.bindFramebuffer(gl.FRAMEBUFFER, null);
+	
+		}
+	
+		return Layer;
 
 	}
-
-	Layer.prototype.cleanupGL = function(gl){
-
-		// render polygons first
-		// if there are any clearpoly polygons
-		// render alpha of pins, same layer pads, and other clearing objects
-		// render rest like normal
-
-		var i;
-		for(i = 0; i < this.parts.length; i++)
-			this.parts[i].cleanupGL(gl);
-
-		gl.deleteTexture(this.texture);
-		gl.deleteRenderbuffer(this.renderbuffer);
-		gl.deleteFramebuffer(this.framebuffer);
-
-	}
-
-	Layer.prototype.init3DArrays = function(gl){
-
-		var i;
-		for(i = 0; i < this.parts.length; i++)
-			this.parts[i].setup3DArrayBuffer(gl, 0, 0);
-
-	}
-
-	Layer.prototype.resizeFrameBuffer = function(gl){
-
-        this.framebuffer.width = gl.viewportWidth;
-        this.framebuffer.height = gl.viewportHeight;
-
-        gl.bindTexture(gl.TEXTURE_2D, this.texture);
-        gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.framebuffer.width, this.framebuffer.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
-        gl.bindRenderbuffer(gl.RENDERBUFFER, this.renderbuffer);
-        gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, this.framebuffer.width, this.framebuffer.height);
-
-	}
-
-	Layer.prototype.setupFramebuffer = function(gl){
-
-        this.framebuffer = gl.createFramebuffer();
-        gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer);
-        this.framebuffer.width = gl.viewportWidth;
-        this.framebuffer.height = gl.viewportHeight;
-
-        this.texture = gl.createTexture();
-        gl.bindTexture(gl.TEXTURE_2D, this.texture);
-        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
-        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
-        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
-
-        gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.framebuffer.width, this.framebuffer.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
-
-        this.renderbuffer = gl.createRenderbuffer();
-        gl.bindRenderbuffer(gl.RENDERBUFFER, this.renderbuffer);
-        gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, this.framebuffer.width, this.framebuffer.height);
-
-        gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0);
-        gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this.renderbuffer);
-
-        gl.bindTexture(gl.TEXTURE_2D, null);
-        gl.bindRenderbuffer(gl.RENDERBUFFER, null);
-        gl.bindFramebuffer(gl.FRAMEBUFFER, null);
-
-	}
-
-	return Layer;
-
-});
+);

--- a/src/js/circuit/PCB/LayerManager.js
+++ b/src/js/circuit/PCB/LayerManager.js
@@ -124,23 +124,23 @@
 
 			if(side == Layer.TOP){
 
-				this.topSilk.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 0.0, g: 0.0, b: 0.0});
-				this.bottomSilk.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 1.0, g: 1.0, b: 1.0});
-
-				this.top.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 1.0, g: 1.0, b: 1.0});
-				this.solder.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 0.0, g: 0.0, b: 0.0});
+				this.topSilk.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 0.0, g: 0.0, b: 0.0}, this.pins, null);
+				this.bottomSilk.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 1.0, g: 1.0, b: 1.0}, this.pins, null);
+
+				this.top.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 1.0, g: 1.0, b: 1.0}, this.pins, null);
+				this.solder.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 0.0, g: 0.0, b: 0.0}, this.pins, null);
 
 			} else {
 
-				this.topSilk.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 1.0, g: 1.0, b: 1.0});
-				this.bottomSilk.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 0.0, g: 0.0, b: 0.0});
-
-				this.top.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 0.0, g: 0.0, b: 0.0});
-				this.solder.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 1.0, g: 1.0, b: 1.0});
-
-			}
-
-			this.pins.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 1.0, g: 1.0, b: 1.0});
+				this.topSilk.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 1.0, g: 1.0, b: 1.0}, this.pins, null);
+				this.bottomSilk.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 0.0, g: 0.0, b: 0.0}, this.pins, null);
+
+				this.top.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 0.0, g: 0.0, b: 0.0}, this.pins, null);
+				this.solder.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 1.0, g: 1.0, b: 1.0}, this.pins, null);
+
+			}
+
+			this.pins.renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: 1.0, g: 1.0, b: 1.0}, null);
 
 			for(l = 0; l < this.otherLayers.length; l++){
 
@@ -150,7 +150,12 @@
 				g = parseInt(color.substring(3, 5), 16) / 256;
 				b = parseInt(color.substring(5, 7), 16) / 256;
 
-				this.otherLayers[l].renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: r, g: g, b: b});
+				if(this.otherLayers[l].name == "bottom")
+					this.otherLayers[l].renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: r, g: g, b: b}, this.pins, this.solder);
+				else if(this.otherLayers[l].name == "top")
+					this.otherLayers[l].renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: r, g: g, b: b}, this.pins, this.top);
+				else
+					this.otherLayers[l].renderGL(gl, shaderProgram, oMatrix, mvMatrix, {r: r, g: g, b: b}, this.pins, null);
 
 			}
 

--- a/src/js/circuit/PCB/Line.js
+++ b/src/js/circuit/PCB/Line.js
@@ -8,14 +8,77 @@
 		Class
 	){
 
-		var Line = function(x1, y1, x2, y2, thick, notsure, notsure2){
+		var Line = function(x1, y1, x2, y2, thick, clearance, flags){
 	
 			ElementLine.call(this, x1, y1, x2, y2, thick);
-			
+
+			this.clearance = clearance;
+			this.flags = 
+			{
+				clearline: false
+			};
+
+			if(flags){
+				var split = flags.split(','), i;
+
+				for(i = 0; i < split.length; i++){
+					this.flags[split[i]] = true;
+				}
+			}
+
 		};
 	
 		Class.extend(ElementLine, Line);
+
+		Line.prototype.clearGL = function(gl, shaderProgram){
+
+			if(this.flags.clearline){
+
+				gl.bindBuffer(gl.ARRAY_BUFFER, this.clearBuffer);
+				gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, this.clearBuffer.itemSize, gl.FLOAT, false, 0, 0);
+				gl.drawArrays(gl.TRIANGLE_STRIP, 0, this.clearBuffer.numItems);
 	
+				gl.uniform1f(shaderProgram.innerRadiusUniform, 0.0);
+	
+				gl.uniform1f(shaderProgram.pointsizeUniform, (this.thick + this.clearance) * gl.scaleFactor);
+				gl.uniform1f(shaderProgram.roundPointsUniform, true);
+				gl.bindBuffer(gl.ARRAY_BUFFER, this.pointBuffer);
+				gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, this.pointBuffer.itemSize, gl.FLOAT, false, 0, 0);
+				gl.drawArrays(gl.POINTS, 0, this.pointBuffer.numItems);
+				gl.uniform1f(shaderProgram.roundPointsUniform, false);
+
+			}
+
+		};
+
+		Line.prototype.setup3DArrayBuffer = function(gl, x, y){
+
+			var vBuffer, ox1, oy1, ox2, oy2;
+
+			ox1 = this.x1;
+			oy1 = this.y1;
+			ox2 = this.x2;
+			oy2 = this.y2;
+
+			if(this.parent){
+				ox1 += this.parent.mx;
+				oy1 += this.parent.my;
+				ox2 += this.parent.mx;
+				oy2 += this.parent.my;
+			}
+
+			this.vertexBuffer = this.generateLineBuffer(gl, this.thick);
+			this.clearBuffer = this.generateLineBuffer(gl, (this.thick + this.clearance));
+
+			vBuffer = gl.createBuffer();
+			gl.bindBuffer(gl.ARRAY_BUFFER, vBuffer);
+			gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ox1,oy1,0.0,ox2,oy2,0.0]), gl.STATIC_DRAW);
+			vBuffer.itemSize = 3;
+			vBuffer.numItems = 2;
+			this.pointBuffer = vBuffer;
+
+		};
+		
 		return Line;
 
 	}

--- a/src/js/circuit/PCB/Pad.js
+++ b/src/js/circuit/PCB/Pad.js
@@ -40,6 +40,14 @@
 
 	}
 
+	Pad.prototype.clearGL = function(gl, shaderProgram){
+
+		gl.bindBuffer(gl.ARRAY_BUFFER, this.clearBuffer);
+		gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, this.clearBuffer.itemSize, gl.FLOAT, false, 0, 0);
+		gl.drawArrays(gl.TRIANGLE_STRIP, 0, this.clearBuffer.numItems);
+
+	};
+
 	Pad.prototype.cleanupGL = function(gl){
 
 		if(this.vertexBuffer){
@@ -51,17 +59,17 @@
 
 	}
 
-	Pad.prototype.setup3DArrayBuffer = function(gl, x, y){
+	Pad.prototype.generatePadBuffer = function(gl, thick){
 
 		var vBuffer, vertices, x1, x2, y1, y2;
 
 		vBuffer = gl.createBuffer();
 		gl.bindBuffer(gl.ARRAY_BUFFER, vBuffer);
 
-		x1 = this.parent.mx + this.x1 - (this.thick / 2);
-		y1 = this.parent.my + this.y1 - (this.thick / 2);
-		x2 = x1 + this.x2 - this.x1 + this.thick;
-		y2 = y1 + this.y2 - this.y1 + this.thick;
+		x1 = this.parent.mx + this.x1 - (thick / 2);
+		y1 = this.parent.my + this.y1 - (thick / 2);
+		x2 = x1 + this.x2 - this.x1 + thick;
+		y2 = y1 + this.y2 - this.y1 + thick;
 
 		vertices = [
 		 x2, y2,  0.0,
@@ -75,7 +83,14 @@
 		vBuffer.itemSize = 3;
 		vBuffer.numItems = 4;
 
-		this.vertexBuffer = vBuffer;
+		return vBuffer;
+
+	}
+
+	Pad.prototype.setup3DArrayBuffer = function(gl, x, y){
+
+		this.vertexBuffer = this.generatePadBuffer(gl, this.thick);
+		this.clearBuffer = this.generatePadBuffer(gl, this.thick + this.clear);
 
 	};
 

--- a/src/js/circuit/PCB/Pin.js
+++ b/src/js/circuit/PCB/Pin.js
@@ -74,6 +74,28 @@
 
 	}
 
+	Pin.prototype.clearGL = function(gl, shaderProgram){
+
+		var splt = this.flags.split(','), square = true;
+
+		for (i = 0; i < splt.length; i++)
+			if (splt[i] == 'square')
+				square = false;
+
+		
+		gl.uniform1f(shaderProgram.roundPointsUniform, square);
+
+		gl.bindBuffer(gl.ARRAY_BUFFER, this.pointBuffer);
+		gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, this.pointBuffer.itemSize, gl.FLOAT, false, 0, 0);
+
+		gl.uniform1f(shaderProgram.innerRadiusUniform, 0.0);
+		gl.uniform1f(shaderProgram.pointsizeUniform, (this.thick + this.clear) * gl.scaleFactor);
+		gl.drawArrays(gl.POINTS, 0, this.pointBuffer.numItems);
+
+		gl.uniform1f(shaderProgram.roundPointsUniform, false);
+
+	};
+
 	Pin.prototype.cleanupGL = function(gl){
 
 		if(this.pointBuffer){

--- a/src/js/circuit/PCB/Text.js
+++ b/src/js/circuit/PCB/Text.js
@@ -81,6 +81,8 @@
 	        gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);
 
 		}
+
+		Text.prototype.clearGL = function(gl, shaderProgram){};
 	
 		Text.prototype.cleanupGL = function(gl){}
 

--- a/src/js/circuit/PCB/Via.js
+++ b/src/js/circuit/PCB/Via.js
@@ -1,10 +1,11 @@
 define(function() {
-	var Via = function(x, y, od, u1, u2, id, u3, u4) {
+	var Via = function(x, y, od, clearance, u2, id, u3, u4) {
 
 		this.x = x;
 		this.y = y;
 		this.od = od;
 		this.id = id;
+		this.clearance = clearance;
 
 	};
 
@@ -45,6 +46,23 @@
 
 	}
 
+	Via.prototype.clearGL = function(gl, shaderProgram){
+
+		gl.uniform1f(shaderProgram.roundPointsUniform, true);
+
+		gl.bindBuffer(gl.ARRAY_BUFFER, this.pointBuffer);
+		gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, this.pointBuffer.itemSize, gl.FLOAT, false, 0, 0);
+
+		gl.uniform1f(shaderProgram.innerRadiusUniform, 0.0);
+
+		gl.uniform1f(shaderProgram.pointsizeUniform, (this.od + this.clearance) * gl.scaleFactor);
+		gl.drawArrays(gl.POINTS, 0, this.pointBuffer.numItems);
+
+
+		gl.uniform1f(shaderProgram.roundPointsUniform, false);
+
+	};
+
 	Via.prototype.cleanupGL = function(gl){
 
 		if(this.pointBuffer){