List of usage examples for com.badlogic.gdx.graphics Color mul
public Color mul(float value)
From source file:com.kotcrab.vis.ui.widget.LinkLabel.java
License:Apache License
@Override public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); Drawable underline = style.underline; if (underline != null && clickListener.isOver()) { Color color = tempColor.set(getColor()); color.a *= parentAlpha;/*from w w w .j a va 2 s. c om*/ if (style.fontColor != null) color.mul(style.fontColor); batch.setColor(color); underline.draw(batch, getX(), getY(), getWidth(), 1); } }
From source file:com.lyeeedar.Roguelike3D.Graphics.Lights.LightManager.java
License:Open Source License
private Color calculateLight(Vector3 l_vector, Color l_colour, float l_attenuation, float l_power, Vector3 n_dir) {/*from w ww .j a v a2s . c om*/ float distance = l_vector.len(); Vector3 l_dir = l_vector.cpy().div(distance); float NdotL = n_dir.dot(l_dir); float intensity = MathUtils.clamp(NdotL, 0.0f, 1.0f); float attenuation = 1.0f; if (l_attenuation != 0) attenuation /= (l_attenuation * distance + l_attenuation / 10 * distance * distance); return l_colour.mul(intensity).mul(l_power).mul(attenuation); }
From source file:com.ray3k.skincomposer.utils.Utils.java
License:Open Source License
/** * Does not dispose pixmap/*from w ww . j a va2 s. c om*/ * @param pixmap * @return */ public static Pixmap tintPixmap(Pixmap pixmap, Color color) { Color tempColor = new Color(); for (int y = 0; y < pixmap.getHeight(); y++) { for (int x = 0; x < pixmap.getWidth(); x++) { tempColor.set(pixmap.getPixel(x, y)); float a = tempColor.a; tempColor.mul(color); tempColor.a = a; pixmap.setColor(tempColor); pixmap.drawPixel(x, y); tempColor.set(pixmap.getPixel(x, y)); } } return pixmap; }
From source file:de.bioviz.ui.DrawableField.java
License:Open Source License
/** * Calculates the current color based on the parent circuit's * displayOptions./*from w w w . j a va 2s . co m*/ * * @return the field's color. */ @Override public Color getColor() { /** * This value stores the amount of colors being overlaid in the process * of computing the color. This is currently required to calculate the * average value of all colors at the end of the process (e.g. if three * different colors are being added, the final result needs to be * divided by three). */ int colorOverlayCount = 0; /* We need to create a copy of the FIELD_EMPTY_COLOR as that value is final and thus can not be modified. If that value is unchangeable, the cells all stay white */ de.bioviz.ui.Color result = new de.bioviz.ui.Color(Color.BLACK); if (getField().isBlocked(getParentAssay().getCurrentTime())) { result.add(Colors.BLOCKED_COLOR); colorOverlayCount++; } netColoring(); colorOverlayCount += cellUsageColoring(result); colorOverlayCount += inteferenceRegionColoring(result); colorOverlayCount += reachableRegionColoring(result); /** * Here we highlight cells based on their actuation value */ int t = getParentAssay().getCurrentTime(); if (getOption(Actuations)) { Actuation act = field.getActuation(t); switch (act) { case ON: result.add(Colors.ACTUATION_ON_COLOR); break; case OFF: result.add(Colors.ACTUATION_OFF_COLOR); break; case DONTCARE: default: result.add(Colors.ACTUATION_DONTCARE_COLOR); } ++colorOverlayCount; } if (colorOverlayCount == 0) { colorOverlayCount += typeColoring(result, t); } if (getOption(Adjacency)) { final Stream<FluidicConstraintViolation> violations = getParentAssay().getData() .getAdjacentActivations().stream(); if (violations.anyMatch(v -> v.containsField(this.field))) { result.add(Colors.ADJACENT_ACTIVATION_COLOR); } } if (colorOverlayCount > 0) { result.mul(1f / ((float) colorOverlayCount)); result.clamp(); } else { result = new de.bioviz.ui.Color(Colors.FIELD_COLOR); } if (this.isHovered()) { result.add(Colors.HOVER_DIFF_COLOR); } if (getOption(HighlightAnnotatedFields) && field.hasAnnotations()) { result = new de.bioviz.ui.Color(Color.VIOLET); } return result.buildGdxColor().cpy(); }
From source file:de.bioviz.ui.DrawableField.java
License:Open Source License
/** * Colors based on the interference region. * * @param result/*from ww w .java2s. co m*/ * The color that results from this method call. * @return The amount of color overlays produced by this method. */ private int inteferenceRegionColoring(final de.bioviz.ui.Color result) { int colorOverlayCount = 0; boolean isBlocked = getField().isBlocked(getParentAssay().getCurrentTime()); /** Colours the interference region **/ if (getOption(InterferenceRegion)) { int amountOfInterferenceRegions = 0; final Set<Droplet> dropsSet = getParentAssay().getData().getDroplets(); ArrayList<Droplet> drops = dropsSet.stream().filter(d -> isPartOfInterferenceRegion(d)) .collect(Collectors.toCollection(ArrayList<Droplet>::new)); for (int i = 0; i < drops.size(); ++i) { boolean interferenceViolation = false; for (int j = i + 1; j < drops.size(); j++) { final Droplet drop1 = drops.get(i); final Droplet drop2 = drops.get(j); boolean sameNet = getParentAssay().getData().sameNet(drop1, drop2); if (!sameNet && !isBlocked) { result.add(Colors.INTERFERENCE_REGION_OVERLAP_COLOR); ++colorOverlayCount; interferenceViolation = true; } } /* We only increase the amount of interference regions if no violation took place. This makes sense as a violation is handled differently. */ if (!interferenceViolation) { ++amountOfInterferenceRegions; } } if (amountOfInterferenceRegions > 0 && !isBlocked) { float scale = (float) Math.sqrt(amountOfInterferenceRegions); Color c = new Color(Colors.INTERFERENCE_REGION_COLOR); result.add(c.mul(scale)); ++colorOverlayCount; } } return colorOverlayCount; }
From source file:de.longri.cachebox3.gui.widgets.ScrollLabel.java
License:Open Source License
@Override public void draw(Batch batch, float parentAlpha) { BitmapFontCache cache = super.getBitmapFontCache(); validate();//from w w w . j a va2 s.co m Color color = tempColor.set(getColor()); color.a *= parentAlpha; if (style.background != null) { batch.setColor(color.r, color.g, color.b, color.a); style.background.draw(batch, getX(), getY(), getWidth(), getHeight()); } if (style.fontColor != null) color.mul(style.fontColor); cache.tint(color); cache.setPosition(getX() + scrollPosition, getY()); getStage().calculateScissors(localRec, scissorRec); ScissorStack.pushScissors(scissorRec); cache.draw(batch); batch.flush(); try { ScissorStack.popScissors(); } catch (Exception e) { } }