Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GoogleCodeExporter opened this issue Mar 14, 2015 · 8 comments

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 23 Jul 2011 at 10:54

@GoogleCodeExporter
Copy link
Author

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 [email protected] on 23 Jul 2011 at 4:35

@GoogleCodeExporter
Copy link
Author

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 [email protected] on 24 Jul 2011 at 3:36

@GoogleCodeExporter
Copy link
Author

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 [email protected] on 22 Oct 2011 at 4:10

Attachments:

@GoogleCodeExporter
Copy link
Author

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 [email protected] on 26 Oct 2011 at 3:12

@GoogleCodeExporter
Copy link
Author

"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 [email protected] on 1 Nov 2011 at 11:28

@GoogleCodeExporter
Copy link
Author

Adding example

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

Original comment by [email protected] on 31 Aug 2012 at 4:59

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 31 Aug 2012 at 8:29

  • Added labels: Toolkit-Piccolo2D.Java

@GoogleCodeExporter
Copy link
Author

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 [email protected] on 9 Dec 2012 at 6:12

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant