@Override public float height() { if (heightSet) return height; assert img != null : "Image has not yet been set"; return img.height(); }
/** * Draws this image with the supplied transform in the specified target dimensions. */ void draw(GLShader shader, InternalTransform xform, int tint, float dx, float dy, float dw, float dh) { draw(shader, xform, tint, dx, dy, dw, dh, 0, 0, (repeatX ? dw : width()), (repeatY ? dh : height())); }
/** * Draws this image with the supplied transform, and source and target dimensions. */ void draw(GLShader shader, InternalTransform xform, int tint, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { float texWidth = width(), texHeight = height(); drawImpl(shader, xform, ensureTexture(), tint, dx, dy, dw, dh, sx / texWidth, sy / texHeight, (sx + sw) / texWidth, (sy + sh) / texHeight); }
@Override void draw(GLShader shader, InternalTransform xform, int tint, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { if (repeatX || repeatY) { // if we're repeating, then we have our own texture and want to draw it normally super.draw(shader, xform, tint, dx, dy, dw, dh, sx, sy, sw, sh); } else { float texWidth = (tex > 0) ? width : parent.width(); float texHeight = (tex > 0) ? height : parent.height(); sx += x(); sy += y(); parent.drawImpl(shader, xform, ensureTexture(), tint, dx, dy, dw, dh, sx / texWidth, sy / texHeight, (sx + sw) / texWidth, (sy + sh) / texHeight); } }
@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; }
@Override public Surface fillTriangles(float[] xys, int xysOffset, int xysLen, int[] indices, int indicesOffset, int indicesLen, int indexBase) { bindFramebuffer(); GLShader shader = ctx.trisShader(this.shader); if (fillPattern != null) { int tex = fillPattern.ensureTexture(); if (tex > 0) { shader.prepareTexture(tex, tint); shader.addTriangles(topTransform(), xys, xysOffset, xysLen, fillPattern.width(), fillPattern.height(), indices, indicesOffset, indicesLen, indexBase); } } else { int tex = ctx.fillImage().ensureTexture(); shader.prepareTexture(tex, Tint.combine(fillColor, tint)); shader.addTriangles(topTransform(), xys, xysOffset, xysLen, 1, 1, indices, indicesOffset, indicesLen, indexBase); } return this; }
shader.prepareTexture(tex, tint); shader.addQuad(l, 0, 0, length, width, 0, 0, length/fillPattern.width(), width/fillPattern.height());
float tw = parent.width(), th = parent.height(); float sl = this.x, st = this.y, sr = sl + this.width, sb = st + this.height; GLShader shader = ctx.quadShader(null).prepareTexture(tex, Tint.NOOP_TINT);