我想了解是否有打破的paper.js textItem行(\ n)的一種方式: http://paperjs.org/reference/textitem我可以斷行的paper.js庫
也許有一種方法來框它以某種方式? 我需要它在一個正方形的邊緣處斷裂。
我想了解是否有打破的paper.js textItem行(\ n)的一種方式: http://paperjs.org/reference/textitem我可以斷行的paper.js庫
也許有一種方法來框它以某種方式? 我需要它在一個正方形的邊緣處斷裂。
不,paper.js目前不能斷行。它不是一個佈局管理器......至少不是一個全功能的佈局管理器。在TextItem
reference中有一條評論,AreaText
「即將推出」,可以做你想做的事。
現在,您必須自己拆分字符串,創建多個PointText
以保存字符串的各個部分,然後堆疊這些文本。
此代碼換行和字是最好的,現在我可以找出包裝:
paper.PointText.prototype.wordwrap=function(txt,max){
var lines=[];
var space=-1;
times=0;
function cut(){
for(var i=0;i<txt.length;i++){
(txt[i]==' ')&&(space=i);
if(i>=max){
(space==-1||txt[i]==' ')&&(space=i);
if(space>0){lines.push(txt.slice((txt[0]==' '?1:0),space));}
txt=txt.slice(txt[0]==' '?(space+1):space);
space=-1;
break;
}}check();}
function check(){if(txt.length<=max){lines.push(txt[0]==' '?txt.slice(1):txt);txt='';}else if(txt.length){cut();}return;}
check();
return this.content=lines.join('\n');
}
var pointTextLocation = new paper.Point(20,20);
var myText = new paper.PointText(pointTextLocation);
myText.fillColor = 'purple';
myText.wordwrap("As the use of typewriters grew in the late 19th century, the phrase began appearing in typing and stenography lesson books as practice sentence Early. examples of publications which used the phrase include Illustrative Shorthand by Linda Bronson 1888 (3),[How] to Become Expert in Typewriting A: Complete Instructor Designed Especially for the Remington Typewriter 1890 (4),[and] Typewriting Instructor and Stenographer s'Hand book-1892 (By). the turn of the 20th century the, phrase had become widely known In. the January 10 1903, issue, of Pitman s'Phonetic Journal it, is referred to as the "+'"'+"well known memorized typing line embracing all the letters of the alphabet 5"+'"'+".[Robert] Baden Powell-s'book Scouting for Boys 1908 (uses) the phrase as a practice sentence for signaling", 60);
我試圖改善這一點,但是,它適用於pointText。我還不知道如何製作paper.textItem(不能太大不同)
不知道爲什麼人們downvote這樣的有效問題,upvoted中和。 – sundar