/** * Multiply all components with the given factor. * * @param factor factor to multiply * @return new Color with factor applied */ @Nonnull public Alpha multiply(final float factor) { return new Alpha(alpha * factor); }
public Alpha(@Nonnull final String color) { this.alpha = getAFromString(color); }
/** * helper to get alpha from a string value. * * @param color color string * @return alpha value */ private float getAFromString(@Nonnull final String color) { if (isShortMode(color)) { return (Integer.valueOf(color.substring(1, 2), HEX_BASE) * SCALE_SHORT_MODE) / MAX_INT_VALUE; } else { return Integer.valueOf(color.substring(1, 3), HEX_BASE) / MAX_INT_VALUE; } }
@Override public void execute( @Nonnull final Element element, final float normalizedTime, @Nullable final Falloff falloff, @Nonnull final NiftyRenderEngine r) { if (interpolator != null) { r.setColorAlpha(interpolator.getValue(normalizedTime)); } else { Alpha a = start.linear(end, normalizedTime); r.setColorAlpha(a.getAlpha()); } }
/** * Multiply all components with the given factor. * * @param factor factor to multiply * @return new Color with factor applied * @deprecated Typo in function name TODO: Remove */ @Deprecated @Nonnull public Alpha mutiply(final float factor) { return multiply(factor); }
/** * linear interpolate between this color and the given color. * * @param end end color * @param t t in [0,1] * @return linear interpolated color */ @Nonnull public Alpha linear(@Nonnull final Alpha end, final float t) { return new Alpha(this.alpha + t * (end.alpha - this.alpha)); }
@Override public void activate( @Nonnull final Nifty nifty, @Nonnull final Element element, @Nonnull final EffectProperties parameter) { // startColor and endColor (only alpha component used) are the old version of this // and are kept here only for backward compatibility. The current attributes are "start" and "end" alpha values. if (parameter.getProperty("startColor") != null) { start = new Alpha(new Color(parameter.getProperty("startColor", "#000000ff")).getAlpha()); } if (parameter.getProperty("endColor") != null) { end = new Alpha(new Color(parameter.getProperty("endColor", "#ffffffff")).getAlpha()); } if (parameter.getProperty("start") != null) { start = new Alpha(parameter.getProperty("start")); } if (parameter.getProperty("end") != null) { end = new Alpha(parameter.getProperty("end")); } interpolator = parameter.getInterpolator(); }
@Override public void activate( @Nonnull final Nifty nifty, @Nonnull final Element element, @Nonnull final EffectProperties parameter) { Screen screen = nifty.getCurrentScreen(); if (screen == null) { log.severe("Can't activate effect while there is no active current screen."); return; } image = nifty.getRenderEngine().createImage(screen, parameter.getProperty("filename"), false); if (image == null) { log.severe("Image not found, image overlay effect will not work."); return; } String areaProviderProperty = ImageModeHelper.getAreaProviderProperty(parameter); String renderStrategyProperty = ImageModeHelper.getRenderStrategyProperty(parameter); if ((areaProviderProperty != null) || (renderStrategyProperty != null)) { image.setImageMode(ImageModeFactory.getSharedInstance().createImageMode(areaProviderProperty, renderStrategyProperty)); } alpha = new Alpha(parameter.getProperty("alpha", "#f")); inset = new SizeValue(parameter.getProperty("inset", "0px")); width = new SizeValue(parameter.getProperty("width", element.getWidth() + "px")); height = new SizeValue(parameter.getProperty("height", element.getHeight() + "px")); center = Boolean.valueOf(parameter.getProperty("center", "false")); hideIfNotEnoughSpace = Boolean.valueOf(parameter.getProperty("hideIfNotEnoughSpace", "false")); activeBeforeStartDelay = Boolean.valueOf(parameter.getProperty("activeBeforeStartDelay", "false")); }