-
Notifications
You must be signed in to change notification settings - Fork 11
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
add palette.satyg #22
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
@import: float | ||
|
||
module Gray :sig | ||
|
||
val make-gray : float -> color | ||
|
||
val red : color | ||
val green : color | ||
val blue : color | ||
val brown : color | ||
val lime : color | ||
val orange : color | ||
val pink : color | ||
val purple : color | ||
val teal : color | ||
val violet : color | ||
val cyan : color | ||
val magenta : color | ||
val yellow : color | ||
val olive : color | ||
val black : color | ||
val darkgray : color | ||
val gray : color | ||
val lightgray : color | ||
val white : color | ||
|
||
end = struct | ||
|
||
let make-gray gr = Gray(gr) | ||
|
||
|
||
let red = make-gray 0.3 | ||
let green = make-gray 0.59 | ||
let blue = make-gray 0.11 | ||
let brown = make-gray 0.5475 | ||
let lime = make-gray 0.815 | ||
let orange = make-gray 0.595 | ||
let pink = make-gray 0.825 | ||
let purple = make-gray 0.2525 | ||
let teal = make-gray 0.35 | ||
let violet = make-gray 0.205 | ||
|
||
let cyan = make-gray 0.7 | ||
let magenta = make-gray 0.41 | ||
let yellow = make-gray 0.89 | ||
let olive = make-gray 0.39 | ||
|
||
let black = make-gray 0.0 | ||
let darkgray = make-gray 0.25 | ||
let gray = make-gray 0.5 | ||
let lightgray = make-gray 0.75 | ||
let white = make-gray 1.0 | ||
|
||
|
||
end | ||
|
||
module RGB :sig | ||
|
||
val make-rgb : float -> float -> float -> color | ||
nyuichi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
val make-rgb-256 : int -> int -> int -> color % 0 - 255 | ||
|
||
val red : color | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RGB.red,CMYK.red,Color.red (color-extの中の定義)はどう違うんでしょうか There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Color.redとRGB.redとの違いはありません。しかし、CMYK.redとRGB.redとの違いは明確で、PDF/X-1aなどの印刷用のPDFファイルを作ろうとした時などのRGBが使えずCMYKが要求される場面で、特にCMYKで定義されているということが明確であるという点で役に立ちます。 colorパッケージで定義されているという理由でRGBモジュールだけからredを無くすというのはGrayモジュールやCMYKモジュールとの整合性との観点から躊躇しています。
とするのもありですが、colorパッケージの中での定義がCMYK空間に変更される可能性を考えるとこのままの方が良いと考えました。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. うーんなるほど,RGB.red/CMYK.red/GRAY.redを用意するならColor.redを実行時に切り替えられるようにしたいですね.stage-0 functionを使ってうまくできそう.
|
||
val green : color | ||
val blue : color | ||
val brown : color | ||
val lime : color | ||
val orange : color | ||
val pink : color | ||
val purple : color | ||
val teal : color | ||
val violet : color | ||
val cyan : color | ||
val magenta : color | ||
val yellow : color | ||
val olive : color | ||
val black : color | ||
val darkgray : color | ||
val gray : color | ||
val lightgray : color | ||
val white : color | ||
|
||
end = struct | ||
|
||
let make-rgb r g b = RGB(r, g, b) | ||
let make-rgb-256 r g b = | ||
let to-bit n = (Float.of-int n) /. 255.0 in | ||
RGB(to-bit r, to-bit g, to-bit b) | ||
|
||
|
||
let red = make-rgb 1.0 0.0 0.0 | ||
let green = make-rgb 0.0 1.0 0.0 | ||
let blue = make-rgb 0.0 0.0 1.0 | ||
let brown = make-rgb 0.75 0.5 0.25 | ||
let lime = make-rgb 0.75 0.5 0.25 | ||
let orange = make-rgb 1.0 0.5 0.0 | ||
let pink = make-rgb 1.0 0.75 0.75 | ||
let purple = make-rgb 0.75 0.0 0.25 | ||
let teal = make-rgb 0.0 0.5 0.5 | ||
let violet = make-rgb 0.5 0.0 0.5 | ||
|
||
let cyan = make-rgb 0.0 1.0 1.0 | ||
let magenta = make-rgb 1.0 0.0 1.0 | ||
let yellow = make-rgb 1.0 1.0 0.0 | ||
let olive = make-rgb 0.5 0.5 0.0 | ||
|
||
let black = make-rgb 0.0 0.0 0.0 | ||
let darkgray = make-rgb 0.25 0.25 0.25 | ||
let gray = make-rgb 0.5 0.5 0.5 | ||
let lightgray = make-rgb 0.75 0.75 0.75 | ||
let white = make-rgb 1.0 1.0 1.0 | ||
|
||
end | ||
|
||
module CMYK :sig | ||
|
||
val make-cmyk : float -> float -> float -> float -> color | ||
val make-cmyk-256 : int -> int -> int -> int -> color % 0 - 255 | ||
|
||
val red : color | ||
val green : color | ||
val blue : color | ||
val brown : color | ||
val lime : color | ||
val orange : color | ||
val pink : color | ||
val purple : color | ||
val teal : color | ||
val violet : color | ||
val cyan : color | ||
val magenta : color | ||
val yellow : color | ||
val olive : color | ||
val black : color | ||
val darkgray : color | ||
val gray : color | ||
val lightgray : color | ||
val white : color | ||
|
||
end = struct | ||
|
||
let make-cmyk c m y k = CMYK(c, m, y, k) | ||
let make-cmyk-256 c m y k = | ||
let to-bit n = (Float.of-int n) /. 255.0 in | ||
CMYK(to-bit c, to-bit m, to-bit y, to-bit k) | ||
|
||
|
||
let red = make-cmyk 0.0 1.0 1.0 0.0 | ||
let green = make-cmyk 1.0 0.0 1.0 0.0 | ||
let blue = make-cmyk 1.0 1.0 0.0 0.0 | ||
let brown = make-cmyk 0.0 0.25 0.5 0.25 | ||
let lime = make-cmyk 0.25 0.0 1.0 0.0 | ||
let orange = make-cmyk 0.0 0.5 1.0 0.0 | ||
let pink = make-cmyk 0.0 0.25 0.25 0.0 | ||
let purple = make-cmyk 0.0 0.74 0.5 0.25 | ||
let teal = make-cmyk 0.5 0.0 0.0 0.5 | ||
let violet = make-cmyk 0.0 0.5 0.0 0.5 | ||
|
||
let cyan = make-cmyk 1.0 0.0 0.0 0.0 | ||
let magenta = make-cmyk 0.0 1.0 0.0 0.0 | ||
let yellow = make-cmyk 0.0 0.0 1.0 0.0 | ||
let olive = make-cmyk 0.0 0.0 1.0 0.5 | ||
|
||
let black = make-cmyk 0.0 0.0 0.0 1.0 | ||
let darkgray = make-cmyk 0.0 0.0 0.0 0.75 | ||
let gray = make-cmyk 0.0 0.0 0.0 0.5 | ||
let lightgray = make-cmyk 0.0 0.0 0.0 0.25 | ||
let white = make-cmyk 0.0 0.0 0.0 0.0 | ||
|
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gray.redとかGray.greenとかはどういう場面で使うことを想定していますか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Color.to-gray (Color.red)でここのGray.redと同じになるような
という関数を用意すると便利かもしれません.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gray.redやGray.greenはモノクロ印刷をするところでもそれらしい色を使い時などを想定しています。
また、RGBやCMYKと同じ色が定義されているのは、「執筆中ではカラーで表示するが、印刷所に提出するときにはモノクロにしたい」時などに
のようにすることを想定してるからです。
to-gray
関数は欲しいですが、どの変換式を採用するかで悩んでいます。参考:グレースケール画像のうんちく(Qiita)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
あーなるほど,意図は理解しました.
ぷりにゃんさんの方法だと試し時と印刷時でモノクロかどうかを分けたいときに色を使う全てのsatyとsatyh(自分で書いたものだけでなくすでにインストール済みのものも含む)にopen Grayをつけて回る作業が発生してしまいそうですがそれでも問題なさそうですか?(実際にはライブラリから直接色を使うことはない気がするので大丈夫そうではある)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to-grayは全部実装してもよさそうです:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
openを付けて回るのは回避したいですが、
let f = if !if-gray then Gray.red else RGB.red
のように使ってもらえると少し楽になるかもしれません……。to-grayはできるものから実装していくことにします
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SATySFiコードのレベルでモノクロへ切り替えるという方法は外部プログラムに依存しないという利点がありますが、他の方法としてSATySFiでのPDF出力時にコマンドラインオプションで指定するようにしたり(SATySFi本体の改造が必要)、出力したPDFをモノクロ化するという方法(cf. http://rakkyoo.net/?p=131 )も考えられると思います。
コードで切り替えを行う方法の欠点として、例えばカラー画像はそのままになってしまいます。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
はい、カラー画像の扱いなどの問題もありますし、可能であればsatysfi本体への変更が1番だと思います。ただし、satysfi本体への変更はマージされる見込みがなかなか立たないというメタな問題もあるのでひとまずsatysfi-baseで対応可能な範囲で対応するという方針でもいいと思っています。