[Emacs] Round transparency parameter to a nicer value
This commit is contained in:
		
							parent
							
								
									c3a8a7cf4a
								
							
						
					
					
						commit
						431750aa12
					
				@ -1088,13 +1088,18 @@ windows.
 | 
				
			|||||||
This one allows me to manipulate my Emacs frames’ background
 | 
					This one allows me to manipulate my Emacs frames’ background
 | 
				
			||||||
transparency.
 | 
					transparency.
 | 
				
			||||||
#+begin_src emacs-lisp
 | 
					#+begin_src emacs-lisp
 | 
				
			||||||
 | 
					(defun my/transparency-round (val)
 | 
				
			||||||
 | 
					  "Round VAL to the nearest tenth of an integer."
 | 
				
			||||||
 | 
					  (/ (round (* 10 val)) 10.0))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(defun my/increase-frame-alpha-background ()
 | 
					(defun my/increase-frame-alpha-background ()
 | 
				
			||||||
  "Increase current frame’s alpha background."
 | 
					  "Increase current frame’s alpha background."
 | 
				
			||||||
  (interactive)
 | 
					  (interactive)
 | 
				
			||||||
  (set-frame-parameter nil
 | 
					  (set-frame-parameter nil
 | 
				
			||||||
                       'alpha-background
 | 
					                       'alpha-background
 | 
				
			||||||
                       (min 1.0
 | 
					                       (my/transparency-round
 | 
				
			||||||
                            (+ (frame-parameter nil 'alpha-background) 0.1)))
 | 
					                        (min 1.0
 | 
				
			||||||
 | 
					                             (+ (frame-parameter nil 'alpha-background) 0.1))))
 | 
				
			||||||
  (message "%s" (frame-parameter nil 'alpha-background)))
 | 
					  (message "%s" (frame-parameter nil 'alpha-background)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(defun my/decrease-frame-alpha-background ()
 | 
					(defun my/decrease-frame-alpha-background ()
 | 
				
			||||||
@ -1102,8 +1107,9 @@ transparency.
 | 
				
			|||||||
  (interactive)
 | 
					  (interactive)
 | 
				
			||||||
  (set-frame-parameter nil
 | 
					  (set-frame-parameter nil
 | 
				
			||||||
                       'alpha-background
 | 
					                       'alpha-background
 | 
				
			||||||
                       (max 0.0
 | 
					                       (my/transparency-round
 | 
				
			||||||
                            (- (frame-parameter nil 'alpha-background) 0.1)))
 | 
					                        (max 0.0
 | 
				
			||||||
 | 
					                             (- (frame-parameter nil 'alpha-background) 0.1))))
 | 
				
			||||||
  (message "%s" (frame-parameter nil 'alpha-background)))
 | 
					  (message "%s" (frame-parameter nil 'alpha-background)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(defhydra my/modify-frame-alpha-background ()
 | 
					(defhydra my/modify-frame-alpha-background ()
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user