GoogleCodeArchive / piccolo2d

Automatically exported from code.google.com/p/piccolo2d
0 stars 0 forks source link

Cannot draw veritical and horizontal lines of 0 width stroke using PPath #221

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use the following code:
PPath line = PPath.createLine(5f, 10f, 5f, 100f);
line.setStroke(new BasicStroke(0));

2. The following code too:
PPath line = new PPath();
line.setStroke(new BasicStroke(0));
line.moveTo(5f, 10f);
line.lineTo(5f, 100f);

What is the expected output? What do you see instead?
A horizontal or vertical line of 1 pixel wide should be drawn  in any zoom 
level. However the line just can not be seen!

What version of the product are you using? On what operating system?
Piccolo2d.java 1.3.1 is used on java 1.6.0_14-b08, Windows XP SP3.

Original issue reported on code.google.com by v11...@gmail.com on 23 Jul 2011 at 10:54

GoogleCodeExporter commented 9 years ago
Shouldn't a BasicStroke(0) yield a stroke that is zero pixels wide?  Maybe you 
need to create a BasicStroke(1) to get a stroke of 1 pixel wide.

Original comment by samrr...@gmail.com on 23 Jul 2011 at 4:35

GoogleCodeExporter commented 9 years ago
In the Developer's FAQ http://www.piccolo2d.org/learn/dev-faq.html
section "Why is my app so slow?", it states as follows:

"...., If you need to render the strokes, you could try setting the stroke 
width to zero, which has the effect of always drawing a one-pixel wide stroke. 
...."

And it brings very significant performance improvement using BasicStroke(0).

The bug occurs when either x1 == x2, or y1 == y2 in the case of
PPath.createLine(x1, y1, x2, y2);

Original comment by v11...@gmail.com on 24 Jul 2011 at 3:36

GoogleCodeExporter commented 9 years ago
I can confirm the bug with my system

* Piccolo2d.java 1.3.1, 
* java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.3) (fedora-59.1.10.3.fc15-i386)
OpenJDK Server VM (build 20.0-b11, mixed mode)
* Fedora 15 2.6.40.6-0.fc15.i686

If x1!=x2 or y1!=y2 then a one pixel width line is drawn in every zoom level, 
for stroke width zero. Attached is a test program to show the issue.

Original comment by funny...@googlemail.com on 22 Oct 2011 at 4:10

Attachments:

GoogleCodeExporter commented 9 years ago
Is this a Piccolo2D bug or an AWT one?  I don't see any mention of 1-pixel wide 
stroke width with BasicStroke(0) in the JDK javadocs.

Original comment by heue...@gmail.com on 26 Oct 2011 at 3:12

GoogleCodeExporter commented 9 years ago
"If you need to render the strokes, you could try setting the stroke width to 
zero, which has the effect of always drawing a one-pixel wide stroke."

This is true for the Win7/Java1.6.27 system I've tested it on, but afaik 
Piccolo doesn't have logic that ensures this, so it would be a side effect of 
what the JDK does. If the JDK doesn't document this as a contract, then it must 
be inadvertent or a bug and not to be relied on.

We might want to remove that comment from the developer faq.

Original comment by atdi...@gmail.com on 1 Nov 2011 at 11:28

GoogleCodeExporter commented 9 years ago
Adding example

$ svn commit -m "Issue 221 ; adding ZeroWidthStrokeBug to examples.issues" .
Committed revision 1169.

Original comment by heue...@gmail.com on 31 Aug 2012 at 4:59

GoogleCodeExporter commented 9 years ago

Original comment by heue...@gmail.com on 31 Aug 2012 at 8:29

GoogleCodeExporter commented 9 years ago
The attached java examples draws vertical and horizontal lines with 
BasicStroke(0). It works correctly. I think the problem is not in java itself.

Original comment by v11...@gmail.com on 9 Dec 2012 at 6:12

Attachments: