-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathLCDCircles.java
More file actions
106 lines (81 loc) · 2.77 KB
/
LCDCircles.java
File metadata and controls
106 lines (81 loc) · 2.77 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package ev3dev.actuators.ev3;
import ev3dev.actuators.LCD;
import ev3dev.utils.JarResource;
import lejos.hardware.lcd.GraphicsLCD;
import lejos.robotics.Color;
import lejos.utility.Delay;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.image.BufferedImage;
import java.io.IOException;
public class LCDCircles {
public static Logger LOGGER = LoggerFactory.getLogger(LCDCircles.class);
private GraphicsLCD lcd;
public LCDCircles() {
lcd = LCD.getInstance();
showJavaLogo(lcd);
Delay.msDelay(4000);
clear(lcd);
fourFractalCircle(
1,
25,
0,
128,
lcd);
Delay.msDelay(5000);
clear(lcd);
fourFractalCircle(
2,
25,
0,
128,
lcd);
Delay.msDelay(5000);
clear(lcd);
fourFractalCircle(
3,
25,
0,
128,
lcd);
Delay.msDelay(5000);
clear(lcd);
fourFractalCircle(
4,
25,
0,
128,
lcd);
Delay.msDelay(5000);
}
public static void main(String[] args) {
LCDCircles main = new LCDCircles();
}
public static void fourFractalCircle(int interacoes, int x, int y, int tamanho, GraphicsLCD g) {
if (interacoes == 0) {
} else {
g.setColor(Color.BLACK);
g.drawOval(x, y, tamanho, tamanho);
g.refresh();
fourFractalCircle(interacoes - 1, x+tamanho / 4, y, tamanho / 2, g); //chamada recurssiva para desenhar circulos na parte superior
fourFractalCircle(interacoes - 1, x, y+tamanho / 4, tamanho / 2, g);//chamada recurssiva para desenhar circulos na parte esquerda
fourFractalCircle(interacoes - 1, x + tamanho / 2, y+tamanho / 4, tamanho / 2, g);////chamada recurssiva para desenhar circulos na parte direita
fourFractalCircle(interacoes - 1, x+ tamanho / 4, y + tamanho / 2, tamanho / 2, g);//chamada recurssiva para desenhar circulos na parte inferior
}
}
public static void clear(GraphicsLCD g) {
//lcd.setColor(Color.WHITE);
g.setColor(255,255,255);
g.fillRect(0,0, g.getWidth(), g.getHeight());
}
public static final String JAVA_DUKE_IMAGE_NAME = "java_logo.png";
private static void showJavaLogo(GraphicsLCD lcd) {
try {
BufferedImage image = JarResource.loadImage(JAVA_DUKE_IMAGE_NAME);
lcd.drawImage(image, 35, 10, 0);
lcd.refresh();
}catch (IOException e){
LOGGER.error(e.getLocalizedMessage());
}
}
}