; Script-Fu Motif_Geometrique_1.scm
; Download :
;
; Copyright (C) 2013 samj (
http://aljacom.com/~gmic/ )
;
; Licence GPL
; Ce fichier est le Script-Fu "Motif_Geometrique_1.scm" pour Gimp.
; Ce Script-Fu "Motif_Geometrique_1.scm" est un logiciel libre ; vous pouvez
le redistribuer ou le modifier suivant les termes de la GNU General Public License
; telle que publiée par la Free Software Foundation ; soit la version 3 de la
licence, soit (à votre gré) toute version ultérieure.
; Ce Script-Fu "Motif_Geometrique_1.scm" est distribué dans l'espoir qu'il
sera utile, mais SANS AUCUNE GARANTIE ;
; pas même la garantie implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN
OBJECTIF PARTICULIER.
; Consultez la GNU General Public License pour plus de détails.
; Vous devez avoir reçu une copie de la GNU General Public License en même
temps que GIMP ; si ce n'est pas le cas, consultez <http://www.gnu.org/licenses>
;
; Ce fichier Motif_Geometrique.scm est édité avec Notepad++
http://notepad-plus-plus.org/
;
;
; Version 20130403 ajour ruban
; Version 20130402
;
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;
;
; Accès sur l'image par :
;
; Filters > Render > Pattern > 3D Motif Geometrique ...
;
;
;
;
; Principe :
; H1 H2
; ___ ___
; V1 | |
; V2 | |
; V3 | |
; V4 |___ ___|
;
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;
;*******************************************************************************************
***********
; FONCTION POUR DESSINER LE MOTIF
;*******************************************************************************************
***********
(define
(
Fonction_Motif_Geometrique_3D_samj
image
drawable
Origine_H
H1
H2
V1
V2
V3
V4
Color_1
Color_2
Color_3
*points*
)
(let*
(
;; rien
)
; triangle haut gauche
(set! *points* (cons-array 6 'double))
; déterminer les coordonnées des 3 points
(vector-set! *points* 0 Origine_H ) ; x0
(vector-set! *points* 1 0 ) ; y0
(vector-set! *points* 2 (+ Origine_H H1) ) ; x1
(vector-set! *points* 3 0 ) ; y1
(vector-set! *points* 4 Origine_H ) ; x2
(vector-set! *points* 5 V1 ) ; y2
(gimp-image-select-polygon
image ; image
2 ; operation
6 ; num-segs
*points* ; segs
)
(gimp-context-set-foreground Color_3)
(gimp-edit-bucket-fill drawable 0 0 100 0 FALSE 0 0)
(gimp-selection-none image)
; losange haut gauche
(set! *points* (cons-array 8 'double))
; déterminer les coordonnées des 4 points
(vector-set! *points* 0 Origine_H ) ; x0
(vector-set! *points* 1 V1 ) ; y0
(vector-set! *points* 2 (+ Origine_H H1) ) ; x1
(vector-set! *points* 3 0 ) ; y1
(vector-set! *points* 4 (+ Origine_H H1) ) ; x2
(vector-set! *points* 5 V1 ) ; y2
(vector-set! *points* 6 Origine_H ) ; x3
(vector-set! *points* 7 (+ V1 V2) ) ; y3
(gimp-image-select-polygon
image ; image
2 ; operation
8 ; num-segs
*points* ; segs
)
(gimp-context-set-foreground Color_1)
(gimp-edit-bucket-fill drawable 0 0 100 0 FALSE 0 0)
(gimp-selection-none image)
; losange milieu
(set! *points* (cons-array 8 'double))
; déterminer les coordonnées des 4 points
(vector-set! *points* 0 Origine_H ) ; x0
(vector-set! *points* 1 (+ V1 V2) ) ; y0
(vector-set! *points* 2 (+ Origine_H H1) ) ; x1
(vector-set! *points* 3 V1 ) ; y1
(vector-set! *points* 4 (+ (+ Origine_H H1) H2) ) ; x2
(vector-set! *points* 5 (+ V1 V2) ) ; y2
(vector-set! *points* 6 (+ Origine_H H1) ) ; x3
(vector-set! *points* 7 (+ V1 V2 V3) ) ; y3
(gimp-image-select-polygon
image ; image
2 ; operation
8 ; num-segs
*points* ; segs
)
(gimp-context-set-foreground Color_3)
(gimp-edit-bucket-fill drawable 0 0 100 0 FALSE 0 0)
(gimp-selection-none image)
; losange bas gauche
(set! *points* (cons-array 8 'double))
; déterminer les coordonnées des 4 points
(vector-set! *points* 0 Origine_H ) ; x0
(vector-set! *points* 1 (+ V1 V2) ) ; y0
(vector-set! *points* 2 (+ Origine_H H1) ) ; x1
(vector-set! *points* 3 (+ V1 V2 V3) ) ; y1
(vector-set! *points* 4 (+ Origine_H H1) ) ; x2
(vector-set! *points* 5 (+ V1 V2 V3 V4) ) ; y2
(vector-set! *points* 6 Origine_H ) ; x3
(vector-set! *points* 7 (+ V1 V2 V3) ) ; y3
(gimp-image-select-polygon
image ; image
2 ; operation
8 ; num-segs
*points* ; segs
)
(gimp-context-set-foreground Color_2)
(gimp-edit-bucket-fill drawable 0 0 100 0 FALSE 0 0)
(gimp-selection-none image)
; triangle bas gauche
(set! *points* (cons-array 6 'double))
; déterminer les coordonnées des 3 points
(vector-set! *points* 0 Origine_H ) ; x0
(vector-set! *points* 1 (+ V1 V2 V3) ) ; y0
(vector-set! *points* 2 (+ Origine_H H1) ) ; x1
(vector-set! *points* 3 (+ V1 V2 V3 V4) ) ; y1
(vector-set! *points* 4 Origine_H ) ; x2
(vector-set! *points* 5 (+ V1 V2 V3 V4) ) ; y2
(gimp-image-select-polygon
image ; image
2 ; operation
6 ; num-segs
*points* ; segs
)
(gimp-context-set-foreground Color_3)
(gimp-edit-bucket-fill drawable 0 0 100 0 FALSE 0 0)
(gimp-selection-none image)
; triangle haut droite
(set! *points* (cons-array 6 'double))
; déterminer les coordonnées des 3 points
(vector-set! *points* 0 (+ Origine_H H1) ) ; x0
(vector-set! *points* 1 0 )
; y0
(vector-set! *points* 2 (+ (+ Origine_H H1) H2) ) ; x1
(vector-set! *points* 3 0 )
; y1
(vector-set! *points* 4 (+ (+ Origine_H H1) H2) ) ; x2
(vector-set! *points* 5 V1 ) ; y2
(gimp-image-select-polygon
image ; image
2 ; operation
6 ; num-segs
*points* ; segs
)
(gimp-context-set-foreground Color_3)
(gimp-edit-bucket-fill drawable 0 0 100 0 FALSE 0 0)
(gimp-selection-none image)
; losange haut droite
(set! *points* (cons-array 8 'double))
; déterminer les coordonnées des 4 points
(vector-set! *points* 0 (+ Origine_H H1) ) ; x0
(vector-set! *points* 1 0 )
; y0
(vector-set! *points* 2 (+ (+ Origine_H H1) H2) ) ; x1
(vector-set! *points* 3 V1 ) ; y1
(vector-set! *points* 4 (+ (+ Origine_H H1) H2) ) ; x2
(vector-set! *points* 5 (+ V1 V2) ) ; y2
(vector-set! *points* 6 (+ Origine_H H1) ) ; x3
(vector-set! *points* 7 V1 ) ; y3
(gimp-image-select-polygon
image ; image
2 ; operation
8 ; num-segs
*points* ; segs
)
(gimp-context-set-foreground Color_2)
(gimp-edit-bucket-fill drawable 0 0 100 0 FALSE 0 0)
(gimp-selection-none image)
; losange bas droite
(set! *points* (cons-array 8 'double))
; déterminer les coordonnées des 4 points
(vector-set! *points* 0 (+ (+ Origine_H H1) H2) ) ; x0
(vector-set! *points* 1 (+ V1 V2) ) ; y0
(vector-set! *points* 2 (+ (+ Origine_H H1) H2) ) ; x1
(vector-set! *points* 3 (+ V1 V2 V3) ) ; y1
(vector-set! *points* 4 (+ Origine_H H1) ) ; x2
(vector-set! *points* 5 (+ V1 V2 V3 V4) ) ; y2
(vector-set! *points* 6 (+ Origine_H H1) ) ; x3
(vector-set! *points* 7 (+ V1 V2 V3) ) ; y3
(gimp-image-select-polygon
image ; image
2 ; operation
8 ; num-segs
*points* ; segs
)
(gimp-context-set-foreground Color_1)
(gimp-edit-bucket-fill drawable 0 0 100 0 FALSE 0 0)
(gimp-selection-none image)
; triangle bas droite
(set! *points* (cons-array 6 'double))
; déterminer les coordonnées des 3 points
(vector-set! *points* 0 (+ (+ Origine_H H1) H2) ) ; x0
(vector-set! *points* 1 (+ V1 V2 V3) ) ; y0
(vector-set! *points* 2 (+ (+ Origine_H H1) H2) ) ; x1
(vector-set! *points* 3 (+ V1 V2 V3 V4) ) ; y1
(vector-set! *points* 4 (+ Origine_H H1) ) ; x2
(vector-set! *points* 5 (+ V1 V2 V3 V4) ) ; y2
(gimp-image-select-polygon
image ; image
2 ; operation
6 ; num-segs
*points* ; segs
)
(gimp-context-set-foreground Color_3)
(gimp-edit-bucket-fill drawable 0 0 100 0 FALSE 0 0)
(gimp-selection-none image)
)
)
;*******************************************************************************************
***********
;
;*******************************************************************************************
***********
;*******************************************************************************************
***********
; SCRIPT PRINCIPAL
;*******************************************************************************************
***********
(define
(
Motif_Geometrique_3D_samj
H1
H2
V1
V2
V3
V4
Color_1
Color_2
Color_3
Ribbon
Save_Pattern
Object_Name
)
(let*
(
(message (car (gimp-message-get-handler)))
(old_context_transform_direction (car (gimp-context-get-transform-
direction)))
(old_context_interpolation (car (gimp-context-get-interpolation)))
(old_context_recursion (car (gimp-context-get-transform-recursion)))
(old_context_transform_resize (car (gimp-context-get-transform-
resize)))
(old-fg (car (gimp-context-get-foreground)))
(old-bg (car (gimp-context-get-background)))
(old_context-antialias (car (gimp-context-get-antialias)))
(old_context-feather (car (gimp-context-get-feather)))
(old_context-feather-radiusx (car (gimp-context-get-feather-
radius)))
(old_context-feather-radiusy (cadr (gimp-context-get-feather-
radius)))
(old_context-sample-merged (car (gimp-context-get-sample-merged)))
(old_ontext-sample-criterion (car (gimp-context-get-sample-
criterion)))
(old_context-sample-threshold (car (gimp-context-get-sample-
threshold)))
(old_context-sample-transparent (car (gimp-context-get-sample-
transparent)))
(old-brush-size (car (gimp-context-get-brush-size)))
(old-brush-aspect-ratio (car (gimp-context-get-brush-aspect-ratio)))
(old-brush-angle (car (gimp-context-get-brush-angle)))
(old-brush-name (car (gimp-context-get-brush)))
(image)
(calque_motif)
(path)
(origine_log3 0)
(H1_log3 0)
(H2_log3 0)
(origine_log4 0)
(H1_log4 0)
(H2_log4 0)
(origine_log5 0)
(H1_log5 0)
(H2_log5 0)
(origine_log6 0)
(H1_log6 0)
(H2_log6 0)
(width 0)
(origine_symetrie 0)
)
;*******************************************************************************************
***********
; Tracer Origine 0
;*******************************************************************************************
***********
(if (= Ribbon 0)
(begin
(set! width (+ H1 H2) )
; créer une image pour le motif
(set! image (car (gimp-image-new width (+ V1 V2 V3 V4) 0)))
; créer le calque calque_motif
(set! calque_motif (car (gimp-layer-new image width (+ V1 V2
V3 V4) 1 "calque_motif" 100 0)))
(gimp-undo-push-group-start image)
(gimp-image-insert-layer image calque_motif -1 0)
(gimp-layer-add-alpha calque_motif)
(Fonction_Motif_Geometrique_3D_samj
image ; image
calque_motif ; drawable
0 ; Origine_H
H1 ; H1
H2 ; H2
V1 ; V1
V2 ; V2
V3 ; V3
V4 ; V4
Color_1 ; Color_1
Color_2 ; Color_2
Color_3 ; Color_3
0 ; *points*
)
)
)
;*******************************************************************************************
***********
; RUBAN
;*******************************************************************************************
***********
(if (> Ribbon 0)
(begin
(if (= Ribbon 1)
(begin
(set! H1 (round (/ H1 (log 6) ) ) )
(set! H2 (round (/ H2 (log 6) ) ) )
(set! V1 (round (/ V1 (log 6) ) ) )
(set! V2 (round (/ V2 (log 6) ) ) )
(set! V3 (round (/ V3 (log 6) ) ) )
(set! V4 (round (/ V4 (log 6) ) ) )
)
)
(set! H1_log3 (round (* H1 (log 3) ) ) )
(set! H2_log3 (round (* H2 (log 3) ) ) )
(set! H1_log4 (round (* H1 (log 4) ) ) )
(set! H2_log4 (round (* H2 (log 4) ) ) )
(set! H1_log5 (round (* H1 (log 5) ) ) )
(set! H2_log5 (round (* H2 (log 5) ) ) )
(set! H1_log6 (round (* H1 (log 6) ) ) )
(set! H2_log6 (round (* H2 (log 6) ) ) )
(set! origine_log3 0)
(set! origine_log4 (+ origine_log3 H1_log3 H2_log3) )
(set! origine_log5 (+ origine_log4 H1_log4 H2_log4) )
(set! origine_log6 (+ origine_log5 H1_log5 H2_log5) )
(set! width (* 2 (+ origine_log6 H1_log6 H2_log6) ) )
; créer une image pour le motif
(set! image (car (gimp-image-new width (+ V1 V2 V3 V4) 0)))
; créer le calque calque_motif
(set! calque_motif (car (gimp-layer-new image width (+ V1 V2
V3 V4) 1 "calque_motif" 100 0)))
(gimp-undo-push-group-start image)
(gimp-image-insert-layer image calque_motif -1 0)
(gimp-layer-add-alpha calque_motif)
(Fonction_Motif_Geometrique_3D_samj
image ; image
calque_motif ; drawable
origine_log3 ; Origine_H
H1_log3 ; H1
H2_log3 ; H2
V1 ; V1
V2 ; V2
V3 ; V3
V4 ; V4
Color_1 ; Color_1
Color_2 ; Color_2
Color_3 ; Color_3
0 ; *points*
)
(Fonction_Motif_Geometrique_3D_samj
image ; image
calque_motif ; drawable
origine_log4 ; Origine_H
H1_log4 ; H1
H2_log4 ; H2
V1 ; V1
V2 ; V2
V3 ; V3
V4 ; V4
Color_1 ; Color_1
Color_2 ; Color_2
Color_3 ; Color_3
0 ; *points*
)
(Fonction_Motif_Geometrique_3D_samj
image ; image
calque_motif ; drawable
origine_log5 ; Origine_H
H1_log5 ; H1
H2_log5 ; H2
V1 ; V1
V2 ; V2
V3 ; V3
V4 ; V4
Color_1 ; Color_1
Color_2 ; Color_2
Color_3 ; Color_3
0 ; *points*
)
(Fonction_Motif_Geometrique_1_3D_samj
image ; image
calque_motif ; drawable
origine_log6 ; Origine_H
H1_log6 ; H1
H2_log6 ; H2
V1 ; V1
V2 ; V2
V3 ; V3
V4 ; V4
Color_1 ; Color_1
Color_2 ; Color_2
Color_3 ; Color_3
0 ; *points*
)
;Symétrie
(set! origine_symetrie (+ origine_log6 H1_log6 H2_log6 ) )
(Fonction_Motif_Geometrique_3D_samj
image ; image
calque_motif ; drawable
origine_symetrie ; Origine_H
H2_log6 ; H1
H1_log6 ; H2
V1 ; V1
V2 ; V2
V3 ; V3
V4 ; V4
Color_1 ; Color_1
Color_2 ; Color_2
Color_3 ; Color_3
0 ; *points*
)
(set! origine_symetrie (+ origine_symetrie H1_log6 H2_log6
) )
(Fonction_Motif_Geometrique_3D_samj
image ; image
calque_motif ; drawable
origine_symetrie ; Origine_H
H2_log5 ; H1
H1_log5 ; H2
V1 ; V1
V2 ; V2
V3 ; V3
V4 ; V4
Color_1 ; Color_1
Color_2 ; Color_2
Color_3 ; Color_3
0 ; *points*
)
(set! origine_symetrie (+ origine_symetrie H1_log5 H2_log5
) )
(Fonction_Motif_Geometrique_3D_samj
image ; image
calque_motif ; drawable
origine_symetrie ; Origine_H
H2_log4 ; H1
H1_log4 ; H2
V1 ; V1
V2 ; V2
V3 ; V3
V4 ; V4
Color_1 ; Color_1
Color_2 ; Color_2
Color_3 ; Color_3
0 ; *points*
)
(set! origine_symetrie (+ origine_symetrie H1_log4 H2_log4
) )
(Fonction_Motif_Geometrique_3D_samj
image ; image
calque_motif ; drawable
origine_symetrie ; Origine_H
H2_log3 ; H1
H1_log3 ; H2
V1 ; V1
V2 ; V2
V3 ; V3
V4 ; V4
Color_1 ; Color_1
Color_2 ; Color_2
Color_3 ; Color_3
0 ; *points*
)
; limite en largeur
(if (> width 512)
(begin
(set! width 512)
(gimp-image-scale image width (+ V1 V2 V3
V4))
)
)
)
)
;*******************************************************************************************
***********
;
;*******************************************************************************************
***********
(if (= Save_Pattern 1)
(begin
; déterminer le chemin complet du motif à sauvegarder
(set! path (string-append gimp-directory "/patterns/"
(strcat Object_Name "_" (number->string width ) "_" (number->string (+ V1 V2 V3 V4) )
".pat") ) )
; sauvegarder le motif sous :
"Object_Name"_"Selection_Size".pat
(file-pat-save 1 image (car (gimp-image-get-active-layer
image)) path path (strcat Object_Name "_" (number->string width ) "_" (number->string (+ V1
V2 V3 V4) ) ) )
; mettre à jour les motifs dans Gimp
(gimp-patterns-refresh)
; choisir le motif comme motif actif
(gimp-context-set-pattern (strcat Object_Name "_" (number-
>string width ) "_" (number->string (+ V1 V2 V3 V4) ) ) )
(gimp-image-delete image)
(gimp-message (string-append "Pattern Path :\n" path
"\nPattern Name:\n" Object_Name "_" (number->string width ) "_" (number->string (+ V1 V2 V3
V4) ) ) )
)
;else
(begin
(gimp-item-set-visible calque_motif TRUE)
; afficher l'image
(gimp-display-new image)
(gimp-undo-push-group-end image)
(gimp-displays-flush)
)
)
;*******************************************************************************************
***********
;
;*******************************************************************************************
***********
;*******************************************************************************************
***********
;; rétablir le mode message
(gimp-message-set-handler message)
(gimp-context-set-transform-direction old_context_transform_direction )
(gimp-context-set-interpolation old_context_interpolation)
(gimp-context-set-transform-recursion old_context_recursion)
(gimp-context-set-transform-resize old_context_transform_resize)
(gimp-context-set-background old-bg)
(gimp-context-set-foreground old-fg)
(gimp-context-set-antialias old_context-antialias)
(gimp-context-set-feather old_context-feather)
(gimp-context-set-feather-radius old_context-feather-radiusx old_context-
feather-radiusy)
(gimp-context-set-sample-merged old_context-sample-merged)
(gimp-context-set-sample-criterion old_ontext-sample-criterion)
(gimp-context-set-sample-threshold old_context-sample-threshold)
(gimp-context-set-sample-transparent old_context-sample-transparent)
(gimp-context-set-brush-default-size)
(gimp-context-set-brush-size old-brush-size)
(gimp-context-set-brush-aspect-ratio old-brush-aspect-ratio)
(gimp-context-set-brush-angle old-brush-angle)
(gimp-context-set-brush old-brush-name)
)
)
(script-fu-register "Motif_Geometrique_3D_samj"
_"<Image>/Filters/Render/Pattern/3D Motif Geometrique ..."
"3D pattern made of 3 colours"
"samj"
"samj"
"20130403"
""
SF-ADJUSTMENT "X 1 " '(16 1 128 1 5 0 1)
SF-ADJUSTMENT "X 2 " '(16 1 128 1 5 0 1)
SF-ADJUSTMENT "V 1 " '(16 1 64 1 5 0 1)
SF-ADJUSTMENT "V 2 " '(16 1 64 1 5 0 1)
SF-ADJUSTMENT "V 3 " '(16 1 64 1 5 0 1)
SF-ADJUSTMENT "V 4 " '(16 1 64 1 5 0 1)
SF-COLOR "Color 1 " '(255 255 255)
SF-COLOR "Color 2 " '(128 128 128)
SF-COLOR "Color 3 " '(0 0 0)
SF-OPTION "Ribbon (Wmax=512px) " '("A Without" "B
Ribbon small" "C Large ribbon")
SF-TOGGLE "Save Pattern" FALSE
SF-STRING "Pattern Name to save (DO NOT USE SPACES)
" "3d_Motif_Geometrique"
)
;; FIN