animation ์œผ๋กœ ๋†€๊ธฐ - Conic Gradient -

7888 ๋‹จ์–ด CSSanimation
CSS animation day 54๊ฐ€ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
์˜ค๋Š˜, 31์„ธ์˜ ์ƒ์ผ์„ ๋งž์ดํ–ˆ์Šต๋‹ˆ๋‹ค.ใ€€

4์›”๋ถ€ํ„ฐ BeatFit์—์„œ ํ”„๋ŸฐํŠธ ์—”๋“œ ์—”์ง€๋‹ˆ์–ด๋กœ ์ผํ•ฉ๋‹ˆ๋‹ค.
์•ž์œผ๋กœ๋„ ์ž˜ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

์˜ค๋Š˜์€ ์ฝ”๋‹‰ gradient์— ๊ด€ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

1. ์™„์„ฑํŒ





2. ์ฐธ๊ณ ๋ฌธํ—Œ



CSS TRICKS
ICS MEDIA
์•„์•„๊ฐ€์™€ r. ์ด์˜ค

3. ๋ถ„ํ•ดํ•ด ๋ณธ๋‹ค



โถ.

conic gradient ๋Š” ์ค‘์‹ฌ์ ์„ ๋Œ๋ฉด์„œ ๋ฐฉ์‚ฌํ˜•์œผ๋กœ ๊ทธ๋ผ๋ฐ์ด์…˜์„ ์ƒ์„ฑํ•˜๋Š” ์†์„ฑ์ž…๋‹ˆ๋‹ค.



conic์€ ์›๋ฟ”์ด๋ผ๋Š” ์˜๋ฏธ์ž…๋‹ˆ๋‹ค. ์œ„์—์„œ ๋ณด๋ฉด ์›๋ฟ”๋กœ ๋ณด์ด๋Š” ๊ฒƒ์œผ๋กœ ๋ช…๋ช…๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๊ตฌ๋ฌธ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
conic-gradient([ from <angle> ]? [ at <position> ]?,  <angular-color-stop-list>)

์ฒซ ๋ฒˆ์งธ ์ธ์ˆ˜



