DVUI

uvFromRectuv

Set uv coords of vertexes according to position in r (with r_uv coords at corners).

Parameters

#
self:*Triangles
*Triangles
r:Rect.Physical
Rect.Physical
r_uv:Rect
Rect

Source

Implementation

#
pub fn uvFromRectuv(self: *Triangles, r: Rect.Physical, r_uv: Rect) void {
    for (self.vertexes) |*v| {
        const xfrac = (v.pos.x - r.x) / r.w;
        v.uv[0] = r_uv.x + xfrac * r_uv.w;

        const yfrac = (v.pos.y - r.y) / r.h;
        v.uv[1] = r_uv.y + yfrac * r_uv.h;
    }
}