Hello,
I am very new to processing and find it of great interest.
However I have a problem rendering text in a pdf file. The text just does not render.
Here is my program for a binomial tree:
Code:import processing.pdf.*;
int unit = 80;
int steps = 5;
size(100*steps,12*unit);
PFont font = loadFont("ArialMT-48.vlw");
PGraphicsPDF pdf;
pdf= (PGraphicsPDF)beginRecord(PDF, "binomial-tree.pdf");
beginRecord(pdf);
//quad(0, height/2, unit, height/2 - unit, unit*2, height/2, unit, height/2 + unit);
String spotPriceStr = "S";//these will never render
String optionPriceStr = "f";//these will never render
strokeWeight(2.0);
//Thin lines
for(int outer = steps; outer>0; outer--){
pushMatrix();
for(int inner = 0; inner<outer; inner++){
line(0+(steps-outer)*unit, height/2 +(steps-outer)*unit, unit +(steps-outer)*unit, height/2 - unit +(steps-outer)*unit);
translate(unit,-unit);
}
popMatrix();
pushMatrix();
for(int inner = 0; inner<outer; inner++){
line(0+(steps-outer)*unit, height/2 +(steps-outer)*unit, unit +(steps-outer)*unit, height/2 + unit +(steps-outer)*unit);
translate(unit,-unit);
}
popMatrix();
}
//Thick points
for(int outer = steps; outer>=0; outer--){
pushMatrix();
for(int inner = 0; inner<=outer; inner++){
pushStyle();
stroke(#ff0000);
strokeWeight(10.0);
point(0+(steps-outer)*unit, height/2 + (steps-outer)*unit);
strokeWeight(3.0);
textFont(font, 32);
fill(#000000);
//textLeading(10);
text(optionPriceStr, 0+(steps-outer)*unit, height/2 + (steps-outer)*unit);
translate(unit, -unit);
popStyle();
}
popMatrix();
}
endRecord();
Can anyone please enlighten me..
Julien.