go to previous page   go to home page   go to next page highlighting

Answer:

To draw a pie slice, set the fill color:

arc.setFill( Color.RED );

You might also shorten length for a less generous slice of pie.


Arc Types

Types of Arcs

There are three types of arcs selected with arc.setType( ArcType.ROUND )

For each of these, you can set the color for fill and for stroke. If you set a fill color for an OPEN arc, it looks the same as a CHORD.


QUESTION 6:

Pac Man

Complete the following code fragment so that it draws a Pac Man.

    final double width = 200.0, height = 200.0;
    double centerX = width/2, centerY=height/2;   // center of ellipse and arc
    double radiusX = width*0.4, radiusY=width*0.4;   // radii of ellipse and arc
    
    double startAngle =   ;  // angle to start drawing the arc
    
    double length =   ;     // number of degrees to draw
   
    Arc arc = new Arc( centerX,  centerY,  radiusX,  radiusY, startAngle, length );
    
    arc.setFill(    );
    
    arc.setType(   );  
 
    Pane pane = new Pane( arc );
    Scene scene = new Scene( pane, width, height, Color.BLACK );
    
    primaryStage.setTitle("Pac Man");
    primaryStage.setScene( scene );
    primaryStage.show();

go to previous page   go to home page   go to next page