From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../hjp5/examples/Listing2501.java | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Master/Reference Architectures and Patterns/hjp5/examples/Listing2501.java (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Listing2501.java') 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 -- cgit v1.2.3