Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 375524

Summary: [GC] Arc is drawn incorrectly
Product: [RT] RAP Reporter: Moritz Post <mpost>
Component: RWTAssignee: 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:
Description Flags
Comparison of GC on RAP and SWT none

Description Moritz Post CLA 2012-03-28 08:59:03 EDT
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.
Comment 1 Tim Buschtoens CLA 2012-03-28 09:44:27 EDT
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).
Comment 2 Tim Buschtoens CLA 2012-03-28 09:54:10 EDT
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).
Comment 3 Tim Buschtoens CLA 2012-03-28 11:23:45 EDT
Fixed in CVS HEAD.

Except the renaming of arc->ellipse, all changes are in GCOperationsWriter#drawArc.