-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImage.java
More file actions
executable file
·56 lines (51 loc) · 1.41 KB
/
Image.java
File metadata and controls
executable file
·56 lines (51 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Image class. Allows for easier modification of images
*
* @author Jimmy, Adrian, Daniel
* @version April 24, 2024
*/
public class Image extends Actor {
private GreenfootImage image;
/**
* Sets image with its original proportions
*
* @param path Location of the file
*/
public Image(String path) {
image = new GreenfootImage(path);
setImage(image);
}
/**
* Sets image with scaled proportions in its X and Y
*
* @param path Location of the file
* @param scaleX Amount of X scaled
* @param scaleY Amount of Y scaled
*/
public Image(String path, int scaleX, int scaleY) {
image = new GreenfootImage(path);
image.scale(scaleX, scaleY);
setImage(image);
}
/**
* Sets image with percentage scaled proportions
*
* @param path Location of the file
* @param scalePercent Percentage scaled
*/
public Image(String path, int scalePercent) {
image = new GreenfootImage(path);
double width = image.getWidth() * scalePercent / 100;
double height = image.getHeight() * scalePercent / 100;
image.scale((int) width, (int) height);
setImage(image);
}
/**
* Act - do whatever the Image wants to do. This method is called whenever the 'Act' or 'Run'
* button gets pressed in the environment.
*/
public void act() {
// Add your action code here.
}
}