public GOut reclip(Coord ul, Coord sz) { GOut g = new GOut(this); g.tx = this.tx.add(ul); g.ul = new Coord(g.tx); Coord gbr = g.ul.add(sz), tbr = this.ul.add(this.sz); if (g.ul.x < this.ul.x) g.ul.x = this.ul.x; if (g.ul.y < this.ul.y) g.ul.y = this.ul.y; if (gbr.x > tbr.x) gbr.x = tbr.x; if (gbr.y > tbr.y) gbr.y = tbr.y; g.sz = gbr.sub(g.ul); return (g); }
/* Draw texture at c, clipping everything outside ul to ul + sz. */ public void image(Tex tex, Coord c, Coord ul, Coord sz) { if (tex == null) return; st.set(cur2d); ul = ul.add(this.tx); Coord br = ul.add(sz); if (ul.x < this.ul.x) ul.x = this.ul.x; if (ul.y < this.ul.y) ul.y = this.ul.y; if (br.x > this.ul.x + this.sz.x) br.x = this.ul.x + this.sz.x; if (br.y > this.ul.y + this.sz.y) br.y = this.ul.y + this.sz.y; tex.crender(this, c.add(this.tx), ul, br.sub(ul)); checkerr(); }
public void frect(Coord ul, Coord sz) { ul = tx.add(ul); Coord br = ul.add(sz); if (ul.x < this.ul.x) ul.x = this.ul.x; if (ul.y < this.ul.y) ul.y = this.ul.y; if (br.x > this.ul.x + this.sz.x) br.x = this.ul.x + this.sz.x; if (br.y > this.ul.y + this.sz.y) br.y = this.ul.y + this.sz.y; if ((ul.x >= br.x) || (ul.y >= br.y)) return; st.set(cur2d); apply(); gl.glBegin(GL2.GL_QUADS); gl.glVertex2i(ul.x, ul.y); gl.glVertex2i(br.x, ul.y); gl.glVertex2i(br.x, br.y); gl.glVertex2i(ul.x, br.y); gl.glEnd(); checkerr(); }
public void ftexrect(Coord ul, Coord sz, GLState s, float tl, float tt, float tr, float tb) { ul = tx.add(ul); Coord br = ul.add(sz); Coord ult = new Coord(0, 0); Coord brt = new Coord(sz); if (ul.x < this.ul.x) { ult.x += this.ul.x - ul.x; ul.x = this.ul.x; } if (ul.y < this.ul.y) { ult.y += this.ul.y - ul.y; ul.y = this.ul.y; } if (br.x > this.ul.x + this.sz.x) { brt.x -= br.x - (this.ul.x + this.sz.x); br.x = this.ul.x + this.sz.x; } if (br.y > this.ul.y + this.sz.y) { brt.y -= br.y - (this.ul.y + this.sz.y); br.y = this.ul.y + this.sz.y; } if ((ul.x >= br.x) || (ul.y >= br.y)) return; st.set(cur2d); state(s); apply(); float l = tl + ((tr - tl) * ((float) ult.x) / ((float) sz.x)); float t = tt + ((tb - tt) * ((float) ult.y) / ((float) sz.y)); float r = tl + ((tr - tl) * ((float) brt.x) / ((float) sz.x)); float b = tt + ((tb - tt) * ((float) brt.y) / ((float) sz.y)); gl.glBegin(GL2.GL_QUADS); gl.glTexCoord2f(l, b); gl.glVertex2i(ul.x, ul.y); gl.glTexCoord2f(r, b); gl.glVertex2i(br.x, ul.y); gl.glTexCoord2f(r, t); gl.glVertex2i(br.x, br.y); gl.glTexCoord2f(l, t); gl.glVertex2i(ul.x, br.y); gl.glEnd(); checkerr(); }
public void rimage(Tex tex, Coord c, Coord sz) { Coord cc = new Coord(); for (cc.y = c.y; cc.y < c.y + sz.y; cc.y += tex.sz().y) { for (cc.x = c.x; cc.x < c.x + sz.x; cc.x += tex.sz().x) image(tex, cc, c, sz); } }
public void rimagev(Tex tex, Coord c, int h) { Coord cc = new Coord(c); Coord sz = new Coord(tex.sz().x, h); for (; cc.y < c.y + h; cc.y += tex.sz().y) image(tex, cc, c, sz); }