SHOW:
|
|
- or go back to the newest paste.
| 1 | local W,H = 1024, 1024 | |
| 2 | local tex = Texture(1024, 1024, ETF_A8R8G8B8) | |
| 3 | ||
| 4 | - | ffi.cdef("typedef struct { uint8_t r, g, b, a; } rgba_pixel;")
|
| 4 | + | |
| 5 | local img = ffi.new("unsigned char[?]", length)
| |
| 6 | - | local img = ffi.new("rgba_pixel[?]", length)
|
| 6 | + | |
| 7 | - | for i = 0, length-1 do |
| 7 | + | |
| 8 | - | img[i].r = math.random(255) |
| 8 | + | local r = math.random |
| 9 | - | img[i].g = math.random(255) |
| 9 | + | |
| 10 | - | img[i].b = math.random(255) |
| 10 | + | |
| 11 | - | img[i].a = math.random(255) |
| 11 | + | for i = 0, length-1 do |
| 12 | - | end |
| 12 | + | img[i+0] = r(255) |
| 13 | img[i+1] = r(255) | |
| 14 | - | tex:SetData(img) |
| 14 | + | img[i+2] = r(255) |
| 15 | - | |
| 15 | + | img[i+3] = 255 |
| 16 | end | |
| 17 | ||
| 18 | tex:SetData(img) | |
| 19 | ||
| 20 | rect.x, rect.y = mouse.GetPos() | |
| 21 | ||
| 22 | graphics.Set2DFlags() | |
| 23 | graphics.DrawTexture(tex, rect, nil, nil, true) | |
| 24 | end) |