Example #1
0
  /**
   * Reads the star color chart and loads them into a hash
   *
   * @param starColorChart
   * @param starColorMap
   */
  private static void ReadStarColorChart(
      final String starColorChart, final ArrayList<StarColorTuple> starColorMap) {
    int minColor = 0;
    int maxColor = 33000;

    Texture starColorImage = new Texture(VFile.getFileHandle(starColorChart));

    starColorImage.getTextureData().prepare();
    Pixmap pixelData = starColorImage.getTextureData().consumePixmap();

    for (int i = 1; i < starColorImage.getWidth(); i += 5) {
      Color color = new Color();
      Color.rgba8888ToColor(color, pixelData.getPixel(starColorImage.getWidth() - i, 0));
      color.a = 1.0F;

      StarColorTuple tuple =
          new StarColorTuple(
              (int)
                  ((float) (starColorImage.getWidth() - i)
                      / starColorImage.getWidth()
                      * (maxColor - minColor)),
              color);
      // System.err.println("added tuple: " + tuple.getTemperature() + " " +
      // tuple.getColor());
      starColorMap.add(tuple);
    }

    Color color = new Color();
    Color.rgba8888ToColor(color, pixelData.getPixel(starColorImage.getWidth(), 0));
    color.a = 1.0F;
    starColorMap.add(new StarColorTuple(Integer.MIN_VALUE, color));

    starColorImage.dispose();
  }
Example #2
0
  @Override
  public final void _render(SpriteBatch spriteBatch) {
    if (frozen) {
      // set shader
      float brightness = .5f / (freezeCounterMax / freezeCounter);
      spriteBatch.setShader(Shader.FREEZE_SHADER);
      spriteBatch.getShader().setUniformf("u_contrast", 1.1f);
      spriteBatch.getShader().setUniformf("u_brightness", brightness);

      // set color
      frozenColor.a = FROZEN_COLOR_START_ALPHA / (freezeCounterMax / freezeCounter);
      spriteBatch.setColor(frozenColor);

      // render
      doRender(spriteBatch);

      // reset shader
      spriteBatch.setShader(null);

      // reset color
      spriteBatch.setColor(Color.WHITE);
    } else {
      doRender(spriteBatch);
    }
  }
Example #3
0
  private void drawCullingRectangles(ShapeRenderer shapeRenderer, Color color) {
    for (BoundingBox br : boundingBoxes) {

      Rectangle r = br.rectangle;
      Rectangle cullingArea = getCullingArea(tmpRectangle, r, angleRad, position, scale);

      shapeRenderer.set(ShapeRenderer.ShapeType.Filled);

      Color fillColor = tmpColor.set(color);
      fillColor.a *= 0.25f;

      shapeRenderer.setColor(fillColor);

      shapeRenderer.rect(cullingArea.x, cullingArea.y, cullingArea.width, cullingArea.height);

      tmp.set(r.x, r.y).rotateRad(angleRad).add(position);
      tmp1.set(r.x + r.width, r.y).rotateRad(angleRad).add(position);
      tmp2.set(r.x + r.width, r.y + r.height).rotateRad(angleRad).add(position);
      tmp3.set(r.x, r.y + r.height).rotateRad(angleRad).add(position);

      shapeRenderer.set(ShapeRenderer.ShapeType.Line);
      shapeRenderer.setColor(color);

      shapeRenderer.line(tmp, tmp1);
      shapeRenderer.line(tmp1, tmp2);
      shapeRenderer.line(tmp2, tmp3);
      shapeRenderer.line(tmp3, tmp);
    }
  }
  private void drawFeatheredFullLine(
      Vector2 a, Vector2 b, float width, float feather, Color color) {
    checkMaxVerts(3 * 6);

    // Calculate the normal that defines the center rectangle
    norm.set(b);
    norm.sub(a);
    norm.rotate(90);
    norm.setLength(width / 2); // Scale to line width

    // Calculate the normal that defines feathering
    feath.set(norm);
    feath.setLength(feather / 2);

    zeroAlpha.set(color);
    zeroAlpha.a = 0;

    // ORDER OF RENDERING

    // 1                    2
    // top feather
    // 3                    4

    // center

    // 5                    6
    // bottom feather
    // 7                    8

    // Top feather
    tL.set(a).add(norm).add(feath);
    tR.set(b).add(norm).add(feath);
    bL.set(a).add(norm);
    bR.set(b).add(norm);

    // Draw it
    // Top feather  (1-2-3)
    uncheckedTriangle(tL.x, tL.y, tR.x, tR.y, bL.x, bL.y, zeroAlpha, zeroAlpha, color);
    uncheckedTriangle(tR.x, tR.y, bL.x, bL.y, bR.x, bR.y, zeroAlpha, color, color);

    // Center line
    tL.set(a).add(norm);
    tR.set(b).add(norm);
    bL.set(a).sub(norm);
    bR.set(b).sub(norm);

    // Draw it
    uncheckedTriangle(tL.x, tL.y, tR.x, tR.y, bL.x, bL.y, color, color, color);
    uncheckedTriangle(tR.x, tR.y, bL.x, bL.y, bR.x, bR.y, color, color, color);

    // Bottom feather
    tL.set(a).sub(norm);
    tR.set(b).sub(norm);
    bL.set(a).sub(norm).sub(feath);
    bR.set(b).sub(norm).sub(feath);

    // Draw it
    uncheckedTriangle(tL.x, tL.y, tR.x, tR.y, bL.x, bL.y, color, color, zeroAlpha);
    uncheckedTriangle(tR.x, tR.y, bL.x, bL.y, bR.x, bR.y, color, zeroAlpha, zeroAlpha);
  }
  @Override
  public void render() {
    red.a = (red.a + Gdx.graphics.getDeltaTime() * 0.1f) % 1;

    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    spriteBatch.begin();
    logoSprite.draw(spriteBatch);
    switch (renderMode) {
      case 0:
        font.getData().setScale(1);
        renderNormal("normal");
        break;
      case 1:
        font.getData().setScale(1);
        renderCached();
        break;
      case 2:
        font.getData().setScale(red.a + 0.5f);
        renderNormal("normal scaled");
        break;
      case 3:
        font.getData().setScale(1);
        renderCachedScaled();
        break;
    }
    spriteBatch.end();
  }
Example #6
0
  private void init(
      Criteria[] choiceCriteria,
      Criteria[][] choiceShortCriteria,
      String[][] choiceShorts,
      Criteria[][] choiceTextCriteria,
      String[][] choiceTexts,
      Criteria[][] proceedKeyCriteria,
      String[][] proceedKeys) {
    this.choiceCriteria = choiceCriteria;
    this.choiceShortCriteria = choiceShortCriteria;
    this.choiceShorts = choiceShorts;
    this.choiceTextCriteria = choiceTextCriteria;
    this.choiceTexts = choiceTexts;
    this.proceedKeyCriteria = proceedKeyCriteria;
    this.proceedKeys = proceedKeys;

    hasBeenSaid = false;

    madeChoice = false;
    choice = 0;
    font = new BitmapFont(Gdx.files.internal("main_text.fnt"));
    Color temp = character.speechColor;
    temp.a = 0.7f;
    font.setColor(temp);
    font.getData().setScale(1f);
  }
  /**
   * Everything calls this one. Draw an arc, most specific way.
   *
   * @param center
   * @param radInner
   * @param radOuter
   * @param fromDeg
   * @param toDeg
   * @param segs
   * @param innerCol
   * @param outerCol
   */
  public void drawPartialArc(
      Vector2 center,
      float radInner,
      float radOuter,
      float fromDeg,
      float toDeg,
      int segs,
      Color innerCol,
      Color outerCol) {
    setType(GL20.GL_TRIANGLE_STRIP);

    n_verts = (segs + 1) * 2 + 1;
    checkMaxVerts(n_verts);

    segs = (int) (segs * (toDeg - fromDeg) / 360f);
    if (segs < 5) { // Otherwise the rounding draws nothing
      segs = 5;
    }
    float d = (toDeg - fromDeg) / segs;

    tmpCol1.set(outerCol);
    tmpCol1.a = 0;
    a.set(CircleLogic.findPos(center, radOuter, fromDeg, 0f));
    putVertex(a.x, a.y, tmpCol1);
    putVertex(a.x, a.y, tmpCol1);

    for (int i = 0; i < segs + 1; i++) {
      if (toDeg < 359 && i == (segs)) { // set the alpha to 0 for nice smooth starts and ends.
        tmpCol1.set(outerCol);
        tmpCol1.a = 0;
        a.set(CircleLogic.findPos(center, radOuter, i * (d) + fromDeg, 0f));
        putVertex(a.x, a.y, tmpCol1);

        tmpCol1.set(innerCol);
        tmpCol1.a = 0;
        a.set(CircleLogic.findPos(center, radInner, i * (d) + fromDeg, 0f));
        putVertex(a.x, a.y, tmpCol1);
      } else {
        a.set(CircleLogic.findPos(center, radOuter, i * (d) + fromDeg, 0f));
        putVertex(a.x, a.y, outerCol);
        a.set(CircleLogic.findPos(center, radInner, i * (d) + fromDeg, 0f));
        putVertex(a.x, a.y, innerCol);
      }
    }
    putVertex(a.x, a.y, innerCol); // Prevent drawing again.
    putVertex(a.x, a.y, innerCol); // Prevent drawing again.
  }
Example #8
0
 @Override
 public void blend(Color source, Color dest, Color output) {
   output.r = (source.r == 0) ? 0 : 1 - (1 - dest.r) / source.r;
   output.g = (source.g == 0) ? 0 : 1 - (1 - dest.g) / source.g;
   output.b = (source.b == 0) ? 0 : 1 - (1 - dest.b) / source.b;
   output.a = dest.a;
   output.clamp();
 }
Example #9
0
 @Override
 public void blend(Color source, Color dest, Color output) {
   output.r = (dest.r == 1) ? 1 : source.r / (1 - dest.r);
   output.g = (dest.g == 1) ? 1 : source.g / (1 - dest.g);
   output.b = (dest.b == 1) ? 1 : source.b / (1 - dest.b);
   output.a = dest.a;
   output.clamp();
 }
Example #10
0
 @Override
 public void blend(Color source, Color dest, Color output) {
   output.r = (1 - ((1 - dest.r) * (1 - source.r)));
   output.g = (1 - ((1 - dest.g) * (1 - source.g)));
   output.b = (1 - ((1 - dest.b) * (1 - source.b)));
   output.a = dest.a;
   output.clamp();
 }
Example #11
0
 @Override
 public void blend(Color source, Color dest, Color output) {
   output.r = min(source.r, dest.r);
   output.g = min(source.g, dest.g);
   output.b = min(source.b, dest.b);
   output.a = dest.a;
   output.clamp();
 }
Example #12
0
 // TCOD_BKGND_OVERLAY
 @Override
 public void blend(Color source, Color dest, Color output) {
   output.r = source.r <= 0.5 ? 2 * (source.r) * dest.r : 1 - 2 * (1 - source.r) * (1 - dest.r);
   output.g = source.g <= 0.5 ? 2 * (source.g) * dest.g : 1 - 2 * (1 - source.g) * (1 - dest.g);
   output.b = source.b <= 0.5 ? 2 * (source.b) * dest.b : 1 - 2 * (1 - source.b) * (1 - dest.b);
   output.a = dest.a;
   output.clamp();
 }
Example #13
0
 // JCOD Extension
 @Override
 public void blend(Color source, Color dest, Color output) {
   output.r = source.r * source.a + dest.r * (1 - source.a);
   output.g = source.g * source.a + dest.g * (1 - source.a);
   output.b = source.b * source.a + dest.b * (1 - source.a);
   output.a = dest.a;
   output.clamp();
 }
Example #14
0
 @Override
 public void blend(Color source, Color dest, Color output) {
   // can't use set/add/sub methods, they clamp too soon
   output.r = source.r + dest.r - 1;
   output.g = source.g + dest.g - 1;
   output.b = source.b + dest.b - 1;
   output.a = dest.a;
   output.clamp();
 }
Example #15
0
 /**
  * @return the rendering color of this SpriteBatch. Manipulating the returned instance has no
  *     effect.
  */
 public Color getColor() {
   int intBits = NumberUtils.floatToIntColor(color);
   Color color = this.tempColor;
   color.r = (intBits & 0xff) / 255f;
   color.g = ((intBits >>> 8) & 0xff) / 255f;
   color.b = ((intBits >>> 16) & 0xff) / 255f;
   color.a = ((intBits >>> 24) & 0xff) / 255f;
   return color;
 }
Example #16
0
 /**
  * Returns the color of this font. Changing the returned color will have no affect, {@link
  * #setColor(Color)} or {@link #setColor(float, float, float, float)} must be used.
  */
 public Color getColor() {
   int intBits = Float.floatToRawIntBits(color);
   Color color = this.tempColor;
   color.r = (intBits & 0xff) / 255f;
   color.g = ((intBits >>> 8) & 0xff) / 255f;
   color.b = ((intBits >>> 16) & 0xff) / 255f;
   color.a = ((intBits >>> 24) & 0xff) / 255f;
   return color;
 }
Example #17
0
 public void freeze() {
   frozen = true;
   frozenColor.a = FROZEN_COLOR_START_ALPHA;
   freezeCounter = FREEZE_TIMER_DEF;
   if (mIceResistance > 0.0f) {
     freezeCounter *= (mIceResistance * -1) + 1;
   }
   freezeCounterMax = freezeCounter;
   velocityDump = 0.95f;
   velocity.y = 0;
 }
 public void drawMenuBoxSelected(Vector2 position, float menuWidth, float menuHeight) {
   // TODO probably a better way to do this
   Color orgColor =
       new Color(com.nerddaygames.rupert.games.Protect.managers.AssetsManager.menuBox.getColor());
   Color color =
       new Color(com.nerddaygames.rupert.games.Protect.managers.AssetsManager.menuBox.getColor());
   color.a = color.a / 2;
   batch.setColor(color);
   com.nerddaygames.rupert.games.Protect.managers.AssetsManager.menuBox.draw(
       batch, position.x, position.y, menuWidth, menuHeight);
   batch.setColor(orgColor);
 }
Example #19
0
  @Override
  public void draw(Batch batch, float alpha) {
    batchColor = batch.getColor();
    oldAlpha = batchColor.a;
    batchColor.a = this.alpha;
    batch.setColor(batchColor);

    batch.draw(
        TextureLibrary.getTexture(objectType),
        getX(),
        getY(),
        getOriginX(),
        getOriginY(),
        getWidth(),
        getHeight(),
        getScaleX(),
        getScaleY(),
        -getRotation());

    batchColor.a = oldAlpha;
    batch.setColor(batchColor);
  }
  public void update(float deltaTime) {
    if (livingTime <= 0) return;

    life += deltaTime;

    if (life > livingTime) {
      tipsFreeList.add(this);
      tipsActiveList.remove(this);
      return;
    }

    oringinX += velocity.x * deltaTime;
    oringinY += velocity.y * deltaTime;
    color.a = 1.0f - life / livingTime;
  }
Example #21
0
  @Override
  public Tint tween(Tint a, Tint b, float value) {

    final Interpolation linear = Interpolation.linear;

    final Color colorA = a.color;
    final Color colorB = b.color;

    color.r = linear.apply(colorA.r, colorB.r, value);
    color.g = linear.apply(colorA.g, colorB.g, value);
    color.b = linear.apply(colorA.b, colorB.b, value);
    color.a = linear.apply(colorA.a, colorB.a, value);

    return this;
  }
  public void drawCircle(Vector2 center, float rad, float feath, int segs, Color col) {
    if (segs < 3) {
      throw new IllegalArgumentException("Segs must be > 3");
    }

    if (rad == 0) {
      return;
    }

    drawCircle(center, rad, segs, col);

    tmpCol1.set(col);
    tmpCol1.a = 0;

    drawArc(center, rad, rad + feath, segs, col, tmpCol1);
  }
Example #23
0
  @Override
  public final void _update(float delta) {
    if (frozen) {
      velocity.x *= velocityDump;

      if (!deadByBullet) freezeCounter -= delta;
      if (freezeCounter <= 0) {
        frozen = false;
        freezeCounter = freezeCounterMax = 0;
        velocityDump = DEF_VEL_DUMP;
        frozenColor.a = FROZEN_COLOR_START_ALPHA;
      }
      if (deadByBullet) update(delta);
    } else {
      update(delta);
    }
    turned = false;
  }
Example #24
0
 private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
   in.defaultReadObject();
   // setName(in.readUTF());
   setX(in.readFloat());
   setY(in.readFloat());
   setWidth(in.readFloat());
   setHeight(in.readFloat());
   setOriginX(in.readFloat());
   setOriginY(in.readFloat());
   setScaleX(in.readFloat());
   setScaleY(in.readFloat());
   setRotation(in.readFloat());
   Color color = new Color();
   color.r = in.readFloat();
   color.g = in.readFloat();
   color.b = in.readFloat();
   color.a = in.readFloat();
   setColor(color);
 }
  public void drawSmoothPartialArc(
      Vector2 center,
      float radInner,
      float radOuter,
      float fromDeg,
      float toDeg,
      int segs,
      float feath,
      Color col) {
    tmpCol1.set(col);
    tmpCol1.a = 0;

    // Draw an center bit.
    drawPartialArc(center, radInner, radOuter, fromDeg, toDeg, segs, col, col);

    // Draw outer bit
    drawPartialArc(center, radOuter, radOuter + feath, fromDeg, toDeg, segs, col, tmpCol1);

    // Draw inner bit
    drawPartialArc(center, radInner - feath, radInner, fromDeg, toDeg, segs, tmpCol1, col);
  }
  public void drawLineShape(
      Vector2 center,
      int verts,
      float size,
      float lineWidth,
      float fadeWidth,
      float rotation,
      Color color) {
    setType(GL20.GL_TRIANGLE_STRIP);

    zeroAlpha.set(color);
    zeroAlpha.a = 0f;

    float innerPos = size - lineWidth / 2f, outerPos = size + lineWidth / 2f;
    drawLineShapePart(center, verts, innerPos, outerPos, rotation, color, color);

    float innerFadePosInner = innerPos - fadeWidth, innerFadePosOuter = innerPos;
    drawLineShapePart(
        center, verts, innerFadePosInner, innerFadePosOuter, rotation, zeroAlpha, color);

    float outerFadePosInner = outerPos, outerFadePosOuter = outerPos + fadeWidth;
    drawLineShapePart(
        center, verts, outerFadePosInner, outerFadePosOuter, rotation, color, zeroAlpha);
  }
