-
-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DSL] Expose ColorUtil methods to DSL rules (#3749)
Fix #3743 Signed-off-by: Laurent Garnier <[email protected]>
- Loading branch information
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...les/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/CoreUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Copyright (c) 2010-2023 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.core.model.script.actions; | ||
|
||
import org.openhab.core.library.types.HSBType; | ||
import org.openhab.core.library.types.PercentType; | ||
import org.openhab.core.util.ColorUtil; | ||
import org.openhab.core.util.ColorUtil.Gamut; | ||
|
||
/** | ||
* This class provides static methods mapping methods from package org.openhab.core.util | ||
* | ||
* @author Laurent Garnier - Initial contribution | ||
*/ | ||
public class CoreUtil { | ||
|
||
public static int[] hsbToRgb(HSBType hsb) { | ||
return ColorUtil.hsbToRgb(hsb); | ||
} | ||
|
||
public static PercentType[] hsbToRgbPercent(HSBType hsb) { | ||
return ColorUtil.hsbToRgbPercent(hsb); | ||
} | ||
|
||
public static int hsbTosRgb(HSBType hsb) { | ||
return ColorUtil.hsbTosRgb(hsb); | ||
} | ||
|
||
public static double[] hsbToXY(HSBType hsb) { | ||
return ColorUtil.hsbToXY(hsb); | ||
} | ||
|
||
public static double[] hsbToXY(HSBType hsb, double[] gamutR, double[] gamutG, double[] gamutB) { | ||
Gamut gamut = new Gamut(gamutR, gamutG, gamutB); | ||
return ColorUtil.hsbToXY(hsb, gamut); | ||
} | ||
|
||
public static HSBType rgbToHsb(int[] rgb) throws IllegalArgumentException { | ||
return ColorUtil.rgbToHsb(rgb); | ||
} | ||
|
||
public static HSBType rgbToHsb(PercentType[] rgb) throws IllegalArgumentException { | ||
return ColorUtil.rgbToHsb(rgb); | ||
} | ||
|
||
public static HSBType xyToHsb(double[] xy) throws IllegalArgumentException { | ||
return ColorUtil.xyToHsb(xy); | ||
} | ||
|
||
public static HSBType xyToHsb(double[] xy, double[] gamutR, double[] gamutG, double[] gamutB) | ||
throws IllegalArgumentException { | ||
Gamut gamut = new Gamut(gamutR, gamutG, gamutB); | ||
return ColorUtil.xyToHsb(xy, gamut); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters