45 lines
1.3 KiB
Plaintext
45 lines
1.3 KiB
Plaintext
package graphics;
|
|
|
|
import scheme.lib.htdp.image;
|
|
import scheme.lib.htdch.graphics.rename;
|
|
|
|
public class PictureFactory {
|
|
|
|
boolean pinholeInCenter;
|
|
|
|
public PictureFactory( boolean pinholeInCenter ) {
|
|
this.pinholeInCenter = pinholeInCenter;
|
|
}
|
|
|
|
Image setPinhole(Image i ) {
|
|
if (pinholeInCenter)
|
|
return i;
|
|
else
|
|
return i.putPinhole(new Posn(0,0));
|
|
}
|
|
|
|
public Image makeCircle( int r, String mode, Color c) {
|
|
return setPinhole(new Image( image.circle( r, rename.toSymbol(mode), c.toString() ) ));
|
|
}
|
|
|
|
public Image makeRectangle( int width, int height, String mode, Color c) {
|
|
return setPinhole(new Image( image.rectangle( width, height, rename.toSymbol(mode), c.toString() )));
|
|
}
|
|
|
|
public Image makeEllipse( int width, int height, String mode, Color c) {
|
|
return setPinhole(new Image( image.ellipse( width, height, rename.toSymbol(mode), c.toString() )));
|
|
}
|
|
|
|
public Image makeTriangle( int edge, String mode, Color c) {
|
|
return setPinhole(new Image( image.triangle( edge, rename.toSymbol(mode), c.toString() )));
|
|
}
|
|
|
|
public Image makeLine( Posn to, Color c) {
|
|
return setPinhole(new Image( image.line(to.x,to.y,c.toString())));
|
|
}
|
|
|
|
public Image makeText( String text, int ptSize, Color c) {
|
|
return setPinhole(new Image( image.text( text, ptSize, c.toString() ) ));
|
|
}
|
|
|
|
} |