Last active
August 12, 2024 14:04
-
-
Save luizbills/114d1389a6650901fc03a79c3842cbb3 to your computer and use it in GitHub Desktop.
Draw a cube in canvas #litecanvas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
litecanvas() | |
function init () { | |
loadScript('https://unpkg.com/@litecanvas/plugin-more-shapes/dist/dist.js', (res) => { | |
if (res) use(pluginMoreShapes) | |
}) | |
size = 100 | |
x = WIDTH/2 - size/2 | |
y = HEIGHT/2 - size/2 | |
colors = [4,5,6] | |
} | |
function update (dt) { | |
if (LOADING) return | |
} | |
function draw () { | |
if (LOADING) return | |
cls(0) | |
polfill( | |
[ | |
x, y, | |
x + size, y, | |
x + size, y + size, | |
x, y + size, | |
], | |
colors[0] | |
) | |
polfill( | |
[ | |
x, y, | |
x + size/2, y - size/2, | |
x + size/2 + size, y - size/2, | |
x + size, y, | |
], | |
colors[1] | |
) | |
polfill( | |
[ | |
x + size, y, | |
x + size + size/2, y - size/2, | |
x + size/2 + size, y - size/2 + size, | |
x + size, y + size, | |
], | |
colors[2] | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://litecanvas.js.org?c=eJydkF1LwzAUhu%2F7K87dUmyXrqgXwkRhsg38uNjAi7GL0qZbNEtCkqpT%2Bt9NUztaXVG8SU7e85HnPYwakib8JdHI97y84KmhggPl1ADy4cMDYCLJFqmi0qDB1hipLzAuuHzeDFOxw1fsMAFLVmwoD3dCkVBvE0k0zqg27hg%2B6UEASBHtw%2FjSDQag%2BZdSaILq7jvbvHC9vi0pLRSApu8ExjCKIvt4s9HjfLKc4RhCl8KxlfdWnt3Mp7NlV08FE0rb5Oo0OAvO117ZslnILDEEUGZqqxXP7cP1ZH4%2F9UERUyjeqc9U8tqs5Vit%2FY5pFFXkUrCcMoacz5U7LXsA%2B6CJ4cRRHpeaqNXYkdb1VbtbRWv7cqv687c4rkY2i%2FqZbaH0FR2mdmFGv8D0%2B%2F4%2F2vd19SyyCxrXoKX3CVaqzmQ%3D