From 575c861f1d48bc3a540db597b7b4865f39b3c252 Mon Sep 17 00:00:00 2001
From: Lucas Stratmann <lucas.stratmann@student.reutlingen-university.de>
Date: Wed, 21 Oct 2020 13:26:15 +0200
Subject: [PATCH] adjusted RGB behavior

---
 .../ardublock/simulator/view/modules/RGB.java   | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java b/src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java
index 63a59ac..2fa8d08 100644
--- a/src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java
+++ b/src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java
@@ -15,6 +15,7 @@ import javax.swing.JLabel;
 
 import tec.letsgoing.ardublock.simulator.arduino.Arduino;
 import tec.letsgoing.ardublock.simulator.arduino.Pin;
+import tec.letsgoing.ardublock.simulator.simcode.datatypes.SimTypeInt;
 
 /**
  * Modul mit einer RGB LED
@@ -43,8 +44,15 @@ public class RGB extends Modul {
 			@Override
 			public void paintComponent(Graphics g) {
 				Graphics2D ga = (Graphics2D) g;
-				int transparancy = (int) (Math.max(redValue, Math.max(greenValue, blueValue)) * 0.8);
-				ga.setPaint(new Color(redValue, greenValue, blueValue, transparancy));
+				int transparancy = (int) (Math.max(redValue, Math.max(greenValue, blueValue)) * 0.9);
+				int tredValue=0,tgreenValue=0,tblueValue=0;
+				if (transparancy!=0) {
+					if(redValue>0)tredValue=map(redValue);
+					if(greenValue>0)tgreenValue=map(greenValue);
+					if(blueValue>0)tblueValue=map(blueValue);
+				}
+				System.out.println(tredValue+" "+ tgreenValue+" "+ tblueValue+" "+ transparancy);
+				ga.setPaint(new Color(tredValue, tgreenValue, tblueValue, transparancy));
 				ga.fillOval(0, 0, 73, 73);
 			}
 
@@ -89,6 +97,11 @@ public class RGB extends Modul {
 
 		return true;
 	}
+	public int map(int v) {
+		float vL=0,vH=255,tL=200,tH=255;
+		return (int) (((v - vL) / (vH - vL)) * (tH - tL) + tL);
+	}
+	
 
 	/**
 	 * Funktion, welche die Positionen der Modulpins berechnet (in Pixeln für das
-- 
GitLab