Example #27
0
 /**
  * Converts HSV to RGB
  *
  * @param h hue 0-360
  * @param s saturation 0-100
  * @param v value 0-100
  * @param alpha 0-1
  * @return RGB values in LibGDX {@link Color} class
  */
 public static Color HSVtoRGB(float h, float s, float v, float alpha) {
   Color c = HSVtoRGB(h, s, v);
   c.a = alpha;
   return c;
 }
Example #28
0
 @Override
 public void blend(Color source, Color dest, Color output) {
   output.set(dest);
   output.mul(source);
   output.a = dest.a;
 }
Example #29
0
 // *back = TCOD_color_lerp(*back,col,(float)(alpha/255.0f));
 @Override
 public void blend(Color source, Color dest, Color output) {
   lerp(dest, source, source.a, output);
   output.a = dest.a;
   output.clamp();
 }
Example #30
0
  public void createWindow() {
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    TextButton closeButton = new TextButton("", skin, "close-toggle");

    Random random = new Random();

    dialog = new Window("Terminal", skin);
    dialog.setBounds(10 + random.nextInt(50), 100 + random.nextInt(50), 400, 200);
    dialog.setResizable(true);
    dialog.setKeepWithinStage(true);
    dialog
        .getTitleTable()
        .add(closeButton)
        .size(dialog.getPadTop() * 4 / 5, dialog.getPadTop() * 4 / 5)
        .padRight(dialog.getPadRight());
    dialog.left().top();
    dialog.setResizeBorder(5);
    dialog.padRight(0);
    dialog.padBottom(1);

    SimpleDateFormat simpleDateformat = new SimpleDateFormat("E");
    String day = simpleDateformat.format(new Date());
    String month = new SimpleDateFormat("MMM").format(Calendar.getInstance().getTime());
    int date = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
    int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
    int min = Calendar.getInstance().get(Calendar.MINUTE);
    int sec = Calendar.getInstance().get(Calendar.SECOND);
    String textTest =
        "Last login: "******" "
            + month
            + " "
            + String.format("%02d", date)
            + " "
            + String.format("%02d", hour)
            + ":"
            + String.format("%02d", min)
            + ":"
            + String.format("%02d", sec);

    cld.textHistory = textTest;
    consoleDialog = new Label(cld.textHistory, skin);
    consoleDialog.setWrap(true);
    consoleDialog.setAlignment(Align.topLeft, Align.topLeft);

    consoleArrow =
        new Label(cld.parser.getInputPrefix(), new LabelStyle(skin.get(LabelStyle.class)));
    consoleField = new TextField("", skin);
    consoleField.setFocusTraversal(false);
    Color colour = Color.ORANGE;
    colour.a = 0.8f;
    consoleField.getStyle().cursor = skin.newDrawable("white", colour);
    consoleField.getStyle().cursor.setMinWidth(10);
    consoleField.setBlinkTime(0.6f);

    Table scrollTable = new Table();
    scrollTable.top();
    scrollTable.add(consoleDialog).colspan(2).growX().fill().left().top();
    scrollTable.row();
    scrollTable.add(consoleArrow).left().top();
    scrollTable.add(consoleField).expand(true, false).fill().left().top();
    scrollTable.padBottom(1);

    consoleScroll = new ScrollPane(scrollTable, skin);
    consoleScroll.setFadeScrollBars(false);
    consoleScroll.setVariableSizeKnobs(true);
    consoleScroll.setFlickScroll(false);
    dialog.add(consoleScroll).fill().expand();
    this.stage.addActor(dialog);

    closeButton.addListener(new CLICloseButtonListener(this, dialog));

    setKeyboardFocus();
  }