Passed
Push — master ( 82dbb2...0f24f3 )
by Seth
08:38
created

example.TransformationTest.loop()   A

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
dl 0
loc 7
rs 10
1
package example;
2
3
import org.gannacademy.cdf.graphics.geom.Rectangle;
4
import org.gannacademy.cdf.graphics.geom.*;
5
import org.gannacademy.cdf.graphics.ui.AppWindow;
6
7
import java.awt.*;
8
import java.awt.geom.AffineTransform;
9
10
public class TransformationTest extends AppWindow {
11
    Path p, q, r, s;
12
    Rectangle a;
13
    RoundRectangle b;
14
    Ellipse c;
15
    Arc d;
16
17
    @Override
18
    protected void setup() {
19
        Color
20
                transparentRed = new Color(1f, 0f, 0f, 0.5f),
21
                transparentBlue = new Color(0f, 0f, 1f, 0.5f);
22
23
        a = new Rectangle(100, 50, 150, 100, getDrawingPanel());
24
        a.setFillColor(transparentRed);
25
        b = new RoundRectangle(350, 50, 150, 100, 25, 25, getDrawingPanel());
26
        b.setFillColor(transparentRed);
27
        c = new Ellipse(100, 250, 150, 100, getDrawingPanel());
28
        c.setFillColor(transparentRed);
29
        d = new Arc(350, 250, 150, 100, 117, 312, getDrawingPanel());
30
        d.setFillColor(transparentRed);
31
32
        p = a.getAsPath();
33
        p.setFillColor(transparentBlue);
34
        q = b.getAsPath();
35
        q.setFillColor(transparentBlue);
36
        r = c.getAsPath();
37
        r.setFillColor(transparentBlue);
38
        s = d.getAsPath();
39
        s.setFillColor(transparentBlue);
40
41
42
    }
43
44
    @Override
45
    protected void loop() {
46
        p.transform(AffineTransform.getRotateInstance(Math.PI / 36, 175, 100));
47
        q.transform(AffineTransform.getRotateInstance(Math.PI / 32, 425, 100));
48
        r.transform(AffineTransform.getRotateInstance(Math.PI / 28, 175, 300));
49
        s.transform(AffineTransform.getRotateInstance(Math.PI / 24, 425, 300));
50
        sleep(100);
51
    }
52
53
    public static void main(String[] args) {
54
        new TransformationTest();
55
    }
56
}
57