CSS Paint API๋กœ ๋™์  ๋ฐฐ๊ฒฝ์„ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•


์›๋ฌธ: https://www.webtips.dev/how-to-make-dynamic-backgrounds-with-the-css-paint-api

Unsplash์— Paweล‚ Czerwiล„ski์˜ ์‚ฌ์ง„.

ํ˜„๋Œ€์˜ ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์€ ๋งŽ์€ ์ด๋ฏธ์ง€๊ฐ€ ์‚ฌ์šฉ๋˜๋ฉฐ ๋‹ค์šด๋กœ๋“œ๋˜๋Š” ์šฉ๋Ÿ‰์˜ ๋Œ€๋ถ€๋ถ„์„ ์ฐจ์ง€ํ•œ๋‹ค. ์ด๋ฅผ ์ตœ์ ํ™”ํ•˜๋ฉด ์›นํŽ˜์ด์ง€์˜ ์„ฑ๋Šฅ์„ ํšจ๊ณผ์ ์œผ๋กœ ํ–ฅ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค. ๊ธฐํ•˜ํ•™์  ๋ชจ์–‘์˜ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ, CSS Paint API๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๋ฐฉ์‹์œผ๋กœ ์ด๋ฅผ ๋Œ€์ฒดํ•  ๊ฒฝ์šฐ ํšจ๊ณผ์ ์œผ๋กœ ์›นํŽ˜์ด์ง€์˜ ์„ฑ๋Šฅ์„ ํ–ฅ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค.

์ด ํŠœํ† ๋ฆฌ์–ผ์—์„œ CSS Paint API์˜ ๊ธฐ๋Šฅ์„ ์‚ดํŽด๋ณด๊ณ , ํ•ด์ƒ๋„ ์˜ํ–ฅ์„ ๋ฐ›์ง€ ์•Š๋Š” ๋™์  ๋ฐฐ๊ฒฝ์„ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณด์ž. ๋จผ์ € ํŠœํ† ๋ฆฌ์–ผ ๊ฒฐ๊ณผ๋ฅผ ์‚ดํŽด๋ณด์ž.


ํ”„๋กœ์ ํŠธ ์„ค์ •

๋จผ์ € ์ƒˆ index.html ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ณ  ๋‹ค์Œ ์ฝ”๋“œ๋กœ ์ฑ„์›Œ๋ณด์ž.

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>๐ŸŽจ CSS Paint API</title>
        <link rel="stylesheet" href="styles.css" />
    </head>
    <body>
        <textarea class="pattern"></textarea>
        <script>
            if ('paintWorklet' in CSS) {
                CSS.paintWorklet.addModule('pattern.js');
            }
        </script>
    </body>
</html>

๋‹ค์Œ ๋ช‡ ๊ฐ€์ง€ ์‚ฌํ•ญ์— ์œ ์˜ํ•ด์•ผ ํ•œ๋‹ค.

  • 13๋ฒˆ์งธ ์ค„์—์„œ paintWorklet์„ ๋กœ๋“œํ•œ๋‹ค. ๊ธ€๋กœ๋ฒŒ ๋ธŒ๋ผ์šฐ์ € ์ง€์›์œจ์€ ํ˜„์žฌ 63%์ด๋‹ค. ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— ๊ฐœ๋ฐœ๋˜๋Š” ํ™˜๊ฒฝ์—์„œ ๋จผ์ € paintWorklet์ด ์ง€์›๋˜๋Š”์ง€๋ถ€ํ„ฐ ํ™•์ธํ•ด์•ผ ํ•œ๋‹ค.
  • ๋ฐ๋ชจ๋ฅผ ์œ„ํ•ด textarea์„ ์บ”๋ฒ„์Šค๋กœ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์œผ๋ฏ€๋กœ, textarea์˜ ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•˜์—ฌ ํŒจํ„ด์ด ์–ด๋–ป๊ฒŒ ๋‹ค์‹œ ๊ทธ๋ ค์ง€๋Š”์ง€ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.
  • ๋งˆ์ง€๋ง‰์œผ๋กœ, paintWorklet์„ ๋“ฑ๋กํ•  pattern.js์™€ ๋ช‡ ๊ฐ€์ง€ ์Šคํƒ€์ผ์„ ์ •์˜ํ•  ์ˆ˜ ์žˆ๋Š” styles.css๋ฅผ ๋งŒ๋“ค์–ด์•ผ ํ•œ๋‹ค.

worklet์ด๋ž€ ๋ฌด์—‡์ธ๊ฐ€?

paintWorklet์€ ๊ทธ๋ ค์•ผ ํ•˜๋Š” ๊ฒƒ์„ ์ •์˜ํ•˜๋Š” ํด๋ž˜์Šค๋กœ์„œ ์บ”๋ฒ„์Šค ์š”์†Œ์™€ ์œ ์‚ฌํ•˜๊ฒŒ ๋™์ž‘ํ•œ๋‹ค. ๋งŒ์•ฝ ์บ”๋ฒ„์Šค ์š”์†Œ์— ๋Œ€ํ•ด ์ด๋ฏธ ์•Œ๊ณ  ์žˆ๋‹ค๋ฉด ์ฝ”๋“œ๋Š” ์ต์ˆ™ํ•ด ๋ณด์ผ ๊ฒƒ์ด๋‹ค. ํ•˜์ง€๋งŒ 100% ๋™์ผํ•˜์ง€๋Š” ์•Š๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด, ํ…์ŠคํŠธ ๋žœ๋”๋ง์€ ์•„์ง paintWorklet์—์„œ ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค.

์ด์ œ CSS ์Šคํƒ€์ผ์„ ์ •์˜ํ•ด๋ณด์ž. CSS์—์„œ paintWorklet์˜ ์‚ฌ์šฉ์„ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

.pattern {
    width: 250px;
    height: 250px;
    border: 1px solid #000;

    background-image: paint(pattern);
}

ํ…์ŠคํŠธ ์˜์—ญ์„ ๋” ์ž˜ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ฒ€์€์ƒ‰ ํ…Œ๋‘๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ–ˆ๋‹ค. paintWorklet ์ž‘์—…๋ฌผ์„ ์ฐธ์กฐํ•˜๋ ค๋ฉด paint(paintWorklet ์ด๋ฆ„)๋ฅผ background-image ์†์„ฑ ๊ฐ’์œผ๋กœ ์ „๋‹ฌํ•ด์•ผ ํ•œ๋‹ค.pattern์€ ๋‹ค์Œ ๋‹จ๊ณ„์—์„œ ์‚ดํŽด๋ณด์ž. ์•„์ง ์ •์˜ํ•˜์ง€ ์•Š์•˜์œผ๋‹ˆ ๋‹ค์Œ ๋‹จ๊ณ„์—์„œ ์‚ดํŽด๋ณด์ž.

worklet ์ •์˜

pattern.jsํŒŒ์ผ์„ ๋งŒ๋“ค๊ณ  ๋‹ค์Œ ๋‚ด์šฉ์„ ์ถ”๊ฐ€ํ•˜์ž.

class Pattern {
    paint(context, canvas, properties) {
        
    }
}

registerPaint('pattern', Pattern);

registerPaint ๋ฉ”์„œ๋“œ๋กœ paintWorklet์„ ๋“ฑ๋กํ•  ์ˆ˜ ์žˆ๋‹ค. ์ฒซ ๋ฒˆ์งธ ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” CSS์—์„œ ์ฐธ์กฐํ•˜๊ธฐ ์œ„ํ•œ ๋„ค์ด๋ฐ์ด๊ณ , ๋‘ ๋ฒˆ์งธ ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” ์บ”๋ฒ„์Šค์— ๊ทธ๋ฆด ๊ฒƒ์„ ์ •์˜ํ•˜๋Š” ํด๋ž˜์Šค์ด๋‹ค.์ด ํด๋ž˜์Šค๋Š” ์„ธ ๊ฐ€์ง€ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ตฌํ˜„๋˜๋Š” paint ๋ฉ”์„œ๋“œ๋ฅผ ๊ฐ€์ง„๋‹ค.

  • context - CanvasRenderingContext2D API์˜ ํ•˜์œ„ ์ง‘ํ•ฉ์„ ๊ตฌํ˜„ํ•˜๋Š” PaintRenderingContext2D ๊ฐœ์ฒด๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
  • canvas - ๋„ˆ๋น„์™€ ๋†’์ด์˜ ๋‘ ๊ฐ€์ง€ ์†์„ฑ๋งŒ ๊ฐ–๋Š” PaintSize ๊ฐ์ฒด๋‹ค.
  • properties - CSS ์†์„ฑ๊ณผ ๊ฐ’์„ ์ฝ๋Š” ๋ฐ ์‚ฌ์šฉ๋˜๋Š” StylePropertyMapReadOnly ๊ฐ์ฒด๊ฐ€ ๋ฐ˜ํ™˜๋œ๋‹ค.

์ง์‚ฌ๊ฐํ˜• ๊ทธ๋ฆฌ๊ธฐ

์ด์ œ, ์ง์‚ฌ๊ฐํ˜•์„ ๊ทธ๋ ค๋ณด์ž. paint ๋ฉ”์„œ๋“œ์— ๋‹ค์Œ ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.

paint(context, canvas, properties) {
    for (let x = 0; x < canvas.height / 20; x++) {
        for (let y = 0; y < canvas.width / 20; y++) {
            const bgColor = (x + y) % 2 === 0 ? '#FFF' : '#FFCC00';
  
            context.shadowColor = '#212121';
            context.shadowBlur = 10;
            context.shadowOffsetX = 10;
            context.shadowOffsetY = 1;
  
            context.beginPath();
            context.fillStyle = bgColor;
            context.rect(x * 20, y * 20, 20, 20);
            context.fill();
        }
    }
}

์—ฌ๊ธฐ์„œ๋Š” ์ค‘์ฒฉ ๋ฃจํ”„๋ฅผ ๋งŒ๋“ค์–ด ์บ”๋ฒ„์Šค์˜ ํญ๊ณผ ๋†’์ด๋ฅผ ์ด์šฉํ•œ ๊ณ„์‚ฐ์„ ํ•œ๋‹ค. ์ง์‚ฌ๊ฐํ˜•์˜ ํฌ๊ธฐ๊ฐ€ 20์ด๋ฏ€๋กœ ๋†’์ด์™€ ํญ์„ ๋ชจ๋‘ 20์œผ๋กœ ๋‚˜๋ˆˆ๋‹ค.

๋„ค ๋ฒˆ์งธ ๋ผ์ธ์—์„œ ๋‚˜๋จธ์ง€ ์—ฐ์‚ฐ์ž๋ฅผ ์ด์šฉํ•˜์—ฌ ๋‘ ์ƒ‰์ƒ ์‚ฌ์ด๋ฅผ ์ „ํ™˜ํ•œ๋‹ค. ๊นŠ์ด ํ‘œํ˜„์„ ์œ„ํ•ด shadow์†์„ฑ์„ ๋ช‡ ๊ฐœ ์ถ”๊ฐ€ํ–ˆ๋‹ค. ๋งˆ์ง€๋ง‰์œผ๋กœ ์ง์‚ฌ๊ฐํ˜•์„ ๊ทธ๋ฆฐ๋‹ค. ๋ธŒ๋ผ์šฐ์ €์—์„œ ํŒŒ์ผ์„ ์—ด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ๋ณด์—ฌ์•ผ ํ•œ๋‹ค.


๋ฐฐ๊ฒฝ์„ ๋™์ ์œผ๋กœ ๋งŒ๋“ค๊ธฐ

