Mirroring a Color Question
in
Programming Questions
•
2 years ago
Hi, i'm trying to make an function that "mirror" a color;
(example, if user give)
I make this, but with some debug and visual verification, i verifyed that this is not best approach...
Anyone can suggest other ways to mirroring a reference Color?
Thanks
(example, if user give)
I make this, but with some debug and visual verification, i verifyed that this is not best approach...
Copy code
- private static Color mirrorColors(Color bkg, int whichWay) {
- // TODO Auto-generated method stub
- int rR = bkg.getRed();
- int gG = bkg.getGreen();
- int bB = bkg.getBlue();
- int r, g, b;
- switch (whichWay) {
- case colors.MIRROR_SIMPLE:
- r = rR>=127?rR-127:rR+127;
- g = gG>=127?gG-127:gG+127;
- b = bB>=127?bB-127:bB+127;
- return new Color(r,g,b);
- case colors.MIRROR_EXP:
- r = (int) (rR>=127?rR-Math.pow(rR, 0.5):rR+Math.pow(rR, 0.5));
- g = (int) (gG>=127?rR-Math.pow(gG, 0.5):gG+Math.pow(gG, 0.5));
- b = (int) (bB>=127?rR-Math.pow(bB, 0.5):bB+Math.pow(bB, 0.5));
- return new Color(r,g,b);
- default:
- r = rR>=127?rR-127:rR+127;
- g = gG>=127?gG-127:gG+127;
- b = bB>=127?bB-127:bB+127;
- return new Color(r,g,b);
- }
- }
Anyone can suggest other ways to mirroring a reference Color?
Thanks
1