use of com.bitwig.extension.api.Color in project DrivenByMoss by git-moss.
the class ColorSettingImpl method addValueObserver.
/**
* {@inheritDoc}
*/
@Override
public void addValueObserver(final IValueObserver<ColorEx> observer) {
this.colorValue.addValueObserver((red, green, blue) -> observer.update(new ColorEx(red, green, blue)));
// Directly fire the current value
final Color color = this.colorValue.get();
observer.update(new ColorEx(color.getRed(), color.getGreen(), color.getBlue()));
}
use of com.bitwig.extension.api.Color in project DrivenByMoss by git-moss.
the class HwSurfaceFactoryImpl method createLight.
/**
* {@inheritDoc}
*/
@Override
public IHwLight createLight(final int surfaceID, final OutputID outputID, final Supplier<ColorEx> supplier, final Consumer<ColorEx> sendValueConsumer) {
this.lightCounter++;
final String id = createID(surfaceID, outputID == null ? "LIGHT" + this.lightCounter : outputID.name());
final MultiStateHardwareLight hardwareLight = this.hardwareSurface.createMultiStateHardwareLight(id);
final Supplier<InternalHardwareLightState> valueSupplier = () -> new RawColorLightState(supplier.get());
final Consumer<InternalHardwareLightState> hardwareUpdater = state -> {
final HardwareLightVisualState visualState = state == null ? null : state.getVisualState();
final Color c = visualState == null ? Color.blackColor() : visualState.getColor();
sendValueConsumer.accept(new ColorEx(c.getRed(), c.getGreen(), c.getBlue()));
};
return new HwLightImpl(this.host, hardwareLight, valueSupplier, hardwareUpdater);
}
use of com.bitwig.extension.api.Color in project DrivenByMoss by git-moss.
the class RawColorLightState method getVisualState.
/**
* {@inheritDoc}}
*/
@Override
public HardwareLightVisualState getVisualState() {
final Color color = Color.fromRGB(this.colorState.getRed(), this.colorState.getGreen(), this.colorState.getBlue());
final ColorEx contrastColorEx = ColorEx.calcContrastColor(this.colorState);
final Color contrastColor = Color.fromRGB(contrastColorEx.getRed(), contrastColorEx.getGreen(), contrastColorEx.getBlue());
return HardwareLightVisualState.createForColor(color, contrastColor);
}
use of com.bitwig.extension.api.Color in project DrivenByMoss by git-moss.
the class EncodedColorLightState method getVisualState.
/**
* {@inheritDoc}}
*/
@Override
public HardwareLightVisualState getVisualState() {
if (this.encodedColorState == -1)
return HardwareLightVisualState.createForColor(Color.blackColor(), Color.whiteColor());
final int colorIndex = this.encodedColorState & 0xFF;
final int blinkColorIndex = this.encodedColorState >> 8 & 0xFF;
final boolean blinkFast = (this.encodedColorState >> 16 & 1) > 0;
final ColorEx colorEx = this.stateToColorFunction.apply(colorIndex);
final Color color = Color.fromRGB(colorEx.getRed(), colorEx.getGreen(), colorEx.getBlue());
final ColorEx contrastColorEx = ColorEx.calcContrastColor(colorEx);
final Color contrastColor = Color.fromRGB(contrastColorEx.getRed(), contrastColorEx.getGreen(), contrastColorEx.getBlue());
if (blinkColorIndex <= 0 || blinkColorIndex >= 128)
return HardwareLightVisualState.createForColor(color, contrastColor);
final ColorEx blinkColorEx = this.stateToColorFunction.apply(blinkColorIndex);
final Color blinkColor = Color.fromRGB(blinkColorEx.getRed(), blinkColorEx.getGreen(), blinkColorEx.getBlue());
final ColorEx contrastBlinkColorEx = ColorEx.calcContrastColor(blinkColorEx);
final Color contrastBlinkColor = Color.fromRGB(contrastBlinkColorEx.getRed(), contrastBlinkColorEx.getGreen(), contrastBlinkColorEx.getBlue());
final double blinkTimeInSec = blinkFast ? 0.5 : 1;
return HardwareLightVisualState.createBlinking(blinkColor, color, contrastBlinkColor, contrastColor, blinkTimeInSec, blinkTimeInSec);
}
Aggregations