Skip to content
Snippets Groups Projects
Commit 575c861f authored by Lucas Stratmann's avatar Lucas Stratmann
Browse files

adjusted RGB behavior

parent 2f1a5d1a
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,7 @@ import javax.swing.JLabel; ...@@ -15,6 +15,7 @@ import javax.swing.JLabel;
import tec.letsgoing.ardublock.simulator.arduino.Arduino; import tec.letsgoing.ardublock.simulator.arduino.Arduino;
import tec.letsgoing.ardublock.simulator.arduino.Pin; import tec.letsgoing.ardublock.simulator.arduino.Pin;
import tec.letsgoing.ardublock.simulator.simcode.datatypes.SimTypeInt;
/** /**
* Modul mit einer RGB LED * Modul mit einer RGB LED
...@@ -43,8 +44,15 @@ public class RGB extends Modul { ...@@ -43,8 +44,15 @@ public class RGB extends Modul {
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
Graphics2D ga = (Graphics2D) g; Graphics2D ga = (Graphics2D) g;
int transparancy = (int) (Math.max(redValue, Math.max(greenValue, blueValue)) * 0.8); int transparancy = (int) (Math.max(redValue, Math.max(greenValue, blueValue)) * 0.9);
ga.setPaint(new Color(redValue, greenValue, blueValue, transparancy)); 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); ga.fillOval(0, 0, 73, 73);
} }
...@@ -89,6 +97,11 @@ public class RGB extends Modul { ...@@ -89,6 +97,11 @@ public class RGB extends Modul {
return true; 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 * Funktion, welche die Positionen der Modulpins berechnet (in Pixeln für das
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment