public Vert(int x, int y, PicV p, float borderPercent) { uv = new Vector4(halfPix + x / (float)width, halfPix + y / (float)width // normal coordinate , halfPix + x / (float)width, halfPix + y / (float)width); // with center coordinate pos = new Vector3(uv.x - 0.5f, uv.y - 0.5f, 0); float off = halfPix * (1 - borderPercent); Vector3 offf = Vector3.zero; switch (p) { case PicV.ldwn: offf += new Vector3(-off, off, 0); break; case PicV.lup: offf += new Vector3(-off, -off, 0); break; case PicV.rdwn: offf += new Vector3(off, off, 0); break; case PicV.rup: offf += new Vector3(off, -off, 0); break; } pos += offf; uv.x += offf.x; uv.y += offf.y; }
static int GetIndOf(int x, int y, PicV p) => (y * width + x) * 4 + (int)p;
static int GetIndOf(int x, int y, PicV p) { return((y * width + x) * 4 + (int)p); }