textarea์˜ ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•  ๋•Œ Paint API๊ฐ€ ๋‹ค์‹œ ๊ทธ๋ฆฌ๋Š” ๊ฑธ ์—ฟ๋ณผ ์ˆ˜ ์žˆ์ง€๋งŒ, ์•ˆํƒ€๊น๊ฒŒ๋„ ๊ทธ๋ž˜๋„ ์—ฌ์ „ํžˆ ์ •์ ์ด๋‹ค. ์šฐ๋ฆฌ๊ฐ€ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅํ•œ ์‚ฌ์šฉ์ž ์ •์˜ CSS์†์„ฑ์„ ์ถ”๊ฐ€ํ•˜์—ฌ ์ข€ ๋” ๋™์ ์ธ ๋ฐฐ๊ฒฝ์„ ๋งŒ๋“ค์–ด ๋ณด์ž.

styles.css ํŒŒ์ผ์„ ์—ด๊ณ  ์•„๋ž˜ ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜์ž.

 .pattern {
     width: 250px;
     height: 250px;
     border: 1px solid #000;

     background-image: paint(pattern);
+    --pattern-color: #FFCC00;
+    --pattern-size: 23;
+    --pattern-spacing: 0;
+    --pattern-shadow-blur: 10;
+    --pattern-shadow-x: 10;
+    --pattern-shadow-y: 1;
 }

์‚ฌ์šฉ์ž ์ •์˜ CSS ์†์„ฑ์€ --๋กœ ์ ‘๋‘์‚ฌ๋ฅผ ๋ถ™์—ฌ ์ •์˜ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋ณดํ†ต์€ var()ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•˜์—ฌ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ ์šฐ๋ฆฌ๋Š” paintWorklet์—์„œ ์‚ฌ์šฉํ•  ๊ฒƒ์ด๋‹ค.

CSS๋กœ ์ง€์› ํ™•์ธํ•˜๊ธฐ

CSS๋ฅผ ํ†ตํ•ด Paint API๊ฐ€ ์ง€์›๋˜๋Š”์ง€ ํ™•์ธํ•  ์ˆ˜๋„ ์žˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•œ ๋‘ ๊ฐ€์ง€ ์˜ต์…˜์ด ์žˆ๋‹ค.

  • @supports๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ทœ์น™์„ ๋ณดํ˜ธ.
  • ๋Œ€์ฒด ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€ ์‚ฌ์šฉ
/* ์ฒซ๋ฒˆ์งธ ์˜ต์…˜ */
@supports (background: paint(pattern)) {
  /**
   * ์ด ๋ถ€๋ถ„์ด ์‹คํ–‰๋˜๋ฉด Paint API๊ฐ€ ์ง€์›๋จ์„ ์˜๋ฏธํ•œ๋‹ค
   **/
}

/**
 * ๋‘๋ฒˆ์งธ ์˜ต์…˜
 * Paint API๊ฐ€ ์ง€์›๋˜๋Š” ๊ฒฝ์šฐ ํ›„์ž์˜ ๊ทœ์น™์œผ๋กœ ์žฌ์ •์˜ ๋œ๋‹ค
 * ๊ทธ๋ ‡์ง€ ์•Š์„ ๊ฒฝ์šฐ url()์ด ์ ์šฉ๋œ๋‹ค
 **/
.pattern {
  background-image: url(pattern.png);
  background-image: paint(pattern);
}

paintWorklet์˜ ๋งค๊ฐœ๋ณ€์ˆ˜์— ์ ‘๊ทผํ•˜๊ธฐ

pattern.js ๋‚ด์—์„œ ๋งค๊ฐœ ๋ณ€์ˆ˜๋ฅผ ์ฝ์œผ๋ ค๋ฉด ์•„๋ž˜์ฒ˜๋Ÿผ paintWorklet์„ ์ •์˜ํ•˜๋Š” ํด๋ž˜์Šค์— ์ƒˆ ๋ฉ”์„œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ด์•ผ ํ•œ๋‹ค.

class Pattern {
    // paintWorklet์€ `inputProperties` ๋ฉ”์†Œ๋“œ๊ฐ€ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ชจ๋“  ํ•ญ๋ชฉ์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋‹ค.
    static get inputProperties() { 
        return [
            '--pattern-color',
            '--pattern-size',
            '--pattern-spacing',
            '--pattern-shadow-blur',
            '--pattern-shadow-x',
            '--pattern-shadow-y'
        ]; 
    }
}

paint ๋ฉ”์„œ๋“œ ๋‚ด์—์„œ properties.get๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์†์„ฑ์— ์•ก์„ธ์Šค ํ•  ์ˆ˜ ์žˆ๋‹ค.

paint(context, canvas, properties) {
    const props = {
        color: properties.get('--pattern-color').toString().trim(),
        size: parseInt(properties.get('--pattern-size').toString()),
        spacing: parseInt(properties.get('--pattern-spacing').toString()),
        shadow: {
            blur: parseInt(properties.get('--pattern-shadow-blur').toString()),
            x: parseInt(properties.get('--pattern-shadow-x').toString()),
            y: parseInt(properties.get('--pattern-shadow-y').toString())
        }
    };
}

properties.get์ด CSSUnparsedValue๋ฅผ ๋ฐ˜ํ™˜ํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ์ƒ‰์ƒ์€ ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜ํ•ด์•ผ ํ•˜๋ฉฐ ๋‚˜๋จธ์ง€๋Š” ๋ชจ๋‘ ์ˆซ์ž๋กœ ๋ณ€ํ™˜ํ•ด์•ผ ํ•œ๋‹ค.

์ข€ ๋” ์ฝํžˆ๊ธฐ ์‰ฌ์šด ์ฝ”๋“œ๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด ํŒŒ์‹ฑ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋‘ ๊ฐ€์ง€ ์ƒˆ๋กœ์šด ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์—ˆ๋‹ค.

paint(context, canvas, properties) {
    const getPropertyAsString = property => properties.get(property).toString().trim();
    const getPropertyAsNumber = property => parseInt(properties.get(property).toString());

    const props = {
        color: getPropertyAsString('--pattern-color'),
        size: getPropertyAsNumber('--pattern-size'),
        spacing: getPropertyAsNumber('--pattern-spacing'),
        shadow: {
            blur: getPropertyAsNumber('--pattern-shadow-blur'),
            x: getPropertyAsNumber('--pattern-shadow-x'),
            y: getPropertyAsNumber('--pattern-shadow-y')
        }
    };
}

์ด์ œ for ๋ฃจํ”„์— ์žˆ๋Š” ๋ชจ๋“  ์†์„ฑ ๊ฐ’์„ ํ•ด๋‹นํ•˜๋Š” prop ๊ฐ’์œผ๋กœ ๋ฐ”๊พธ๊ธฐ๋งŒ ํ•˜๋ฉด ๋œ๋‹ค.

for (let x = 0; x < canvas.height / props.size; x++) {
    for (let y = 0; y < canvas.width / props.size; y++) {
        const bgColor = (x + y) % 2 === 0 ? '#FFF' : props.color;

        context.shadowColor = '#212121';
        context.shadowBlur = props.shadow.blur;
        context.shadowOffsetX = props.shadow.x;
        context.shadowOffsetY = props.shadow.y;

        context.beginPath();
        context.fillStyle = bgColor;
        context.rect(x * (props.size + props.spacing),
                     y * (props.size + props.spacing), props.size, props.size);
        context.fill();
    }
}

์ด์ œ ๋ธŒ๋ผ์šฐ์ €๋กœ ๋Œ์•„๊ฐ€ ์†์„ฑ์„ ๋ณ€๊ฒฝํ•ด๋ณด์ž.

