canvas - JavaFX 8 strokeText unexpected behaviour -


stroketext uses setlinewidth width of stroke. if set linewidth 0.0 (expecting stroke of 0.0 i.e. no stroke @ all), strokes text set linewidth. despite explicit gc.setlinewidth(0.0);, stroke value ignored , uses whatever set previously. here example:

    canvas fieldcanvas = new canvas(400, 400);     gc = fieldcanvas.getgraphicscontext2d();          gc.setfill(color.yellow);      gc.setstroke(color.red);     gc.setlinewidth(10.0);         gc.fillrect(50, 50, 350, 150);     gc.strokerect(50, 50, 350, 150);      gc.setfont(font.font("arial", 100));                     gc.setfill(color.green);     gc.setstroke(color.black);             gc.setlinewidth(0.0);                                     gc.filltext("test", 100, 160);     gc.stroketext("test", 100, 160); 

this stroke text value of 10.0

the java fx8 documentation states: infinite or non-positive value outside of range (0, +inf) ignored , current value remain unchanged.

but seems include 0 itself. value must > 0 not == 0.

should documentation clearer or missing here?

the docs clearer, means exclusive range. here's current implementation:

 * sets current line width.  *   * @param lw value in range {0-positive infinity}, other value   * being ignored , leaving value unchanged.  */ public void setlinewidth(double lw) {     // per w3c spec: on setting, zero, negative, infinite, , nan     // values must ignored, leaving value unchanged     if (lw > 0 && lw < double.positive_infinity) { 

as comment suggests, seems following canvas spec, behaves identically, can try similar in browser -

var c = document.getelementbyid("mycanvas"); var ctx = c.getcontext("2d"); ctx.linewidth = 30; ctx.linewidth = 0; ctx.strokerect(20, 20, 80, 100); 

which gives fat rectangle.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -