Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Simulator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
letsgoING
ArduBlock Source
Simulator
Commits
575c861f
Commit
575c861f
authored
Oct 21, 2020
by
Lucas Stratmann
Browse files
Options
Downloads
Patches
Plain Diff
adjusted RGB behavior
parent
2f1a5d1a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java
+15
-2
15 additions, 2 deletions
src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java
with
15 additions
and
2 deletions
src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java
+
15
−
2
View file @
575c861f
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment