java.lang.Object <- greenfoot.GreenfootImage
public class GreenfootImage extends java.lang.Object
L’immagine può essere caricata da un file immagine e/o disegnata utilizzando diversi metodi per di disegno.
public GreenfootImage(int larghezza, int altezza)
Parametri:
altezza – L’altezza dell’immagine in pixel.
public GreenfootImage(java.lang.String nomeFile) throws java.lang.IllegalArgumentException
I formati file accettati sono JPEG, GIF e PNG.
Il nome file può essere un nome completo di percorso, un nome di base per un file collocato nella cartella del progetto.
Parametro:
Throws:
public GreenfootImage(GreenfootImage immagine) throws java.lang.IllegalArgumentException
Throws:
public java.awt.image.BufferedImage getAwtImage()
Ogni cambiamento all’immagine restituita si rifletterà nella GreenfootImage.
Restituisce:
public int getWidth()
public int getHeight()
public void setColor(java.awt.Color colore)
Parametri:
public java.awt.Color getColor()
Restituisce:
public void setColorAt(int x, int y, java.awt.Color colore)
public java.awt.Color getColorAt(int x, int y)
Throws:
public void setTransparency(int t)
public int getTransparency()
Parametro:
Restituisce:
Con 0 è completamente trasparente (invisibile) e con 255 è completamente opaca (lo standard).
public void rotate(int gradi)
Parametro:
public void scale(int larghezza, int altezza)
Parametri:
altezza – Altezza della nuova immagine.
public void mirrorVertically()
public void mirrorHorizontally()
public void clear()
public void fill()
public void setFont(java.awt.Font font)
public java.awt.Font getFont()
public void drawString(java.lang.String stringa, int x, int y)
La posizione (x, y) è quella della base sinistra del primo carattere.
Parametri:
x – La coordinata x.
y – La coordinata y.
public void drawLine(int x1, int y1, int x2, int y2)
Parametri:
y1 – La coordinata y del primo punto.
x2 – La coordinata x del secondo punto.
y2 – La coordinata y del secondo punto.
public void drawImage(GreenfootImage immagine, int x, int y)
Parametri:
x – La coordinata x dell’immagine da disegnare.
y – La coordinata y dell’immagine da disegnare.
public void drawRect(int x, int y, int larghezza, int altezza)
public void fillRect(int x, int y, int larghezza, int altezza)
Fill the specified rectangle.
The left and right edges of the rectangle are at x and x+width.
The top and bottom edges are at y and y+height.
The rectangle is drawn using the current color.
Parametri:
y – the y coordinate of the rectangle to be drawn.
larghezza – the width of the rectangle to be drawn.
altezza – the height of the rectangle to be drawn.
public void drawOval(int x, int y, int larghezza, int altezza)
public void fillOval(int x, int y, int larghezza, int altezza)
Parametri:
y – the y coordinate of the upper left corner of the oval to be filled.
larghezza – the width of the oval to be filled.
altezza – the height of the oval to be filled.
public void drawPolygon(int[] xPunti, int[] yPunti, int nPunti)
public void fillPolygon(int[] xPunti, int[] yPunti, int nPunti)
This method draws the polygon defined by nPoint line segments, where the first nPoint – 1 line segments are line segments from (xPoints[i – 1], yPoints[i – 1]) to (xPoints[i], yPoints[i]), for 1 ≤ i ≤ nPoints. The figure is automatically closed by drawing a line connecting the final point to the first point, if those points are different.
The area inside the polygon is defined using an even-odd fill rule, also known as the alternating rule.
Parametri:
yPunti – an array of y coordinates.
nPunti – the total number of points.
public void drawShape(java.awt.Shape figura)
public void fillShape(java.awt.Shape figura)
Disegna una figura con riempimento direttamente sull’immagine.
Le figure sono specificate dall’interfaccia java.awt.Shape.
Parametri:
public java.lang.String toString()
Sovrascrive: