1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

filterでイラストをベタ塗りにする

Posted at

こちらの記事を見た時に、イラストでも同じことができるかなと、次のようなコードを書きました。

img {
  /* 赤くする */
  filter: invert(15%) sepia(95%) saturate(6932%) hue-rotate(358deg) brightness(95%) contrast(112%);
}

失敗。
スクリーンショット 2024-04-01 21.04.18.png

よく見たら「黒い画像を」って書いてありました。

なので画像を黒くしてから、ラッパーの方に適用させます。

.wrapper {
  /* 赤くする */
  filter: invert(15%) sepia(95%) saturate(6932%) hue-rotate(358deg) brightness(95%) contrast(112%);

}
img {
  /* 黒くする */
  filter: brightness(0);
}
 <div class="wrapper">
   <img src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/1.png" alt="">
 </div>

スクリーンショット 2024-04-01 21.07.40.png

OK。

ちなみにこんなツールもありました
https://codepen.io/sosuke/pen/Pjoqqp
このツールを使えば好きな色にすることができます。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?