GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Screenshot of web page (detail, cont.): rows[data.rowIndex][data.columnIndex]++ if (rows[data.rowIndex][data.columnIndex] === colours.length) { rows[data.rowIndex][data.columnIndex] = 0 } page.everyone.send(kitten.html` <${Pixel} rowIndex=${data.rowIndex} columnIndex=${data.columnIndex} pixelColourIndex=${rows[data.rowIndex][data.columnIndex]} /> `) }) } Listens for pixel updates, validates data, updates the grid, and sends the updated pixel state to everyone connected. Pixel component const Pixel = ({ rowIndex, columnIndex, pixelColourIndex }) => kitten.html` <button id='pixel-${rowIndex}-${columnIndex}' aria-label='pixel-${rowIndex}-${columnIndex}' name='pixel' style=' background-color: ${colours[pixelColourIndex]}; top: calc(5% * ${rowIndex}); left: calc(5% * ${columnIndex}); ' connect data='{rowIndex: ${rowIndex}, columnIndex: ${columnIndex}}' morph ></button> ` Defines a button element representing a pixel, styled according to

Download link

https://s3-eu-central-1.amazonaws.com/mastodon-aral/media_attachments/files/113/323/788/975/395/004/original/d998c1a58cf3c554.png

Notices where this attachment appears

  1. Embed this notice
    Aral Balkan (aral@mastodon.ar.al)'s status on Friday, 18-Oct-2024 01:54:19 JST Aral Balkan Aral Balkan

    Just added a code breakdown for the Draw Together¹ Kitten² app to my blog post with the tutorial video:

    https://ar.al/2024/03/26/draw-together/

    Draw Together, in ~50 lines of code, is a real-time collaborative drawing tool on a 20×20 pixel grid where people can click to toggle the colour of each pixel.

    (The full source and explanations fit the four screenshots on this post.)

    ¹ https://draw-together.small-web.org
    ² https://kitten.small-web.org

    #Kitten #DrawTogether #web #design #dev #SmallWeb #WebSockets #StreamingHTML

    In conversation about 8 months ago from mastodon.ar.al permalink
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.