vis_files/button.js
/// Aligns lines of a paragraph within a certain width
Aligns lines of a paragraph within a certain width
Aligns lines of a paragraph within a certain width
function alignparagraph(text,dx,fontset) 
{
	var i, ist, len, yy, font, di;
	dx -= 8;
	if(fontset) font = fontset;
	else font = HELPFONT;
	text = ""+text;
	var textsplit = text.split("  ");
	nlines = 0;
	for(var spl = 0; spl < textsplit.length; spl++){
		var te = textsplit[spl];
		i = 0; len = te.length;
		di = Math.floor(len*dx/textwidth_simp(te,font));
		yy = 0;
		while(i < len){
			ist = i;
			i += di; if(i > len) i = len; 
			while(i < len && textwidth_simp(te.substr(ist,i-ist),font) < dx) i++;
			if(textwidth_simp(te.substr(ist,i-ist),font) >= dx){
				do{
					i--; while(te.substr(i,1) != " " && i > ist) i--;
				}while(textwidth_simp(te.substr(ist,i-ist),font) > dx);
				if(i == ist){
					i = ist + di;
					while(textwidth_simp(te.substr(ist,i-ist),font) < dx) i++;
					while(textwidth_simp(te.substr(ist,i-ist),font) > dx) i--;
				}
				else i++;
			}
			lines[nlines] = te.substr(ist,i-ist);
			while(i < len && te.substr(i,1) == " ") i++;
			linesy[nlines] = yy;
			yy += lineheight;
			nlines++;
		}
		if(spl < textsplit.length-1){
			lines[nlines] = ""; yy += lineheight; nlines++;
		}
	}
	hsto = yy;
}
function alignparagraph ( text , dx , fontset ) { var i , ist , len , yy , font , di ; dx -= 8 ; if ( fontset ) font = fontset ; else font = HELPFONT ; text = "" + text ; var textsplit = text . split ( "  " ) ; nlines = 0 ; for ( var spl = 0 ; spl < textsplit . length ; spl ++ ) { var te = textsplit [ spl ] ; i = 0 ; len = te . length ; di = Math . floor ( len * dx / textwidth_simp ( te , font ) ) ; yy = 0 ; while ( i < len ) { ist = i ; i += di ; if ( i > len ) i = len ; while ( i < len && textwidth_simp ( te . substr ( ist , i - ist ) , font ) < dx ) i ++ ; if ( textwidth_simp ( te . substr ( ist , i - ist ) , font ) >= dx ) { do { i -- ; while ( te . substr ( i , 1 ) != " " && i > ist ) i -- ; } while ( textwidth_simp ( te . substr ( ist , i - ist ) , font ) > dx ) ; if ( i == ist ) { i = ist + di ; while ( textwidth_simp ( te . substr ( ist , i - ist ) , font ) < dx ) i ++ ; while ( textwidth_simp ( te . substr ( ist , i - ist ) , font ) > dx ) i -- ; } else i ++ ; } lines [ nlines ] = te . substr ( ist , i - ist ) ; while ( i < len && te . substr ( i , 1 ) == " " ) i ++ ; linesy [ nlines ] = yy ; yy += lineheight ; nlines ++ ; } if ( spl < textsplit . length - 1 ) { lines [ nlines ] = "" ; yy += lineheight ; nlines ++ ; } } hsto = yy ; }
Aligns lines of a paragraph within a certain width
Aligns lines of a paragraph within a certain width
//while(i < len && text.substr(i,1) != " ") i++;