Search in sources :

Example 1 with InternalTransform

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

the class LayerCanvas method transform.

protected void transform(Canvas canvas) {
    canvas.translate(originX, originY);
    InternalTransform transform = (InternalTransform) transform();
    canvas.transform(transform.m00(), transform.m01(), transform.m10(), transform.m11(), transform.tx() - originX, transform.ty() - originY);
    canvas.translate(-originX, -originY);
}
Also used : InternalTransform(playn.core.InternalTransform)

Example 2 with InternalTransform

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

the class ImmediateLayerGL method paint.

@Override
public void paint(InternalTransform curTransform, int curTint, GLShader curShader) {
    if (!visible())
        return;
    InternalTransform xform = localTransform(curTransform);
    surface.topTransform().set(xform);
    if (tint != Tint.NOOP_TINT)
        curTint = Tint.combine(curTint, tint);
    surface.setTint(curTint);
    surface.setShader((shader == null) ? curShader : shader);
    render(xform);
    surface.setShader(null);
// TODO: restore tint?
}
Also used : InternalTransform(playn.core.InternalTransform)

Example 3 with InternalTransform

use of playn.core.InternalTransform 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)

Aggregations

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