File: pysycache-click.scm

package info (click to toggle)
pysycache 3.1-3.2
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 50,004 kB
  • ctags: 472
  • sloc: python: 5,146; lisp: 1,152; sh: 102; makefile: 51; ansic: 4
file content (191 lines) | stat: -rw-r--r-- 6,460 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
;-------------------------------------------------------------------------------
; The GIMP -- an image manipulation program
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
;-------------------------------------------------------------------------------
; pysycache-click.scm : a script for make three thumbnails of the pictures to 
;                       search in the click activity
; Copyright (C) 2006 Vincent DEROO (vincent.pysycache@free.fr)
;-------------------------------------------------------------------------------
;
;
; This program is free software; you can redistribute it and/or 
; modify it under the terms of the GNU General Public License 
; as published by the Free Software Foundation; either version 2 
; of the License, or (at your option) any later version. 
; 
; This program is distributed in the hope that it will be useful, 
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details. 
; 
; You should have received a copy of the GNU General Public License 
; along with this program; if not, write to the Free Software 
; Foundation, Inc. : 
; 51 Franklin Street, Fifth Floor, Boston, MA02110-1301, USA
;-------------------------------------------------------------------------------




       
;-------------------------------------------------------------------------------
; 
;-------------------------------------------------------------------------------
(define (PutTheText
	ShadowColor
	TopText
	TopTextFont
	Left
	Top
	Size
	TypeOfPosition
	)
	(gimp-palette-set-foreground ShadowColor)
			(let* 
					(	
						(LayText
							(car
							   (gimp-text-fontname
								MyImg -1
								Left Top
								TopText
								-1
								TRUE
								Size PIXELS
								TopTextFont)
						   )
						)						
						(larg (car (gimp-drawable-width LayText)))
                        (haut (car (gimp-drawable-height LayText)))
					)
			
			
			(if (= TypeOfPosition 0)
				;top text
				(begin
				)
			)
			(if (= TypeOfPosition 1)
				;middle text
				(begin
					(gimp-layer-translate LayText (- (/ larg 2) ) (- (/ haut 2) ) )
				)
			)
			(if (= TypeOfPosition 2)
				;bottom text
				(begin					
					(gimp-layer-translate LayText (- larg) (- haut) )
				)
			)
			
			)
			
						
)
       
;-------------------------------------------------------------------------------
; 
;-------------------------------------------------------------------------------
(define (script-fu-pysycache-click
	img
	draw
	dirtarget
	prefixfile
	)
	

	(let*	(	;fichier modeles
				(FichierOn (string-append "" gimp-data-dir "/scripts/images/xxxx-on.png") )
				(FichierOff (string-append "" gimp-data-dir "/scripts/images/xxxx-off.png") )
				(FichierSel (string-append "" gimp-data-dir "/scripts/images/xxxx-selected.png") )
				
				;taille de l'image que l'on doit coller
				(ImgWidth (car (gimp-image-width img)))
				(ImgHeight (car (gimp-image-height img)))
				(filesvgon  (string-append dirtarget "\\" prefixfile "-on.png"  )) 
				(filesvgoff  (string-append dirtarget "\\" prefixfile "-off.png"  )) 
				(filesvgsel  (string-append dirtarget "\\" prefixfile "-selected.png"  )) 
			)

			(if (= ImgWidth ImgHeight )
				(begin
					;------------ meme hauteur et largeur ----------------------
					;------ eventuellement mettre a la taille de 50 x 50 -------
					(if (= ImgWidth 50 )
						(begin
						)
						(begin
							(gimp-image-scale img 50 50)
						)
					)
					
					;------------------ ouvrir les fichiers --------------------
					(set! MyImgOn (car (gimp-file-load RUN-NONINTERACTIVE FichierOn FichierOn)))
					(set! MyImgOff (car (gimp-file-load RUN-NONINTERACTIVE FichierOff FichierOff)))
					(set! MyImgSel (car (gimp-file-load RUN-NONINTERACTIVE FichierSel FichierSel)))			
			
					;--------------------- image on ----------------------------
					(set! MyLayOn (car (gimp-layer-new-from-drawable draw MyImgOn)))
					(gimp-image-add-layer MyImgOn MyLayOn -1)
					(gimp-layer-translate MyLayOn 34 0)
					(gimp-image-merge-visible-layers MyImgOn 1)		
					
					
							
			
					;--------------------- image off ---------------------------
					(set! MyImgDbl (car (gimp-image-duplicate img)))
					;(MyDraw (car (gimp-image-get-active-drawable MyImg)))
					(gimp-image-convert-grayscale MyImgDbl)
					(set! MyDraw (car (gimp-image-get-active-drawable MyImgDbl)))
					(set! MyLayOff (car (gimp-layer-new-from-drawable MyDraw MyImgOff)))
					(gimp-image-add-layer MyImgOff MyLayOff -1)
					(gimp-layer-translate MyLayOff 34 0)
					(gimp-image-merge-visible-layers MyImgOff 1)	
			
					;----------------------- image Sel -------------------------
					(set! MyLaySel (car (gimp-layer-new-from-drawable MyDraw MyImgSel)))
					(gimp-image-add-layer MyImgSel MyLaySel -1)
					(gimp-layer-translate MyLaySel 34 0)
					(gimp-image-merge-visible-layers MyImgSel 1)	
					
					;----------------------- affichage -------------------------
					(set! MyDrawOn (car (gimp-image-get-active-drawable MyImgOn)))
					(set! MyDrawOff (car (gimp-image-get-active-drawable MyImgOff)))
					(set! MyDrawSel (car (gimp-image-get-active-drawable MyImgSel)))
					(gimp-file-save RUN-NONINTERACTIVE MyImgOn MyDrawOn filesvgon filesvgon)
					(gimp-image-delete MyImgOn)
					(gimp-file-save RUN-NONINTERACTIVE MyImgOff MyDrawOff filesvgoff filesvgoff)
					(gimp-image-delete MyImgOff)
					(gimp-file-save RUN-NONINTERACTIVE MyImgSel MyDrawSel filesvgsel filesvgsel)
					(gimp-image-delete MyImgSel)
					
					(gimp-image-delete MyImgDbl)
				)
				(begin
					(gimp-message "Picture must have the same width and height. Abort" )
				)
			)
	)
)


;-------------------------------------------------------------------------------
; Register in the Gimp menus
;-------------------------------------------------------------------------------
(script-fu-register "script-fu-pysycache-click"
		    _"<Image>/Script-Fu/Pysycache/Theme click..."
		    "Make the two thumbnails for the pictures to search in the click activity \
Pictures used for make thumbnail should have the same height and width"


		    "Vincent DEROO (contact.pysycache@free.fr)"
		    "Vincent DEROO"
		    "16/09/2006 - v 1.0"
		    "RGB GRAY RGBA GRAYA"

		    SF-IMAGE "Image" 0
			SF-DRAWABLE "Drawable" 0
		    SF-DIRNAME "Target directory" (string-append "" gimp-directory )
		    SF-STRING "File prefix" "image000"
)