Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

カラーコード定義の追加 #20

Open
2 tasks
tshion opened this issue Feb 6, 2022 · 0 comments
Open
2 tasks

カラーコード定義の追加 #20

tshion opened this issue Feb 6, 2022 · 0 comments
Assignees

Comments

@tshion
Copy link
Owner

tshion commented Feb 6, 2022

旧実装 のような定義を整備したい。

  • 列挙型として使える
  • リソース名として使える(Android は@color, iOS はAssets?)

メモ

定義名に"Color" を含めるとコーディング時に探しやすいかもしれない。

Android 定数

android.graphics.Color の定義はこんな感じ。

public class Color {
    @ColorInt public static final int BLACK       = 0xFF000000;

@ColorInt はA + RGB を意図していて、他の規格に変換するならandroidx.core.graphics.ColorUtilscolorToHSL() などを使う感じ。

Android リソース

android.R.color の定義(colors.xml) はこんな感じ。

<!-- The color black, equivalent to 0xff000000 -->
<color name="black">#ff000000</color>

iOS 定数

https://developer.apple.com/documentation/uikit/uicolor/standard_colors#topics

iOS リソース

配置は置いておいて、下記のようなJSON 形式になる。

{
  "colors" : [
    {
      "color" : {
        "color-space" : "srgb",
        "components" : {
          "alpha" : "1.000",
          "blue" : "0x28",
          "green" : "0x5A",
          "red" : "0xE1"
        }
      },
      "idiom" : "universal"
    },
    {
      "appearances" : [
        {
          "appearance" : "luminosity",
          "value" : "dark"
        }
      ],
      "color" : {
        "color-space" : "srgb",
        "components" : {
          "alpha" : "1.000",
          "blue" : "0x28",
          "green" : "0x5A",
          "red" : "0xE1"
        }
      },
      "idiom" : "universal"
    }
  ],
  "info" : {
    "author" : "xcode",
    "version" : 1
  }
}
@tshion tshion self-assigned this Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant