PilotGaea 3D O'view
    正在準備搜尋索引...

    類別 Color

    顏色類別,有以下建構子

    new ov.Color(255, 255, 255);
    new ov.Color(255, 255, 255, 1.0);

    實作

    索引

    屬性

    r g b a

    方法

    構造函數

    屬性

    r: number

    顏色的紅色值。

    g: number

    顏色的綠色值。

    b: number

    顏色的藍色值。

    a: number

    顏色的 Alpha 值。

    方法

    • 轉換成16進制字串

      參數

      • 可選pattern: "RGB" | "RGBA" | "ARGB"

        格式 (預設"RGBA")

      回傳 `#${string}`

      const color = new ov.Color(255, 127, 0, 0.5);
      color.toHex("RGB"); // "#ff7f00"
      color.toHex("RGBA"); // "#ff7f007f"
      color.toHex("ARGB"); // "#7fff7f00"
      color.toHex(); // "#ff7f007f"
    • 轉換成 rgb() 格式字串

      回傳 `rgb(${number}, ${number}, ${number})`

      const color = new ov.Color(255, 127, 0, 0.5);
      color.toRGB(); //"rgb(255, 127, 0)"
    • 轉換成 rgba() 格式字串

      回傳 `rgba(${number}, ${number}, ${number}, ${number})`

      const color = new ov.Color(255, 127, 0, 0.5);
      color.toRGBA();//"rgba(255, 127, 0, 0.5)"

    構造函數

    • 建構 r, g, b, a 值為 0 的 ov.Color

      回傳 window.ov.Color

    • 使用陣列建構 ov.Color,效能最佳。 陣列前 3 元素分別代表r, g, b 值 (0~255)。第 4 元素代表 a 值 (0.0~1.0) 。 陣列長度小於 4 時,a 值預設為 1.0。

      參數

      回傳 window.ov.Color

      new ov.Color([255, 255, 255]); // 白色,a = 1.0
      new ov.Color([255, 255, 255, 1.0]); // 白色
    • 使用CSS顏色參數建構 ov.Color

      參數

      回傳 window.ov.Color

      // 白色
      new ov.Color("#ffffff"); // a = 1.0
      new ov.Color("#ffffffff");
      new ov.Color("ffffff"); // a = 1.0
      new ov.Color("ffffffff");
      new ov.Color("rgb(255, 255, 255)");
      new ov.Color("rgba(255, 255, 255, 1.0)");
      new ov.Color("white");
    • 使用字串建構 ov.Color。需注意顏色拼寫。

      參數

      • cssColor: string

      回傳 window.ov.Color

    • 使用 ColorLike 建構 ov.Color

      參數

      回傳 window.ov.Color

    • 使用 r, g, b, a 值 (0.0~1.0) 建構 ov.Color

      參數

      • r: number
      • g: number
      • b: number
      • a: number

      回傳 window.ov.Color

    • 使用 r, g, b 值 (0.0~1.0) 建構 ov.Colora 值預設為 1.0。

      參數

      • r: number
      • g: number
      • b: number

      回傳 window.ov.Color