Search in sources :

Example 1 with Tint

use of playn.core.Tint in project playn by threerings.

the class AbstractSurfaceGL method fillRect.

@Override
public Surface fillRect(float x, float y, float width, float height) {
    bindFramebuffer();
    GLShader shader = ctx.quadShader(this.shader);
    if (fillPattern != null) {
        int tex = fillPattern.ensureTexture();
        if (tex > 0) {
            shader.prepareTexture(tex, tint);
            float tw = fillPattern.width(), th = fillPattern.height(), r = x + width, b = y + height;
            shader.addQuad(topTransform(), x, y, x + width, y + height, x / tw, y / th, r / tw, b / th);
        }
    } else {
        int tex = ctx.fillImage().ensureTexture();
        shader.prepareTexture(tex, Tint.combine(fillColor, tint));
        shader.addQuad(topTransform(), x, y, x + width, y + height, 0, 0, 1, 1);
    }
    return this;
}
Also used : Tint(playn.core.Tint)

Example 2 with Tint

use of playn.core.Tint in project playn by threerings.

the class AbstractSurfaceGL method drawLine.

@Override
public Surface drawLine(float x0, float y0, float x1, float y1, float width) {
    bindFramebuffer();
    // swap the line end points if x1 is less than x0
    if (x1 < x0) {
        float temp = x0;
        x0 = x1;
        x1 = temp;
        temp = y0;
        y0 = y1;
        y1 = temp;
    }
    float dx = x1 - x0, dy = y1 - y0;
    float length = FloatMath.sqrt(dx * dx + dy * dy);
    float wx = dx * (width / 2) / length;
    float wy = dy * (width / 2) / length;
    InternalTransform l = ctx.createTransform();
    l.setRotation(FloatMath.atan2(dy, dx));
    l.setTranslation(x0 + wy, y0 - wx);
    l.preConcatenate(topTransform());
    GLShader shader = ctx.quadShader(this.shader);
    if (fillPattern != null) {
        int tex = fillPattern.ensureTexture();
        if (tex > 0) {
            shader.prepareTexture(tex, tint);
            shader.addQuad(l, 0, 0, length, width, 0, 0, length / fillPattern.width(), width / fillPattern.height());
        }
    } else {
        int tex = ctx.fillImage().ensureTexture();
        shader.prepareTexture(tex, Tint.combine(fillColor, tint));
        shader.addQuad(l, 0, 0, length, width, 0, 0, 1, 1);
    }
    return this;
}
Also used : InternalTransform(playn.core.InternalTransform) Tint(playn.core.Tint)

Example 3 with Tint

use of playn.core.Tint in project playn by threerings.

the class AbstractSurfaceGL method setAlpha.

@Override
public Surface setAlpha(float alpha) {
    int ialpha = (int) (0xFF * MathUtil.clamp(alpha, 0, 1));
    this.tint = (ialpha << 24) | (tint & 0xFFFFFF);
    return this;
}
Also used : Tint(playn.core.Tint)

Example 4 with Tint

use of playn.core.Tint in project playn by threerings.

the class AbstractSurfaceGL method fillTriangles.

@Override
public Surface fillTriangles(float[] xys, float[] sxys, int xysOffset, int xysLen, int[] indices, int indicesOffset, int indicesLen, int indexBase) {
    bindFramebuffer();
    if (fillPattern == null)
        throw new IllegalStateException("No fill pattern currently set");
    int tex = fillPattern.ensureTexture();
    if (tex > 0) {
        GLShader shader = ctx.trisShader(this.shader).prepareTexture(tex, tint);
        shader.addTriangles(topTransform(), xys, sxys, xysOffset, xysLen, indices, indicesOffset, indicesLen, indexBase);
    }
    return this;
}
Also used : Tint(playn.core.Tint)

Aggregations

Tint (playn.core.Tint)4 InternalTransform (playn.core.InternalTransform)1