| Summary: | [GC] Arc is drawn incorrectly | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [RT] RAP | Reporter: | Moritz Post <mpost> | ||||
| Component: | RWT | Assignee: | Project Inbox <rap-inbox> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | tbuschto | ||||
| Version: | 1.4 | ||||||
| Target Milestone: | 1.5 M7 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
In SWT the fillArc creates a "Pac-Man" (unlike RAP), but a drawArc only draws the arc itself, no connection to the center (like RAP). I will use this opportunity to rename the "arc" command to "ellipse" in the protocol. The reason is that we currently implement "arc" with a different API than the W3C standard (which is our baseline for canvas protocol). The "ellipse" command on the other hand can be used to correctly draw the SWT arc, though it has an additional (and for us useless) rotation parameter, which we can just ignore. The only downside is that "ellipse" exists only in the WHATWG documentation, but it could become a standard. (Even if its not, its still better than incorrectly implementing arc in my opinion). Fixed in CVS HEAD. Except the renaming of arc->ellipse, all changes are in GCOperationsWriter#drawArc. |
Created attachment 213287 [details] Comparison of GC on RAP and SWT Drawing the following code produces an arc that is filled on the wrong side and does not use the center point in its "path". final Canvas topCanvas = new Canvas( parent, SWT.NO_REDRAW_RESIZE ); topCanvas.addPaintListener( new PaintListener() { @Override public void paintControl( PaintEvent e ) { Rectangle clientArea = topCanvas.getClientArea(); e.gc.setBackground( display.getSystemColor( SWT.COLOR_DARK_MAGENTA ) ); e.gc.fillOval( 0, 0, clientArea.width, clientArea.height ); e.gc.setBackground( display.getSystemColor( SWT.COLOR_DARK_GRAY ) ); e.gc.fillArc( 20, 20, clientArea.width - 40, clientArea.height - 40, 0, -120 ); } } ); The attached screenshot shows the difference on RAP and plain SWT.