¤@ӳ̲³æªºScript_Fu¡Ghi.scm
µ{¦¡ªº¥Dn¬[ºc
l ¥»µ{¦¡hi.scmקï¦Ûslime.scm¡A§R¥h¤j³¡¤Àµ{¦¡½X¡C l °õ¦æ[Gimp] -> Xtrns -> Script-Fu -> hi·|²£¥Í¥k¹Ï l µ{¦¡¥Dn¥Ñ¨â³¡¥÷©Ò¥D²Õ¦¨¡G 1¨ì13¦æ¡G¥Hdefine¨ç¼Æ©w¸qscript-fu-hi¨ç¼Æ¡C 15¨ì26¦æ¡G¥Hscript-fu-register¨ç¼Æ¦V¸ê®Æ®wµù¥U¨ç¼Æ¡C |
hi.scm°õ¦æµ²ªG |
l ¥Hgimp-text-fontname¨ç¼Æ¼g¤WHi! l ¥Hgimp-image-resize¨ç¼Æ±N¼v¹³§ï¬°¾A·í¤j¤p¡C |
1: (define (script-fu-hi text size font) 2: (let* ((img (car
(gimp-image-new 256 256 RGB))) 3:
(text-layer (car (gimp-text-fontname img -1 0 0 text 30 TRUE size
PIXELS font))) 4: (width
(car (gimp-drawable-width text-layer))) 5: (height
(car (gimp-drawable-height text-layer))) 6: ) 7: ;; Resize
the image 8:
(gimp-image-resize img width height 0 0) 9: 10: ;;
display 11: (gimp-display-new img) 12: ) 13: ) 14: |
ª`·N¬A¸¹¦¨¹ï l 1¨ì13¦æ¡G¥Hdefine¨ç¼Æ©w¸qscript-fu-hi¨ç¼Æ¡C¬G²Ä1¦æªº²Ä1Ó¥ª¬A¸¹»P²Ä13¦æªº¥k¬A¸¹¦¨¹ï¡C l 15¨ì26¦æ¡G¥Hscript-fu-register¨ç¼Æ¦V¸ê®Æ®wµù¥Uscript-fu-hi¨ç¼Æ¡C¬G²Ä15¦æªº²Ä1Ó¥ª¬A¸¹»P²Ä26¦æªº¥k¬A¸¹¦¨¹ï¡C l 2¨ì12¦æ¡G¥Hlet*¨ç¼Æ«Å§i°Ï°ìÅܼƨèϥΥ¦¡C¬G²Ä2¦æªº²Ä1Ó¥ª¬A¸¹»P²Ä12¦æªº¥k¬A¸¹¦¨¹ï¡C l 2¨ì6¦æ¡G«Å§i°Ï°ìÅܼơA¥Ñ©ólet*¨ç¼Æ»yªk¡G(let* (variables) expressions)¡A¬G²Ä2¦æªº²Ä2Ó¥ª¬A¸¹»P²Ä6¦æªº¥k¬A¸¹¦¨¹ï¡C l Y§A¦Û¤v¼gSchemeªºµ{¦¡¡A¥²¶·ª`·N¬A¸¹ªº¦¨¹ï¡A³o¬O³Ì®e©ö¥X¿ùªº¦a¤è¡C |
|
15: (script-fu-register "script-fu-hi" 16: "<Toolbox>/Xtns/Script-Fu/hi" 17: "Say
hi..." 18: 19:
"Modified by Samuel Li (sclee@eagle.ee.ntu.edu.tw)" 20:
"Jean-Philippe
Turcat (cmrjpt@soc.staffs.ac.uk)" 21:
"04/21/2001" 22:
"" 23:
SF-STRING "Text String" "Hi!" 24:
SF-ADJUSTMENT "Font Size (pixels)" '(72 2 1000 1 10 0 1) 25:
SF-FONT "Font"
"-*-ComicsCarToon-*-r-*-*-24-*-*-*-p-*-*-*" 26: ) |
¿ï³æ¦b¨º¸Ì¡H l ²Ä16¦æ¡G<Toolbox>ªí¥Ü³o¬O¤@Ó¤£¥²¦³¼v¹³µøµ¡´N¥i°õ¦æªºScript_Fu¡A¬Û¹ï©ó<Image>¡C<Toolbox>ªí¥Ü³oScript_Fuµ{¦¡¦bGimp¤u¨ã²°¤¤ªºXtrns¿ï³æªº¤l¿ï³æ¤¤¡C l <Image>ªí¥ÜÂI¤@¤U¼v¹³µøµ¡«ö·Æ¹«¥kÁä¥X²{¤@¿ï³æ¡AScript_Fuµ{¦¡¦b³o¿ï³æªº¤l¿ï³æ¤¤¡C |
script-fu-register¨ç¼Æªº«e7ӰѼơG
1 |
Name |
§A©Ònµù¥Uªº¨ç¼Æ¦WºÙ¡A¤£¯à»P¤wµù¥Uªº¨ç¼Æ¦P¦W¡C |
Hi.scm©Òµù¥Uªº¨ç¼Æ¦WºÙ¬° "script-fu-hi" |
2 |
Location |
¿ï³æ©Ò¦bªº¦ì¸m¡C |
"<Toolbox>/Xtns/Script-Fu/hi" |
3 |
Description |
¥H¤@¬q¤å¦r´yz§Aªºscriptªº¥\¯à¡C |
"Say hi..." |
4 |
Author |
scriptªº§@ªÌªº©m¦W¡C |
"Modified by Samuel Li " |
5 |
Copyright |
ª©Åv«Å§i¡C |
"Jean-Philippe Turcat " |
6 |
Date |
Scriptµ{¦¡³Ì«á¤@ª©ªº¼g§@§¹¦¨¤é´Á¡C |
"04/21/2001" |
7 |
Type |
³oÓScriptµ{¦¡©Ò³B²zªº¼v¹³ªº¦â±m¼Ò¦¡¡A¦â±m¼Ò¦¡¦³RGB¡BRGBA¡BGRAY¡BINDEXED¡BINDEXEDA¡C |
"" hi.scm¦Û¤v·|²£¥Í¤@Ó¼v¹³ª«¥ó¡A¬G³oӰѼƬ°ªÅ¥ÕÈ¡C |
About¹ï¸Ü²°
About¹ï¸Ü²° |
l 17¨ì21¦æ¡G¦bScript-Fu:hiªºAbout¹ï¸Ü²°¤º¦³¹ïÀ³ªº¸ê®Æ¡C l ¬Û·í©óscript-fu-register¨ç¼Æ²Ä3¡B4¡B5¡B6ӰѼơC |
script-fu-register¨ç¼Æªº²Ä8ӰѼƻP¤§«áªº°Ñ¼Æ
²Ä8ӰѼƻP¤§«áªº°Ñ¼Æ¡A¤£©wӼơA¬O¥Î¨Ó³]©w°Ñ¼Æ¿é¤J¹ï¸Ü²°¤ºªº°Ñ¼Æ¡C°Ñ¼Æ¿é¤J¹ï¸Ü²°¤ºªº¸ê®Æ³Ì«á¥Ñµù¥U¨ç¼Æ¡]²Ä1ӰѼơ^©Ò±µ¦¬¡A§@¬°µù¥U¨ç¼Æªº¿é¤JÅܼơC
²Ä8ӰѼƻP¤§«áªº°Ñ¼Æ¨ä³]©wªº®æ¦¡¬°¡GParam-type "Prompt text" "default value"¡A¡]°Ñ¼Æ«¬ºA "´£¥Ü¤å¦r" "¹w³]È"¡^¡C°Ñ¼Æ«¬ºA·t¥Ü¤Fµù¥U¨ç¼Æªº¿é¤JÅܼƪºÅܼƫ¬ºA¡C
°Ñ¼Æ¿é¤J¹ï¸Ü²° |
l 23¨ì25¦æ¡G¦bScript-Fu:hiªº°Ñ¼Æ¿é¤J¹ï¸Ü²°¤º¦³¹ïÀ³ªº¸ê®Æ¡C l ¬Û·í©óscript-fu-register¨ç¼Æ²Ä8¡B9¡B10ӰѼơC |
23¦æ¡GSF-STRING "Text String" "Hi!" l SF-STRING¡Aªí¥Ü·|¦b°Ñ¼Æ¿é¤J¹ï¸Ü²°¤W²£¥Í¤@Ó¦r¦êªº¤å¦r¿é¤J®Ø¡C l "Text String"¡A¬°»²§U»¡©úªº¤å¦r¡C l "Gimp"¡Aªí¤å¦r¿é¤J®Ø¤º¹w³]ªº¦r¦ê¬°Gimp¡C |
|
24¦æ¡GSF-ADJUSTMENT "Font Size (pixels)" '(72 2 1000 1 10 0 1) l SF-ADJUSTMENT¡A¦b¹ï¸Ü²°¤W²£¥Í¤@Ó¥i¤W¤U½Õ¾ã¤j¤pȪº±±¨î¤¸¥ó¡C l "Font Size (pixels)"¡A¬°»²§U»¡©úªº¤å¦r¡C l
'(72 2 1000 1 10 0 1)¡A¦r§Î¤j¤p¹w³]È72¡B³Ì¤pÈ2¡B³Ì¤jÈ1000¡B¨C¦¸½Õ¾ã±±¨î¤¸¥ó¼W¥[È1¡C |
|
25¦æ¡GSF-FONT "Font" "-*-ComicsCarToon-*-r-*-*-24-*-*-*-p-*-*-*") l SF-FONT¡A¦b¹ï¸Ü²°¤W²£¥Í¤@Ó¦r«¬³]©w«ö¶s¡A«ö¤U«ö¶s¥i±Ò°Ê³]©w¦r«¬ªº¹ï¸Ü²°¡C l "Font"¡A¬°»²§U»¡©úªº¤å¦r¡C l
"-*-ComicsCarToon-*-r-*-*-24-*-*-*-p-*-*-*")¡A¬°¹w³]¦r«¬¡AGimpªº¦r«¬¬O¨Ï¥ÎX11ªº®æ¦¡¡C |
|
²Ä1¦æ¡G(define (script-fu-hi text size font) Âǥѹï¸Ü²°©Ò¿é¤Jªº°Ñ¼Æ¡A³]©wscript-fu-hi¨ç¦¡ªºtext¡Bsize¡Bfont³o¤TÓÅܼơC |
|
OK«ö¶s¡G «ö¤U¹ï¸Ü²°ªºOK«ö¶s«á¡AOK«ö¶s¤U¤èªº¤å¦rÅã¥Ü®Ø¤ºªº¤å¦r·|§Ö³t§ïÅÜ¡A¦¹®Éscript-fu-hi¨ç¼Æ³Q©I¥s¡A¶Ç¤JÅܼƳ]©w¡Ahi.scm±q²Ä1¦æ°õ¦æ¨ì²Ä13¦æ¡C |
|
²Ä32¦æ¡G(gimp-display-new img) ¨q¥X³Ì«áªºµ²ªG¡A³z©ú©³¦âªºHi!¡C |
1 |
Name |
§A©Ònµù¥Uªº¨ç¼Æ¦WºÙ¡A¤£¯à»P¤wµù¥Uªº¨ç¼Æ¦P¦W¡C |
Hi.scm©Òµù¥Uªº¨ç¼Æ¦WºÙ¬° "script-fu-hi" |
2 |
Location |
¿ï³æ©Ò¦bªº¦ì¸m¡C |
"<Toolbox>/Xtns/Script-Fu/hi" |
3 |
Description |
¥H¤@¬q¤å¦r´yz§Aªºscriptªº¥\¯à¡C |
"Say hi..." |
4 |
Author |
scriptªº§@ªÌªº©m¦W¡C |
"Modified by Samuel Li " |
5 |
Copyright |
ª©Åv«Å§i¡C |
"Jean-Philippe Turcat " |
6 |
Date |
Scriptµ{¦¡³Ì«á¤@ª©ªº¼g§@§¹¦¨¤é´Á¡C |
"04/21/2001" |
7 |
Type |
³oÓScriptµ{¦¡©Ò³B²zªº¼v¹³ªº¦â±m¼Ò¦¡¡A¦â±m¼Ò¦¡¦³RGB¡BRGBA¡BGRAY¡BINDEXED¡BINDEXEDA¡C |
"" hi.scm¦Û¤v·|²£¥Í¤@Ó¼v¹³ª«¥ó¡A¬G³oӰѼƬ°ªÅ¥ÕÈ¡C |
2¦æ¨ì11¦æ¡G
l 2: (let* ((img (car (gimp-image-new 256 256 RGB)))
²£¥Í·s¼v¹³¤j¤p¬°256x256¡BRGB¼Ò¦¡¡A±N·s¼v¹³¦s¦bimgÅܼƤº¡C
l 3:(text-layer (car (gimp-text-fontname img -1 0 0 text 30 TRUE size PIXELS font)))
²£¥Í·s¤å¦r¹Ï¼h¡A±N·s¤å¦r¹Ï¼h¦s¦btext-layerÅܼƤº¡C
l 4: (width (car (gimp-drawable-width text-layer)))
¨Ï¥Îgimp-drawable-width±o¨ì¤å¦r¹Ï¼hªº¼e«×¨Ã¦s¦bwidthÅܼƤº¡C
l 5: (height (car (gimp-drawable-height text-layer) ))
¨Ï¥Îgimp-drawable-height±o¨ì¤å¦r¹Ï¼hªº°ª«×¦s¦bheightÅܼƤº¡C
l 8: (gimp-image-resize img width height 0 0)
±N¼v¹³§ï¬°¾A·í¤j¤p¡C
l 11: (gimp-display-new img)
²£¥Í¤@¼v¹³µøµ¡¡A¨q¥X¹Ï¤ù¨Ó¡C
DB Browser¤ºªº¸ê®Æ¡G
¦b¥»¤å¤¤¡A³\¦h¨ç¼Æªº¥\¯à¨S¦³¸ÑÄÀ²M·¡¡A¨ç¼Æªº°Ñ¼Æ¦p¦ó³]©w§¹¥þ¨S¦³¸ÑÄÀ¡C¤@¤Áªºµª®×³£¦bDB Browser¤º¡C
¦³¨ÇªF¦è½Ð¦h«ä¦Ò¡A¦Û¦æ»â·|¡C
l 2: (let* ((img (car (gimp-image-new 256 256 RGB)))
|
²£¥Í¼v¹³ª«¥ó¨Ã¤£¯à°¨¤W¨Ï¥Îgimp-display-new¨ÓÅã¥Ü¼v¹³¡A¼v¹³ª«¥ó¤@©wn¦³¹Ï¼h¤~¯à¦³ªF¦è¥iÅã¥Ü¡C gimp-layer-new¥i²£¥Í¹Ï¼h¡C |
l 3:(text-layer (car (gimp-text-fontname img -1 0 0 text 30 TRUE size PIXELS font)))
|
Gimpªº¦r«¬¬O¨Ï¥ÎX11ªº®æ¦¡¡C |
l 4: (width (car (gimp-drawable-width text-layer)))
|
¤°»ò¬Odrawable¡H ´N¬O¹Ï¼h¡C ¤@Ó¼v¹³¥i¥Ñ¦hӹϼh²Õ¦¨¡A²{¦b³Q¿ï¨ìªº¡A¥i¦b¨ä¤W§@¹Bºâªº¹Ï¼hºÙ¬°drawable¡C |
l 5: (height (car (gimp-drawable-height text-layer) ))
|
|
l 8: (gimp-image-resize img width height 0 0)
|
|
l 11: (gimp-display-new img)
|
¶}¤@Ó·sµøµ¡¨ÓÅã¥Ü¼v¹³¡C |