Help us understand the problem. What is going on with this article?

透過色を、同じ色に見える非透過色に変換するStylusの関数

言葉で説明するのが難しいけど、rgba(255,0,0,0.5)#ff7f7fに変換する関数を作りました。

Stylusのビルトイン関数 transparentifyの逆バージョンみたいなやつ。

背景色を指定すると、その背景色に重ね合わせたときに実際に目に見える色に変換されます。

// color: 変換したい透過色
// background: 透過色の背景
untransparentify(color, background = #fff)
  if alpha(color) == 1
    return color

  else
    if alpha(background) < 1
      background = untransparentify(background)

    base = alpha(color, 1)
    percentage = alpha(color) * 100%

    return mix(base, background, percentage)
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away