๊ฐœ๋ฐœ์ž ๋„๊ตฌ๋ฅผ ํ†ตํ•œ ๋ฐฐ๊ฒฝ ํŽธ์ง‘

์š”์•ฝ

CSS Paint API๊ฐ€ ์™œ ์œ ์šฉํ• ๊นŒ? ์‚ฌ์šฉ ์‚ฌ๋ก€๊ฐ€ ์žˆ์„๊นŒ?

๋ถ„๋ช…ํ•œ ๊ฒƒ์€ API์˜ ๋„์›€์œผ๋กœ ์‘๋‹ต์˜ ํฌ๊ธฐ๋ฅผ ์ค„์ธ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. ์ด๋ฏธ์ง€ ์‚ฌ์šฉ์„ ์ œ๊ฑฐํ•จ์œผ๋กœ์จ ํ•˜๋‚˜์˜ ๋„คํŠธ์›Œํฌ ์š”์ฒญ๊ณผ ๋ช‡ ํ‚ฌ๋กœ๋ฐ”์ดํŠธ์˜ ์šฉ๋Ÿ‰์„ ์ ˆ์•ฝํ•˜์—ฌ ์„ฑ๋Šฅ์„ ํ–ฅ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค.

๋‹ค๋ฅธ ์˜ˆ๋กœ, DOM ์š”์†Œ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ณต์žกํ•œ CSSํšจ๊ณผ์˜ ๊ฒฝ์šฐ ํŽ˜์ด์ง€์˜ ๋…ธ๋“œ ์ˆ˜๋„ ์ค„์ผ ์ˆ˜ ์žˆ๋‹ค. Paint API๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ณต์žกํ•œ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ๋น„์–ด์žˆ๋Š” ๋…ธ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•  ํ•„์š”๊ฐ€ ์—†๋‹ค.

ํ•„์ž๊ฐ€ ์ƒ๊ฐํ•˜๋Š” ๊ฐ€์žฅ ํฐ ์ด์ ์€ ์ •์  ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€๋ณด๋‹ค ํ›จ์”ฌ ๋” ๋งŽ์€ ์‚ฌ์šฉ์ž ์ •์˜๊ฐ€ ๊ฐ€๋Šฅํ•˜๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. API๋Š” ํ•ด์ƒ๋„์— ์˜ํ–ฅ์ด ์—†๋Š” ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•˜๋ฏ€๋กœ ํŠน์ •ํ•œ ํ™”๋ฉด ํฌ๊ธฐ๋ฅผ ๋†“์น˜๋Š” ๊ฒƒ์— ๋Œ€ํ•ด ๊ฑฑ์ •ํ•  ํ•„์š”๊ฐ€ ์—†๋‹ค.

CSS Paint API๋Š” ์•„์ง ๋ธŒ๋ผ์šฐ์ € ์ง€์›๋ฅ ์ด ๋†’์ง€ ์•Š์œผ๋ฏ€๋กœ ์ ์šฉ ์ „์— polyfill ์‚ฌ์šฉ์„ ๊ณ ๋ คํ•ด์•ผ ํ•œ๋‹ค. ํŠœํ† ๋ฆฌ์–ผ์˜ ์™„์„ฑ๋œ ํ”„๋กœ์ ํŠธ๋ฅผ ๋ณด๋ ค๋ฉด ์ด ๊นƒํ—™ ์ €์žฅ์†Œ๋ฅผ ์ฐธ๊ณ ํ•˜๊ธฐ ๋ฐ”๋ž€๋‹ค.

์ด ๊ธ€์„ ์ฝ์–ด์ค˜์„œ ๊ฐ์‚ฌํ•˜๋‹ค. ์ฆ๊ฑฐ์šด ์ฝ”๋”ฉํ•˜๊ธธ ๋ฐ”๋ž€๋‹ค!

๊น€์ง„์šฐ2021.01.25
Back to list