diff --git a/src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java b/src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java index 63a59acbae228ef2b0fa20459384fd037968d471..2fa8d080eb0a378cfd2c0ef01e8b6fcc050edfae 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