1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
// P_3_2_1_01.pde // // Generative Gestaltung, ISBN: 978-3-87439-759-9 // First Edition, Hermann Schmidt, Mainz, 2009 // Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni // Copyright 2009 Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni // // http://www.generative-gestaltung.de // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * typo outline displayed as dots and lines * * KEYS * a-z : text input (keyboard) * backspace : delete last typed letter * ctrl : save png + pdf */ import processing.pdf.*; import geomerative.*;//ライブラリ。文字、svg等を使うのによい。今後ほとんど、文字はこれ。 import java.util.Calendar; RFont font;//使用するフォントのための変数を宣言 String textTyped = "Type ...!"; boolean doSave = false; void setup() { size(1324,350); // make window resizable surface.setResizable(true); //わからん smooth(); // allways initialize the library in setup RG.init(this);//作ってもいないオブジェクトだが、恐らくライブラリを読み込んだ瞬間にできてる。初期化。 font = new RFont("FreeSans.ttf", 200, RFont.LEFT); // get the points on the curve's shape // set style and segment resultion //RCommand.setSegmentStep(11); //RCommand.setSegmentator(RCommand.UNIFORMSTEP); RCommand.setSegmentLength (11);//この細かさで点を取る RCommand.setSegmentator(RCommand.UNIFORMLENGTH);//店の取り方? //RCommand.setSegmentAngle(random(0,HALF_PI)); //RCommand.setSegmentator(RCommand.ADAPTATIVE); } void draw() { if (doSave) beginRecord(PDF, timestamp()+"_####.pdf"); background(255); // margin border translate(20,220); if (textTyped.length() > 0) { // get the points on font outline RGroup grp; grp = font.toGroup(textTyped);//?fontで文字列textTypedをtoGrpoupで何らかのグループに。 grp = grp.toPolygonGroup();//グループを何らかの何かに RPoint[] pnts = grp.getPoints();//grpから点をとって、pntsに入れる。RPoint[]はわからん // lines stroke(181, 157, 0); strokeWeight(1.0); for (int i = 0; i < pnts.length; i++ ) {//pnts[i].xでx座標が、yでy座標が取れるぽい。 float l = 5; //から-1、+1してる。ようは line(pnts[i].x-4, pnts[i].y-4, pnts[i].x+4, pnts[i].y+4);//斜めに線が引かれる } // dots fill(0); noStroke(); for (int i = 0; i < pnts.length; i++ ) { float diameter = 7;//半径 // on ervery second point if (i%2 == 0) { ellipse(pnts[i].x, pnts[i].y, diameter, diameter); } } if (doSave) { doSave = false; endRecord(); saveFrame(timestamp()+"_####.png"); } } } void keyPressed() { // println(keyCode+" -> "+key); if (key != CODED) { switch(key) { case DELETE: case BACKSPACE: textTyped = textTyped.substring(0,max(0,textTyped.length()-1)); break; case TAB: case ENTER: case RETURN: case ESC: break; default: textTyped += key; } } if (keyCode == CONTROL) doSave = true; } // timestamp String timestamp() { Calendar now = Calendar.getInstance(); return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now); } |
One comment