Write a method to clip an image to a triangle or star shape.
What will be an ideal response?
```
public Picture clipToTriangle ( )
{
int width = this . getWidth ( ) ;
int height = this . getHeight ( ) ;
Picture result = new Picture (width , height ) ;
// get the graphics2D object for this picture
Graphics g = result.getGraphics ( ) ;
Graphics2D g2 = (Graphics2D) g ;
// create a path to use for clipping
GeneralPath path =
new GeneralPath (new Line2D . Double ( 0 , height ,
width / 2 , 0 ) ) ;
path . append (new Line2D . Double ( width / 2 , 0 ,
width , height ) , true ) ;
path . append (new Line2D . Double (width , height ,
0 , height ) , true ) ;
// use the path for clipping
g2 . setClip ( path ) ;
// draw the image
g2 . drawImage ( this . getImage ( ) , 0 , 0 , width ,
height , null ) ;
// return the result
return result ;
}
```
You might also like to view...
When a table is selected, and the values in the Before and After options in the Spacing section of the Paragraph dialog box are increased, the result is ________
A) more space before and after the table B) more space above and below the content in each cell C) more space above and below any paragraph that precedes or follows the table D) no change in the table display
When you add text to a page, a wavy blue line appears under any words that are not in Expression Web's dictionary, indicating a potential spelling error.
Answer the following statement true (T) or false (F)
When you ____ data, you place a copy of the filtered table in a range you have specified in the Advanced Filter dialog box.
A. extract B. delete C. find D. None of the above.
What class can be used to provide information on directories or folders?
A. Directory B. File C. Cabinet D. Folder