We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Text With Stroke - how to
Page Index Toggle Pages: 1
Text With Stroke - how to? (Read 443 times)
Text With Stroke - how to?
Feb 6th, 2009, 5:20pm
 

What is the easiest way to have text with a stroke
 outline?

I have been doing a good deal of searching for this issue,
 but did not seem to come up with any example of this.

 I hope it has not been answered in another thread.
 
 Thanks.
Re: Text With Stroke - how to?
Reply #1 - Feb 6th, 2009, 6:25pm
 
I actually came up with something - but please let me know if there is a better solution.

 This method works but is kind of crappy.

  Would definitely break for larger thickness values.


//This is an eclipse example of this
// - remove all ref to the PApplet  
//   if used in a sketch
public void borderText(PApplet papParent,
                      String pstrText,
                      int pintThickness,
                      int pintX,
                      int pintY,
                      Color pclrStroke,
                      Color pclrFill){ 

    papParent.fill(pclrStroke.getRed(),pclrStroke.getGreen(),pclrStroke.getBlue(),pc
lrStroke.getAlpha());

    papParent.text(pstrText,pintX+pintThickness,pintY);
    papParent.text(pstrText,pintX-pintThickness,pintY);
    papParent.text(pstrText,pintX,pintY+pintThickness);
    papParent.text(pstrText,pintX,pintY-pintThickness);
   
    papParent.fill(pclrFill.getRed(),pclrFill.getGreen(),pclrFill.getBlue(),pclrFill
.getAlpha());

    papParent.text(pstrText,pintX,pintY);

 }
Page Index Toggle Pages: 1