Your leaking thatched hut during the restoration of a pre-Enlightenment state.

 

Hello, my name is Judas Gutenberg and this is my blaag (pronounced as you would the vomit noise "hyroop-bleuach").



links

decay & ruin
Biosphere II
Chernobyl
dead malls
Detroit
Irving housing

got that wrong
Paleofuture.com

appropriate tech
Arduino μcontrollers
Backwoods Home
Fractal antenna

fun social media stuff


Like asecular.com
(nobody does!)

Like my brownhouse:
   handtruck in the snow
Sunday, December 30 2007
My gas-powered chainsaw is temperamental beast, sputtering fumes and conking out randomly and then showing resistance to being restarted. Today I managed to cajole it into cutting up pieces from two large downed oaks within several hundred feet of the house. The pieces were so large that the main difficulty was bringing them home, usually with a handtruck. Interestingly, though, I've found that my handtruck actually rolls better over certain kinds of snow than it does over somewhat-uneven snowless terrain. The main problem is finding the foot traction necessary to pull it along.
Today I spent hours re-writing the Javascript that draws relationship lines in my database mapping tool. I knew I could find the cognitive purchase to shorten the code if only I could make it more readable, so I set forth on a nomenclature plan that referred to map directions such as "northeast" and "southwest" for describing the position of one table with respect to the other. At first this resulted in 180 lines of code and twelve explicit "cases" for drawing lines, but over time I was able to crunch this down to just three cases and 90 lines of code. See for yourself, those of you whose eyes are not glazed-over:


function DrawRelationship(x1, y1, x2, y2, relname, 
	location, width1, width2, disp1, disp2, linecolor)
{
	var zindex=12;
	var strokewidth=1;
	var leftoffset=10;
	var downoffset=-1;
	var out="";
	var x, y, yx;
	offset1=leftoffset+ 1 * disp1;
	offset2=leftoffset + 1 * disp2;
	voffset1=downoffset+ 1 * disp1;
	voffset2=downoffset+ 1 * disp2;
	var w=parseInt(Math.abs(x1-x2));
	var container = document.getElementById(location);
	var bwlSkipExtra1=false;
	var bwlSkipExtra2=false;
	var bwlSkipExtra1e=false;
	var bwlSkipExtra2e=false;
	var absxdif=Math.abs(x1-x2)  + disp1 + disp2;
	var offsetsum=offset1 + offset2;
	y1=y1-voffset1;
	y2=y2-voffset2;
	var widthofeasternmost=width1;
	if(x2<x1)
	{
		widthofeasternmost=width2; 
		//allows me to make an ideal transition from 
		//north/south to east/west mode
	}
	var h=parseInt(Math.abs(y1-y2));
	if(absxdif< (widthofeasternmost + offsetsum+3)) 
	//subject and foreign tables have a north/south 
	//or south/north relationship
	{
		x1=x1-offset1;
		x2=x2-offset2;
		x=ReturnSmaller(x1, x2);
		y=ReturnSmaller(y1, y2);
		yx=y2;
		if(x==x2)
		{
			yx=y1;
		}
		DrawDivLine(yx, x, zindex, strokewidth, absxdif, 
			linecolor, container, relname + " x");
		bwlSkipExtra2e=true;
		bwlSkipExtra1e=true;
	}
	else if (x2<x1) //subject table is west of foreign table
	{
		x1=x1-offset1;
		x2=x2+(width2+offset2);
		bwlSkipExtra2=true;
		bwlSkipExtra1e=true;
		w=w-(width2+offset1+offset2);
		yx= ReturnLarger(y2, y1);
		y=y2;
		x=x2;
		if(y2==yx)
		{
			x=x1;
			y=y1;
		}
		DrawDivLine(yx, x2, zindex, strokewidth, w, 
			linecolor, container, relname + " x");
	}
	else if (x1<x2) //subject table is east of foreign table
	{
		x2=x2-offset2;
		x1=x1+(width1+offset1);
		bwlSkipExtra1=true;
		bwlSkipExtra2e=true;
		w=w-(width1+offset1+offset2);
		y=ReturnSmaller(y2, y1);
		x=x1;
		DrawDivLine(y2, x1, zindex, strokewidth, w, 
			linecolor, container, relname + " x");
	}
	if(h!=0)
	//draw the vertical component of the relationship
	{
		DrawDivLine(y, x, zindex, h, strokewidth, 
			linecolor, container, relname + " y");
	}
	if(!bwlSkipExtra1) 
	{//the short horizontal line 
	//coming to subject table from the west
 		DrawDivLine(y1, x1, zindex, strokewidth, offset1, 
		linecolor, container, relname + " x1");
	}
	if(!bwlSkipExtra2)
	{ //the short horizontal line coming to 
	//foreign table from the west
		DrawDivLine(y2, x2, zindex, strokewidth, offset2, 
		linecolor, container, relname + " x2");
	}
	if(!bwlSkipExtra1e) 
	{//the short horizontal line coming to 
	//subject table from the east
 		DrawDivLine(y1, x1-offset1, zindex, strokewidth, offset1, linecolor, 
		container, relname + " x1");
	}
	if(!bwlSkipExtra2e) 
	{//the short horizontal line coming to 
	//foreign table from the east
		DrawDivLine(y2, x2-offset2, zindex, strokewidth, offset2, 
		linecolor, container, relname + " x2");
	}
}


For linking purposes this article's URL is:
http://asecular.com/blog.php?071230

feedback
previous | next