processing
1コード 2`PImage img; 3String lin, lim; 4int i, ln, lm; 5String lines[]; 6 7void setup() { 8 9 background(255); 10 11 img = loadImage("kougishiryou.jpg"); 12 size( img.width, img.height ); 13 image(img, 0, 0); 14 i = 0; 15 ln = 0; 16 lm = 1; 17 lines = loadStrings("test.txt"); 18} 19 20void draw() { 21 lin =lines[ln]; 22 lim =lines[lm]; 23 24 String[] co = split(lin, ','); 25 String[] co2 = split(lim, ','); 26 27 if (co.length==4) { 28 line(int(co[i]), int(co[i+1]), int(co[i+2]), int(co[i+3])); 29 } 30 if (int(co[i])-20 < int(co2[i]) && int(co2[i]) < int(co[i])+20 /*&& int(co[i+1])-20 < int(co2[i+1]) && int(co2[i+1]) < int(co[i+1])+20*/) { 31 //for (lm=1;lm==lines.length;lm++) { 32 stroke(255, 0, 0); 33 strokeWeight(3); 34 line(int(co[i]), int(co[i+1]), int(co[i+2]), int(co[i+3])); 35 //} 36 } 37 ln+=1; 38 39 if (ln == lines.length) noLoop(); 40} 41 42テキストファイル 4366,590,461,583 4466,590,461,583 45696,128,1244,12581 46102,294,593,293 4779,590,460,583 48693,478,819,517 49693,471,1222,462 50701,533,1108,526 51697,637,1237,626 5266,590,461,583 53 54テキストファイルに書かれたlineの座標を表示し,さらに近い位置にあるものをif文で調べて 55上から太い,赤いlineを引くというプログラムです. 56 57if文がうまく機能していません. 58誤差はlineの始点の座標で20を考えています. 59 60特別if文にこだわっているわけではないのですが,何か良い解決方法があればお願いします.
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/14 03:09
2018/11/14 03:31
2018/11/14 03:58