chapter7/tweetshirt.js
// draws all the text, including the tweet
draws all the text, including the tweet
draws all the text including the tweet
function drawText(canvas, context) {
	var selectObj = document.getElementById("foregroundColor");
	var index = selectObj.selectedIndex;
	var fgColor = selectObj[index].value;
	context.fillStyle = fgColor;
	context.font = "bold 1em sans-serif";
	context.textAlign = "left";
	context.fillText("I saw this tweet", 20, 40);
	selectObj = document.getElementById("tweets");
	index = selectObj.selectedIndex;
	var tweet = selectObj[index].value;
	context.font = "italic 1.2em serif";
	context.fillText(tweet, 30, 100);
	context.font = "bold 1em sans-serif";
	context.textAlign = "right";
	context.fillText("and all I got was this lousy t-shirt!", 
		canvas.width-20, canvas.height-40);
}
function drawText ( canvas , context ) { var selectObj = document . getElementById ( "foregroundColor" ) ; var index = selectObj . selectedIndex ; var fgColor = selectObj [ index ] . value ; context . fillStyle = fgColor ; context . font = "bold 1em sans-serif" ; context . textAlign = "left" ; context . fillText ( "I saw this tweet" , 20 , 40 ) ; selectObj = document . getElementById ( "tweets" ) ; index = selectObj . selectedIndex ; var tweet = selectObj [ index ] . value ; context . font = "italic 1.2em serif" ; context . fillText ( tweet , 30 , 100 ) ; context . font = "bold 1em sans-serif" ; context . textAlign = "right" ; context . fillText ( "and all I got was this lousy t-shirt!" , canvas . width - 20 , canvas . height - 40 ) ; }
draws all the text, including the tweet
draws all the text including the tweet
// draw the tweet! // If you want to try splitIntoLines to  // handle longer tweets, uncomment this code // and replace the context.fillText line above /*
	if (tweet.length > 60) {
		var tweetLines = splitIntoLines(tweet);
		for (var i = 0; i < tweetLines.length; i++) {
			context.fillText(tweetLines[i], 30, 70+(i*25));
		}
	}
	else {
		context.fillText(tweet, 30, 100);
	}
*/