sum-grid.love/0011-draw_sum_grid

26 lines
825 B
Plaintext

draw_sum_grid = function(g)
-- lines
love.graphics.setLineWidth(3)
local x1,y1 = X,Y
local x2,y2 = X+Square_side*2, Y+Square_side*2
App.color{r=0, g=0, b=0}
love.graphics.line(x1,y1, x2,y1)
love.graphics.line(x1,y2, x2,y2)
love.graphics.line(x1,y1, x1,y2)
love.graphics.line(x2,y1, x2,y2)
local xm,ym = (x1+x2)/2, (y1+y2)/2
love.graphics.line(x1,ym, x2,ym)
love.graphics.line(xm,y1, xm,y2)
-- data
draw_cell(g.col_totals[1], x1,y1-Square_side, nil, true)
draw_cell(g.col_totals[2], xm,y1-Square_side, nil, true)
draw_cell(g.row_totals[1], x1-Square_side, y1, nil, true)
draw_cell(g.row_totals[2], x1-Square_side, ym, nil, true)
for x=1,2 do
for y=1,2 do
draw_cell(g.data[y][x], x1+(x-1)*Square_side, y1+(y-1)*Square_side,
x == Cursor[1] and y == Cursor[2],
x == g.x and y == g.y)
end
end
end