簡體   English   中英

在 F# Fable 應用程序中使用“System.Drawing.Color”

[英]Using `System.Drawing.Color` in a F# Fable app

我一直在嘗試在我的 Fable 應用程序中使用System.Drawing.Color ,將 aa Color轉換為簡單的rgba css 字符串:

module Color =
    let rgbaString (color: System.Drawing.Color) =
        let alpha = float color.A / 255.0
        String.Format("rgba({0}, {1}, {2}, {3})", color.R, color.G, color.B, alpha)

不幸的是,Fable 編譯器針對 r、g、b 和 alpha 值拋出如下錯誤:

ERROR in ./src/App/App.fs
Module Error (from ./node_modules/fable-loader/index.js):
/everybodykurts/MyApp/src/App/App.fs(13,50): (13,57) error FABLE: Cannot resolve System.Drawing.Color.get_R
 @ ./src/App/App.fsproj 1:0-25 1:0-25

我一直在嘗試使用 F# 的類型擴展向System.Drawing.Color添加get_RR()方法,但這似乎不起作用。

type System.Drawing.Color with 
    member this.R() = this.R
    member this.G() = this.G
    member this.B() = this.B
    member this.A() = this.A

我錯過了什么? 感謝您的任何幫助。

Fable 是 F# 到 javascript 編譯器。 它可以編譯大部分的F#,但很少的.Net BCL(基礎Class庫)。

它根本不知道System.Drawing.Color是什么。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM