Typeface which changes with a kitchen scale - issues

edited February 2018 in How To...

I'm in need of some help for my project. I'm a student and I'm learning code just for this short project.

I have created a typeface made of ellipses on a grid, when weight is placed on the scale the ellipse become bigger and the type, therefore bolder. What I'm wanting to do, is be able to "type" with my coded letters. Is there a really obvious way to do this? Such as importing and placing separate code files (each separate letter). Any tutorials I could be pointed towards would be of great help.

Screen Shot 2018-02-02 at 13.14.33 Screen Shot 2018-02-02 at 13.46.45 Screen Shot 2018-02-02 at 13.47.56

Tagged:

Answers

  • edited February 2018 Answer ✓

    here is a solution

    It first develops the full Alphabet at start up, each letter as a point cloud (taken from the letters A..Z in the current font f). It then displays all letters.

    Then you can (with shift!) hit A, B, C ... Z to test it.

    also try showAllLetters() (shows all letters initially)

    Data structure

    each letter has lots of points, each letter is a point cloud. The points are stored in an array of PVector.

    All arrays of PVector (the Alphabet) are stored in an ArrayList named list.

    The formula

        PVector[] pvector_Array = list.get(key-65);
    

    gets you the array of PVector for key A ... Z from the ArrayList list.

    This might be confusing because it's an array within an ArrayList, but it's easy to handle. If you want I can rewrite it, using a class Letter.

    Best, Chrisir ;-)

    [code just completely re-written (yet without a class)....]

    // https : // forum.processing.org/two/discussion/comment/79932/#Comment_79932
    
    ArrayList<PVector[]> list = new ArrayList(); 
    PGraphics pg=new PGraphics();
    PFont f;
    
    void setup() {
    
      size(1960, 1000);
      background(0);
    
      f = createFont("Arial", 300); // "AR BERKLEY", 300 ) ; // 
      textFont(f);
      fill(0);
    
      pg = createGraphics(400, 400);
      pg.noSmooth();
    
      for (int i='A'; i<='Z'; i++) {
    
        makeLetter(char(i));
    
        PVector[] pv= new PVector[0]; 
    
        for (int x=0; x < pg.width; x+=2) {
          for (int y=0; y < pg.height; y+=3) {
            if (pg.get(x, y) < color(1)) 
              //point(x, y) ;
              pv=(PVector[])append(pv, new PVector(x, y));
          }
        }
    
        list.add(pv);
      }//for
    
      showAllLetters();
      //
    }//func
    
    void draw() {
      //
    }
    
    void showAllLetters() {
    
    
      stroke(0, 225, 0);
    
      int x=0, y=0;
    
      float rad=.7;
      translate(0, 0);
      fill(255);
      for (PVector[] pvector_Array : list) {
        pushMatrix();
        translate(x, y);
        for (PVector pv : pvector_Array) {
          // point(pv.x, pv.y) ;
          noStroke(); 
          fill(0, 255, 0);
          ellipse(pv.x, pv.y, rad, rad) ;
        }
        x+=194;
        if (x>width-200) { 
          x=0;
          y+=250;
        }
        popMatrix();
        rad+=1;
      }
    
      fill(255, 2, 2);
      textSize(22);
      text("Type with shift A...Z", 13, height-28);
    }
    
    void keyPressed () {
    
      if ((key>='A'&&key<='Z')) {
    
        background(255);
        // showAllLetters();
    
        PVector[] pvector_Array = list.get(key-65);
    
        float rad=4;
        translate(107, 40);
        fill(255, 2, 2); // red 
        for (PVector pv : pvector_Array) {
          //point(pv.x, pv.y) ;
          noStroke();
          ellipse(pv.x*3, pv.y*3, rad+pv.y/20, rad+pv.y/20) ;
        }
      }
    }
    
    void makeLetter (char letter) {
      pg.beginDraw();
      pg.background(255);
      pg.textFont(f);
      pg.fill(0);
      pg.text(letter, 4, 223);//"D"
      //pg.text(letter, 3, .5);//"D"
      pg.endDraw();
    }
    //
    
  • Answer ✓

    Unbenannt

  • edited February 2018 Answer ✓

    the resolution is not very high to keep things fast.

    instead of making the alphabet data from scratch, I guess you can store them one time (with another sketch) and then just load it (with your kitchen scale sketch).

    There is a library that can also make point clouds for letters:

    http://www.generative-gestaltung.de/P_3_2_1_02

  • edited February 2018 Answer ✓

    I found a old version with textual data of each letter of the alphabet (it's from the forum)

    it's called letterData1

    Best download entire package as zip, unzip on your hard drive and then turn to the unpacked folder letterData1.

    Download:

    https://github.com/Kango/Processing-snippets

  • Huge thank you, Chrisir.

    I'll see what I can create and will be sure to post back onto here with the final result.

    Cheers!

Sign In or Register to comment.