Charles Rand Barnett / Dot Trombone LLC

Musician & Software Developer


Welcome to the dottrombone.com site!

Site Map

I've been programming since the Apple II came out, but after I failed to make a living playing trombone in the early 2000's (after playing trombone in the US Navy for 7 years), I became homeless and studied programming and math while living on the streets of Seattle.

Here is an example of the computer and math work I do. This is the math behind the menu on this website:

var slantLength = 15;// the horizontal length of the slanted line

// xO stands for x origin, the bottom left of each diagonal line
// xmn stands for x mouse now

var xmn = menuLastMouseX;
var angle = Math.atan((canvas.height + 2) / slantLength);
var sideA = canvas.height - menuLastMouseY;
var sideC = (1 / Math.sin(angle)) * sideA;
var sideB = Math.cos(angle) * sideC;			

var xOffset = sideB;

if(xmn - xOffset > xO && xmn - xOffset < xO + textWidth + textTrailingWidth)
{
	ctx.fillStyle = "yellow";
}
else
{
	ctx.fillStyle = "white";
}

But as is often the case, we don't need fancy trig to do this. We can simply use ratios!

var slantLength = 15;// the horizontal length of the slanted line

// xO stands for x origin, the bottom left of each diagonal line
// xmn stands for x mouse now

var xmn = menuLastMouseX;

// a/b = c/d
var a = canvas.height + 2;
var b = slantLength;
var c = canvas.height - menuLastMouseY;

// now cross multiply and divide to get d
var d = (c * b) / a;

if(xmn > xO && d < xmn - xO && d > xmn - (xO + textWidth + textTrailingWidth))
{
	ctx.fillStyle = "yellow";
}
else
{
	ctx.fillStyle = "white";
}