Lädt...


🔧 How to create your own Paint and use it using javascript and CSS (Houdini API)?


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

You can create your own Paint and use it in css in the following way:

TypeScript

/* checkboardWorklet.ts */
import {
  DOMString,
  PaintFunction,
  PaintGeometry,
  createPaint
} from "houdini-toolkit";

const paintName: DOMString = "checkerboard";
const paintFunction: PaintFunction = (
  ctx: CanvasRenderingContext2D,
  geom: PaintGeometry,
  properties: StylePropertyMapReadOnly
) => {
  const colors = ["red", "green", "blue"];
  const size = 32;
  for (let y = 0; y < geom.height / size; y++) {
    for (let x = 0; x < geom.width / size; x++) {
      const color = colors[(x + y) % colors.length];
      ctx.beginPath();
      ctx.fillStyle = color;
      ctx.rect(x * size, y * size, size, size);
      ctx.fill();
    }
  }
};
createPaint(paintName, paintFunction);

Javascript

/* checkboardWorklet.js */
import { createPaint } from "houdini-toolkit";

createPaint("checkerboard", (ctx, geom, properties) => {
  const colors = ["red", "green", "blue"];
  const size = 32;
  for (let y = 0; y < geom.height / size; y++) {
    for (let x = 0; x < geom.width / size; x++) {
      const color = colors[(x + y) % colors.length];
      ctx.beginPath();
      ctx.fillStyle = color;
      ctx.rect(x * size, y * size, size, size);
      ctx.fill();
    }
  }
});

HTML

<script>
  CSS.paintWorklet.addModule("checkboardWorklet.js");
</script>

CSS

li {
  background-image: paint(checkerboard);
}

In this example, paint is registered in the paintWorklet in the CSS object. Paint API (registerPaint, PaintWorkletGlobalScope, devicePixelRatio).

Links to examples in Github - https://github.com/houdini-toolkit/examples/tree/main/paint

...

🔧 How to create your own Paint and use it using javascript and CSS (Houdini API)?


📈 88.66 Punkte
🔧 Programmierung

🔧 New in Chrome 65: CSS Paint API, Server Timing API, and CSS display: contents


📈 42.64 Punkte
🔧 Programmierung

🔧 How you can create your own custom chatbot with your own custom data using Google Gemini API all for free


📈 41.79 Punkte
🔧 Programmierung

🔧 The Future of CSS: CSS Houdini


📈 41.26 Punkte
🔧 Programmierung

🔧 Introduction of CSS, What is CSS, Why we use CSS and How CSS describe the HTML elements


📈 39.19 Punkte
🔧 Programmierung

🔧 Create your own 📷 image compressor & to webp convertor using HTML, CSS, JavaScript from scratch 🚀


📈 38.86 Punkte
🔧 Programmierung

🪟 Use Beat Saber's Level Editor to create your own tracks with your own music


📈 35.65 Punkte
🪟 Windows Tipps

🔧 How To Create a Calculator Using HTML CSS & JavaScript | Simple Calculator in JavaScript


📈 33.39 Punkte
🔧 Programmierung

🔧 State of CSS Houdini


📈 32.84 Punkte
🔧 Programmierung

🔧 How to Be #Extra with CSS Houdini


📈 32.84 Punkte
🔧 Programmierung

🔧 How to Be #Extra with CSS Houdini


📈 32.84 Punkte
🔧 Programmierung

🎥 Extending CSS with Houdini


📈 32.84 Punkte
🎥 Video | Youtube

🔧 Extending CSS with Houdini


📈 32.84 Punkte
🔧 Programmierung

🔧 An awesome, cross-browser Star Wars circular wipe transition? CSS houdini vs clippath vs mask


📈 32.84 Punkte
🔧 Programmierung

🔧 A Tiny Peep into CSS Houdini


📈 32.84 Punkte
🔧 Programmierung

🔧 Building a 3D Card Flip Animation with CSS Houdini


📈 32.84 Punkte
🔧 Programmierung

🔧 CSS Houdini


📈 32.84 Punkte
🔧 Programmierung

🔧 Chrome 78 Beta: a new Houdini API, native file system access and more


📈 31.27 Punkte
🔧 Programmierung

📰 Houdini is Back Delivered Through a JavaScript Dropper, (Thu, Jun 16th)


📈 31 Punkte
📰 IT Security

🔧 Build a Tic Tac Toe Game using HTML, CSS, JavaScript, Tailwind CSS and Canvas Confetti


📈 29.18 Punkte
🔧 Programmierung

🪟 Microsoft wants to let you dub videos using your own voice in your own language, new patent reveals


📈 28.88 Punkte
🪟 Windows Tipps

🍏 Using Stickers on Your iPhone and How To Create Your Own


📈 28.16 Punkte
🍏 iOS / Mac OS

🔧 Create Two RGB cursor following lines using html, CSS and JavaScript


📈 27.78 Punkte
🔧 Programmierung

🔧 Create a Simple Digital Clock Using HTML, CSS and JavaScript


📈 27.78 Punkte
🔧 Programmierung

🔧 How to Create a Responsive Lightbox Gallery with Thumbnails using HTML, CSS, and JavaScript


📈 27.78 Punkte
🔧 Programmierung

🔧 Create a Pomodoro Timer App using HTML, CSS, and JavaScript


📈 27.78 Punkte
🔧 Programmierung

🔧 How to Create a Loading Bar Using HTML, CSS, and JavaScript


📈 27.78 Punkte
🔧 Programmierung

🔧 How to Create A Color Picker Tool Using HTML, CSS, and JavaScript


📈 27.78 Punkte
🔧 Programmierung

🔧 CSS Paint API


📈 27.35 Punkte
🔧 Programmierung

🐧 Huawei releases it's own desktop PC with their own OS based on Linux and their own ARM CPU.


📈 27.18 Punkte
🐧 Linux Tipps

🪟 Microsoft is killing off Paint 3D after trying and failing to replace classic Paint on Windows 11, 10


📈 27.06 Punkte
🪟 Windows Tipps

🔧 How to Create Personal Blog Website Using HTML CSS JavaScript


📈 26.8 Punkte
🔧 Programmierung

🎥 Create Modals With No CSS/JavaScript Using Popover


📈 26.8 Punkte
🎥 Video | Youtube

matomo