From 00abb6f86489dbac1686f47759429a7e4f0ddd08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20R=2E=20Pietraszczyk?= Date: Mon, 10 Feb 2025 17:30:08 +0100 Subject: Init again --- 3.0/przem-add-background-under-text-v3.scm | 86 ++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 3.0/przem-add-background-under-text-v3.scm (limited to '3.0/przem-add-background-under-text-v3.scm') diff --git a/3.0/przem-add-background-under-text-v3.scm b/3.0/przem-add-background-under-text-v3.scm new file mode 100644 index 0000000..212a665 --- /dev/null +++ b/3.0/przem-add-background-under-text-v3.scm @@ -0,0 +1,86 @@ +; przem-add-background-under-text-v3 - Script-fu dodający podpis z tłem +; author: PRP +; licencja: Public Domain +; Gdańsk - 06-02-2025 +; ver. 1.250210-0~alpha for Gimp 3.0 + +(define (przem-add-background-under-text-v3 image drawable text font font-size color background-transparency opacity) + + (gimp-image-undo-group-start image) + + (let* ( + (image-width (car (gimp-image-get-width image))) + (image-height (car (gimp-image-get-height image))) + ;(text-extents (gimp-text-get-extents-fontname text font-size 0 font)) + (text-extents (gimp-text-get-extents-font text font-size font)) + (text-width (car text-extents)) + (text-height (cadr text-extents)) + (pos-x (- (- image-width text-width) 40)) + (pos-y (- image-height text-height)) + (bg-x-left (- pos-x 10)) + (bg-x-right (+ text-width 10)) + ;(text-layer (car (gimp-text-fontname image -1 0 0 text 0 TRUE font-size 0 font))) + (text-layer (car(gimp-text-font image -1 0 0 text 0 TRUE font-size font))) + (bg-layer (car (gimp-layer-new image bg-x-right text-height RGBA-IMAGE "Background" 100 LAYER-MODE-NORMAL))) + (is-nocolorful (car (gimp-drawable-is-gray drawable))) ; czy obraz jest w odcieniach szarości + ) + + ; Ustawienie koloru tła + (gimp-context-set-background color) + (gimp-drawable-fill bg-layer FILL-BACKGROUND) + (gimp-layer-set-opacity bg-layer opacity) + + ; jeśli obraz jest szary to konwertuje go na RGB - tak na sztukę + (if (= is-nocolorful TRUE) + (gimp-image-convert-rgb image) + ) + + ; Dodanie warstwy tła pod tekstem + (gimp-image-insert-layer image bg-layer 0 -1) + + ;(gimp-layer-translate bg-layer bg-x-left pos-y) + (gimp-selection-translate image bg-layer bg-x-left pos-y) + + (if (= background-transparency TRUE) + (begin + (gimp-drawable-fill bg-layer FILL-TRANSPARENT) + ) + (begin ; else + ) + ) + + ; Ustawienie pozycji tekstu + (gimp-layer-set-offsets text-layer pos-x pos-y) + + ; Przesuń warstwę tekstową na górę stosu warstw + (gimp-image-raise-item-to-top image text-layer) + + ; Scalanie warstw + (gimp-image-merge-down image text-layer CLIP-TO-IMAGE) + + ; Aktualizacja widoku + (gimp-displays-flush) + + (gimp-image-undo-group-end image) ; Zakończ grupę operacji undo + ) +) + +(script-fu-register "przem-add-background-under-text-v3" + _"Add Background Under Text" + _"Dodaje kolorowe tło pod tekstem z możliwością wyboru czcionki i rozmiaru." + "Przemysław R. Pietraszczyk" + "Public Domain" + "2025-02-06" + "RGB* GRAY*" + SF-IMAGE "Image" 0 + SF-DRAWABLE "Drawable" 0 + SF-STRING "Text" "Doda Elektroda" + SF-FONT "Font" "Sans-serif" + SF-ADJUSTMENT "Font Size" '(50 1 1000 1 10 0 1) + SF-COLOR "Background Color" '(255 215 0) + SF-TOGGLE "Background Transparency" FALSE + SF-ADJUSTMENT "Transparency Value" '(100 1 100 1 10 0 1) +) + +(script-fu-menu-register "przem-add-background-under-text-v3" + "/Filters/PIETRASZCZYK/") -- cgit v1.2.3