Export Type to Vector e.g. PDF.
in
Programming Questions
•
1 year ago
Hey Fellows,
Everything looks great and works fine on a mac machine.
my aim is to build a random type generator tool, which is able to save a vectorfile.
I already checked the forums for many sollutions, but processing text is allways different with every library I found.
writing vector data makes it not easier.
The Letters of a word shall change randomly, while their shape has to be centered between the lines(rects).
To maintain the centering I had to modify every font that i used by hand and create a VLW font.
A lot of work and I believe that could be made easier.
I already checked the forums for many sollutions, but processing text is allways different with every library I found.
writing vector data makes it not easier.
The Letters of a word shall change randomly, while their shape has to be centered between the lines(rects).
To maintain the centering I had to modify every font that i used by hand and create a VLW font.
A lot of work and I believe that could be made easier.
Everything looks great and works fine on a mac machine.
As i tried it on a win 7 64bit, i get an error. ( use createFont instead of loadFont)
- Using createFont wreks the allignment (centering),
- Rendering with PGraphics gives the Same mistake.
- Using ProSVG doesnt Work also (Nullpointer)
I would really apricciate your help to make that running on a Win and newer Mac Systems.
EDIT:
Actually it is only running on a mac PowerPC g5 10.5.8 (not Intel)
exporting as an Application and execution leads to a grey display, while nothing happens.
EDIT:
Actually it is only running on a mac PowerPC g5 10.5.8 (not Intel)
exporting as an Application and execution leads to a grey display, while nothing happens.
- import processing.pdf.*;
- boolean savePDF;
- //Fonts
- PFont[] fontList = new PFont[23];
- float fontPosX = 0;
- int fontPosY = 120;
- int fontSize = 19;
- float xPos = 0;
- float yPos = 120;
- //Schwarze Balken
- float linienBreite = 13.277;
- float linienhoehe = .5;
- float linienAbstandY = 20.668;
- float linienAbstandX = 17.336;
- float zifferCorrX = 24.438 ;
- //MouseOver Reaktionsfeld
- int fsY = 134;
- int feY = 80;
- int fsX = 481;
- int feX = 134;
- //RANDOM-Generator
- String word = "LUFSUX55";
- int[] randomValues = new int[word.length()];
- int[] randomCase = new int[word.length()];
- void generateRandomValues() {
- for (int i=0; i<randomValues.length; i++) {
- randomValues[i] = int(random(2)); //randomzahl Schriftart
- randomCase[i] = int(random(2)); //randomzahl Gross-/Kleinschreibung
- }
- }
- void setup() {
- size(800, 600);
- strokeWeight(0);
- // frame.setBackground(new java.awt.Color(0, 0, 0)); ///BLACK APPLET BG
- background(255);
- frameRate(5);
- // FontArray
- // Fehlerhafte Fonts sind ausgegraut
- fontList[0] = loadFont("AntiqueOliveFLUX-70.vlw");
- fontList[1] = loadFont("BaseNineFLUX-70.vlw");
- ////// INIT RANDOM VALUES /////////
- generateRandomValues();
- }
- void draw() {
- if (savePDF) {
- size(142,31); // Ausgabegröße
- beginRecord(PDF, "__exports/"+timestamp()+".pdf");
- }
- background(255);
- ///// Zeichne Reaktionsfeld
- rect( feX+100,feY+50,50,25);
- ////// POSITION where the Randomness begins /////
- if((mouseX <= fsX ) && (mouseX >= feX )) {
- if((mouseY >= feY) && (mouseY<= fsY )) {
- generateRandomValues();
- }
- }//END if()
- runBaby();
- if (savePDF) {
- endRecord();
- savePDF = false;
- size(800, 600);
- } // END if()
- }
- void runBaby() {
- // Schwarze Balken über den Buchstaben
- rectMode(CENTER);
- fill(0);
- xPos = linienBreite/2;
- yPos = linienhoehe/2;
- strokeWeight(0);
- for (int i=0;i<=5;i++) {
- rect(xPos + linienAbstandX*i, yPos, linienBreite, linienhoehe); //obere Balken
- rect(xPos + linienAbstandX*i, yPos + linienAbstandY, linienBreite, linienhoehe); //untere Balken
- }
- rect(xPos + linienAbstandX*5 + zifferCorrX, yPos, linienBreite, linienhoehe); //Nummerbalken oben
- rect(xPos + linienAbstandX*6 + zifferCorrX, yPos, linienBreite, linienhoehe); //Nummerbalken oben
- rect(xPos + linienAbstandX*5 + zifferCorrX, yPos + linienAbstandY, linienBreite, linienhoehe); //Nummerbalken unten
- rect(xPos + linienAbstandX*6 + zifferCorrX, yPos + linienAbstandY, linienBreite, linienhoehe); //Nummerbalken unten
- ///////////// Buchstaben
- textAlign(CENTER); // Die Zentrierung der Buchstaben sollte anhand der Schwarzen Balken berechnet werden.
- // hier wird Sie Anhand von fontPosX berechnet.
- ////////Weitermachen////////Weitermachen////////Weitermachen////////Weitermachen////////Weitermachen////////Weitermachen////////Weitermachen////////Weitermachen
- // Schriftzeichnung
- for (int i=0; i<word.length(); i++) {
- textFont(fontList[randomValues[i]], fontSize);
- if (Character.isDigit(word.charAt(i))) {
- text(word.charAt(i), xPos + (i-1) * linienAbstandX + zifferCorrX, linienAbstandY/2);
- } else {
- // text(word.charAt(i), xPos + (i+1) * fontPosX, fontPosY);
- if (randomCase[i] == 1) text(word.toLowerCase().charAt(i), xPos + i * linienAbstandX, linienAbstandY/2);
- if (randomCase[i] == 0) text(word.toUpperCase().charAt(i), xPos + i * linienAbstandX, linienAbstandY/2);
- }
- }
- }
- void keyPressed() {
- savePDF = true;
- }
- // ---------------------------------------------------------------------------------------- //
- // -- X.X HELPER -------------------------------------------------------------------------- //
- // ---------------------------------------------------------------------------------------- //
- String timestamp() {
- Calendar now = Calendar.getInstance();
- return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM", now);}
1