开发者

Simple math question about frame buffers

How do you get row back out of n?

local n = row * cols + col
local c开发者_如何转开发 = n % cols
local r = ?


Using some simple arithmetic...

You have

n = rows * cols + col

subtract col from both sides

n - col = rows * cols

divide by cols on both sides

(n - col) / cols = rows

Assuming col < cols holds, you could do it with integer division as rows = n / cols.


local r = int( n / cols )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