Munching squares: Difference between revisions
Content added Content deleted
(→{{header|Lua}}: Updated Löve code) |
|||
Line 845: | Line 845: | ||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
Needs LÖVE 2D Engine 11.0 or higher |
Needs LÖVE 2D Engine 11.0 or higher |
||
<lang lua> |
<lang lua>local clr = {} |
||
local clr = {} |
|||
function drawMSquares() |
function drawMSquares() |
||
local points = {} |
|||
for y = 0, hei-1 do |
|||
for x = 0, wid-1 do |
|||
local idx = bit.bxor(x, y)%256 |
|||
local r, g, b = clr[idx][1], clr[idx][2], clr[idx][3] |
|||
local point = {x+1, y+1, r/255, g/255, b/255, 1} |
|||
table.insert (points, point) |
|||
end |
|||
end |
|||
love.graphics.points(points) |
|||
end |
end |
||
function createPalette() |
function createPalette() |
||
for i = 0, 255 do |
|||
clr[i] = {i*2.8%256, i*3.2%256, i*1.5%256} |
|||
end |
|||
end |
end |
||
function love.load() |
function love.load() |
||
wid, hei = 256, 256 |
|||
wid, hei = love.graphics.getWidth(), love.graphics.getHeight() |
|||
love.window.setMode(wid, hei) |
|||
canvas = love.graphics.newCanvas() |
|||
love.graphics. |
love.graphics.setCanvas(canvas) |
||
⚫ | |||
love.graphics.setColor(255/255, 255/255, 255/255) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
function love.draw() |
function love.draw() |
||
love.graphics.setColor(1,1,1) |
|||
love.graphics.draw(canvas) |
|||
end |
|||
</lang> |
end</lang> |
||
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
=={{header|Mathematica}}/{{header|Wolfram Language}}== |