Skip to content

Commit

Permalink
Rename functions edraw-change-* to edraw-replace-*
Browse files Browse the repository at this point in the history
  • Loading branch information
misohena committed Feb 11, 2025
1 parent 4899218 commit 04887e5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 26 deletions.
38 changes: 19 additions & 19 deletions edraw-color-picker.el
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@
(edraw-color-f 0 0 0 0))))
opacity-v-colors (edraw-color-picker-observable-value
:value
(list (edraw-change-a color-2 0)
(edraw-change-a color-2 1))))
(list (edraw-replace-a color-2 0)
(edraw-replace-a color-2 1))))

;; Update model from color-z, color-xy, opacity
(edraw-update-colors model)
Expand Down Expand Up @@ -354,13 +354,13 @@
(cdr (edraw-get-value color2d-hv-colors))))

(setf (elt (edraw-get-value opacity-v-colors) 0)
(edraw-change-a color-2 0.0))
(edraw-replace-a color-2 0.0))
(setf (elt (edraw-get-value opacity-v-colors) 1)
(edraw-change-a color-2 1.0))
(edraw-replace-a color-2 1.0))
(edraw-notify-change opacity-v-colors)

(edraw-set-value color-result
(edraw-change-a color-2 (edraw-get-value opacity)))
(edraw-replace-a color-2 (edraw-get-value opacity)))

;; (let ((message-log-max nil))
;; (message "%s" (edraw-to-string (edraw-get-value color-result))))
Expand Down Expand Up @@ -619,7 +619,7 @@
(seq-map-indexed
(lambda (color index)
(dom-node 'stop
`((stop-color . ,(edraw-to-string (edraw-change-a color 1.0)))
`((stop-color . ,(edraw-to-string (edraw-replace-a color 1.0)))
(stop-opacity . ,(edraw-color-a color))
(offset . ,(/ (float index) (1- (length colors)))))))
colors)))
Expand Down Expand Up @@ -1856,10 +1856,10 @@ but the reverse can also be done."
(edraw-color-r color))))))
(edraw-set-current-color
picker
(edraw-change-r (edraw-get-current-color picker)
(if (integerp value)
(/ value 255.0)
value))))
(edraw-replace-r (edraw-get-current-color picker)
(if (integerp value)
(/ value 255.0)
value))))

(defun edraw-color-picker-set-color-green (picker value)
(interactive
Expand All @@ -1872,10 +1872,10 @@ but the reverse can also be done."
(edraw-color-g color))))))
(edraw-set-current-color
picker
(edraw-change-g (edraw-get-current-color picker)
(if (integerp value)
(/ value 255.0)
value))))
(edraw-replace-g (edraw-get-current-color picker)
(if (integerp value)
(/ value 255.0)
value))))

(defun edraw-color-picker-set-color-blue (picker value)
(interactive
Expand All @@ -1888,10 +1888,10 @@ but the reverse can also be done."
(edraw-color-b color))))))
(edraw-set-current-color
picker
(edraw-change-b (edraw-get-current-color picker)
(if (integerp value)
(/ value 255.0)
value))))
(edraw-replace-b (edraw-get-current-color picker)
(if (integerp value)
(/ value 255.0)
value))))


(defun edraw-color-picker-define-keys-for-color-set (km &optional prefix)
Expand Down Expand Up @@ -3207,7 +3207,7 @@ Valid OPTIONS are:
(alist-get :color-float-format options 4))
(color (if (alist-get :enable-opacity options t)
color
(edraw-change-a color 1.0))))
(edraw-replace-a color 1.0))))
(pcase (alist-get :color-format options)
('nil
(edraw-to-string color))
Expand Down
8 changes: 4 additions & 4 deletions edraw-color.el
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,31 @@
:b (float b)
:a (float (or a 1.0))))

(cl-defmethod edraw-change-r ((color edraw-color) r)
(cl-defmethod edraw-replace-r ((color edraw-color) r)
"Create a new `edraw-color' object by replacing the r of COLOR with R."
(edraw-color
:r (float r)
:g (oref color g)
:b (oref color b)
:a (oref color a)))

(cl-defmethod edraw-change-g ((color edraw-color) g)
(cl-defmethod edraw-replace-g ((color edraw-color) g)
"Create a new `edraw-color' object by replacing the g of COLOR with G."
(edraw-color
:r (oref color r)
:g (float g)
:b (oref color b)
:a (oref color a)))

(cl-defmethod edraw-change-b ((color edraw-color) b)
(cl-defmethod edraw-replace-b ((color edraw-color) b)
"Create a new `edraw-color' object by replacing the b of COLOR with B."
(edraw-color
:r (oref color r)
:g (oref color g)
:b (float b)
:a (oref color a)))

(cl-defmethod edraw-change-a ((color edraw-color) a)
(cl-defmethod edraw-replace-a ((color edraw-color) a)
"Create a new `edraw-color' object by replacing the a of COLOR with A."
(edraw-color
:r (oref color r)
Expand Down
2 changes: 1 addition & 1 deletion edraw-property-editor.el
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ as a string."
(list
(cons 'background-color
;; @todo Show transparency. Use SVG?
(edraw-to-string-hex (edraw-change-a color 1.0))))
(edraw-to-string-hex (edraw-replace-a color 1.0))))
'default)))
))
;; Maybe it's better to add the button here rather than using :value-create?
Expand Down
2 changes: 1 addition & 1 deletion edraw-widget.el
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
(error (widget-get widget :value)))))
(if color
;;@todo Use SVG image for sample
(list (cons 'background-color (edraw-to-string-hex (edraw-change-a color 1.0)))) ;;Force a=1.0
(list (cons 'background-color (edraw-to-string-hex (edraw-replace-a color 1.0)))) ;;Force a=1.0
'default)))

(defun edraw-widget-web-color-action (widget &optional event)
Expand Down
3 changes: 2 additions & 1 deletion todo.org
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ customize-variableからのedraw関連の設定などは特にCustom-modeバッ
** TODO 色/新しい色テキスト処理をミニバッファ入力方式にも適用する
今のままだとedraw-editorからhslやらが使えない。

** TODO 色/edraw-change-はedraw-replace-に変える
** TODO 色/edraw-color-syntax-serializeのoptionsを改善する
様々な形式を指定出来るようにする。もしくは元々の表記をより反映する。
- 細かい書式の改善
Expand Down Expand Up @@ -6442,3 +6441,5 @@ Color Syntax(色構文処理機能)による構文解析は、正規表現の作
- :color-name-schemeの廃止
- edraw-widget.el や edraw-property-editor.el への影響を調べる。 edraw-color-string-patterns-re なんかを使っている箇所があるんだけど。
- edraw-color.elのFrom StringとTo Stringはどうしよう。新しい仕組みと機能が重複するんだけど。できれば消したいけど、とにかく形式は何でもいいから文字列化・復帰できれば良い場合や効率重視の場合に利用価値があるかもしれない。その方向で整理すべき。
** DONE 色/edraw-change-はedraw-replace-に変える
CLOSED: [2025-02-11 Tue 23:20]

0 comments on commit 04887e5

Please sign in to comment.