summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/Listing2501.java
diff options
context:
space:
mode:
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Listing2501.java')
-rw-r--r--Master/Reference Architectures and Patterns/hjp5/examples/Listing2501.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/Listing2501.java b/Master/Reference Architectures and Patterns/hjp5/examples/Listing2501.java
new file mode 100644
index 0000000..3d034b7
--- /dev/null
+++ b/Master/Reference Architectures and Patterns/hjp5/examples/Listing2501.java
@@ -0,0 +1,56 @@
+/* Listing2501.java */
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class Listing2501
+extends Frame
+{
+ public static void main(String[] args)
+ {
+ Listing2501 wnd = new Listing2501();
+ }
+
+ public Listing2501()
+ {
+ super("Der Farbenkreis");
+ addWindowListener(new WindowClosingAdapter(true));
+ setSize(300,200);
+ setVisible(true);
+ }
+
+ public void paint(Graphics g)
+ {
+ int top = getInsets().top;
+ int left = getInsets().left;
+ int maxX = getSize().width-left-getInsets().right;
+ int maxY = getSize().height-top-getInsets().bottom;
+ Color col;
+ int[] arx = {130,160,190};
+ int[] ary = {60,110,60};
+ int[] arr = {50,50,50};
+ int[] arcol = {0,0,0};
+ boolean paintit;
+ int dx, dy;
+
+ for (int y = 0; y < maxY; ++y) {
+ for (int x = 0; x < maxX; ++x) {
+ paintit = false;
+ for (int i = 0; i < arcol.length; ++i) {
+ dx = x - arx[i];
+ dy = y - ary[i];
+ arcol[i] = 0;
+ if ((dx*dx+dy*dy) <= arr[i]*arr[i]) {
+ arcol[i] = 255;
+ paintit = true;
+ }
+ }
+ if (paintit) {
+ col = new Color(arcol[0],arcol[1],arcol[2]);
+ g.setColor(col);
+ g.drawLine(x+left,y+top,x+left+1,y+top+1);
+ }
+ }
+ }
+ }
+} \ No newline at end of file