conic-gradient()๋Š” ์ฒซ ๋ฒˆ์งธ ์ธ์ˆ˜์— ๊ทธ๋ผ๋ฐ์ด์…˜์˜ ์‹œ์ž‘ ์œ„์น˜์™€ ์ค‘์‹ฌ์ ์˜ ์œ„์น˜๋ฅผ โ€‹โ€‹์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
์˜ˆ๋ฅผ ๋“ค์–ด, from 30deg at 10% 10% ๋กœ ์„ค์ •ํ•˜๋ฉด ๊ทธ๋ผ๋ฐ์ด์…˜์ด 30๋„ ์œ„์น˜์—์„œ ์ค‘์‹ฌ์„ 10% 10%๋กœ ์„ค์ •๋ฉ๋‹ˆ๋‹ค.
background: conic-gradient(from 30deg at 30% 30%, #fff, #000);



๋ง๋ถ™์—ฌ ์ด ์ธ์ˆ˜๋ฅผ ์ƒ๋žตํ•˜๋Š” ๊ฒƒ๋„ ๊ฐ€๋Šฅํ•ด, ๊ทธ ๊ฒฝ์šฐ๋Š” ๋””ํดํŠธ๋กœ, ๊ฐ๋„๋Š” 0๋„๋กœ center ๋ฅผ ์ค‘์‹ฌ์œผ๋กœ ํ•ด ๋งŒ๋“ค์–ด์ง‘๋‹ˆ๋‹ค.

๋‘ ๋ฒˆ์งธ ์ธ์ˆ˜



๋‘ ๋ฒˆ์งธ ์ธ์ˆ˜๋กœ ์ƒ‰์ƒ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
์‹œ์ž‘์ ๊ณผ ๋์ ์˜ ์ตœ์†Œ ๋‘ ๊ฐ€์ง€ ์œ ํ˜•์˜ ์ƒ‰์ƒ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
conic-gradient(red, orange, yellow, green, blue);



0๋„๋ถ€ํ„ฐ ์‹œ๊ณ„ ๋ฐฉํ–ฅ์œผ๋กœ ์ˆœ์„œ๋Œ€๋กœ, ๋นจ๊ฐ•, ์ฃผํ™ฉ, ๋…ธ๋ž‘, ๋…น์ƒ‰, ํŒŒ๋ž‘์œผ๋กœ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.
์–ด๋””์—์„œ ์–ด๋””๊นŒ์ง€ ์ƒ‰์ƒ์„ ์ง€์ •ํ•˜๊ฑฐ๋‚˜ ๊ฐ๋„๋ฅผ ์ง์ ‘ ์„ค์ •ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
conic-gradient(
    red 0deg,
    orange 50deg,
    yellow 100deg,
    green 300deg,
    blue 360deg
  );



๋””ํดํŠธ์—์„œ๋Š”, 360/์ƒ‰์˜ ์ˆ˜์—, ๊ท ๋“ฑํ•˜๊ฒŒ ๊ฐ๋„๊ฐ€ ํ• ๋‹น๋ฉ๋‹ˆ๋‹ค.
๋˜ํ•œ ์‹œ์ž‘์ƒ‰์€ 0๋„, ์ข…๋ฃŒ์ƒ‰์€ 360๋„์ž…๋‹ˆ๋‹ค.

์ฃผ์˜์ 



MDN์— ๋”ฐ๋ฅด๋ฉด ํ˜„์žฌ (2019.3)์—์„œ๋Š” Goodle Chrome ๋ฐ Opera ๋งŒ ์ง€์›ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์•ž์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ธŒ๋ผ์šฐ์ €๋Š” ๋Š˜์–ด๋‚  ๊ฒƒ์ž…๋‹ˆ๋‹ค.



โท.
์ด์ œ๋ถ€ํ„ฐ ๋„๋„›์˜ ๊ทธ๋ž˜ํ”„๋ฅผ ๋งŒ๋“ค์–ด ๊ฐ‘๋‹ˆ๋‹ค.
๋งˆํฌ์—…ํ•˜์ž.

index.html
<!DOCTYPE html>
<html lang="ja">
  <head>
    <meta charset="UTF-8" />
    <link rel="stylesheet" href="css/styles.css" />
  </head>
  <body>
    <div class="container">
      <div class="image"></div>
    </div>
  </body>
</html>

styles.scss
body {
  margin: 0;
  padding: 0;
}

.container {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image {
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: conic-gradient(#ff5722 0% 35%, #ffeb3b 35% 60%, #2196f3 60% 100%);
}




์›ํ˜• ์ฐจํŠธ๊ฐ€ ์ƒ๊ฒผ์Šต๋‹ˆ๋‹ค.

๊ทธ๋ ‡๋‹ค๋ฉด ๋„๋„›์„ ๋งŒ๋“ค๋ ค๋ฉด ์–ด๋–ป๊ฒŒํ•ด์•ผํ•ฉ๋‹ˆ๊นŒ?
์ด์ „์˜ ๊ธฐ์‚ฌ ์˜ mask๋‚˜ clipPath ๋กœ ํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค๋งŒ, ๋ชจ์ฒ˜๋Ÿผ์ด๋ฏ€๋กœ, radial gradient๋ฅผ ์‚ฌ์šฉํ•ฉ์‹œ๋‹ค.

radial gradient ์€ ์ค‘์•™์—์„œ ๋ฐฉ์‚ฌํ˜•์œผ๋กœ ์ตœ์ข… ๋ชจ์–‘(์›์ด๋‚˜ ํƒ€์›)์„ ํ–ฅํ•ด ์ผ๋ จ์˜ ๋™์‹ฌ์›์˜ ๋ชจ์–‘์„ ๊ณฑํ•˜๋Š” ์†์„ฑ์ž…๋‹ˆ๋‹ค.
radial-gradient(#fff, transparent) 

๋กœ ์„ค์ •ํ•˜๋ฉด ์•ˆ์ชฝ์— ํฐ์ƒ‰ ์›์„ ๋ฐ”๊นฅ์ชฝ์— ํˆฌ๋ช…ํ•œ ๋ชจ์–‘์˜ ์›์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋ฐฉ๊ธˆ ์ „์˜ conic-gradient์™€ ํ•ฉ์„ฑํ•ฉ์‹œ๋‹ค.

styles.scss
background: radial-gradient(white 40%, transparent 25%),
    conic-gradient(#ff5722 0% 35%, #ffeb3b 35% 60%, #2196f3 60% 100%);



ํ”„๋ ˆ์  ํ…Œ์ด์…˜ ์ž๋ฃŒ๋ผ๋“ ์ง€์—๋„ ์‘์šฉํ•  ์ˆ˜ ์žˆ๋„ค์š”.
conic-gradient๋Š” ์ƒ๋‹นํžˆ ๊นŠ์€ ์†์„ฑ์ด๋ฉฐ, ๋‚ด์ผ๋ถ€ํ„ฐ ์• ๋‹ˆ๋ฉ”์ด์…˜๊ณผ ๊ธฐํƒ€ ํ‘œํ˜„ ๋ฐฉ๋ฒ•์„ ๋ชจ์ƒ‰ํ•ด ๋‚˜๊ฐˆ ๊ฒƒ์ž…๋‹ˆ๋‹ค.
๊ทธ๋Ÿผ ๋˜ ๋‚ด์ผ~

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