±qscript_fu¤¤¾Ç²ß¼v¹³³B²z§Þ¥©¡G¦³¥ú¼vªº²yÅé

 

scripts¥Ø¿ý¤U¦³¶W¹L100­Ó *.scmÀÉ¡A³o¨Ç¬O¾Ç²ß¼v¹³³B²z§Þ¥©ªº³Ì¦n±Ð§÷¡A¥H¤U§Ú­Ì¨Ó¬ã¨sSpencer Kimball©Ò¼gªºsphere.scmµ{¦¡¡C

        Ū¤F¥»¤å§A·|Åé·|¨ìº¥¼h¶ñ¦â¤u¨ãªº«Â¤OµL½a¡C

¤@¡B°õ¦æScript-Fu¡G

¦³¥ú¼vªº²yÅé

l          °õ¦æ[GIMP] -> Xtns -> Script_Fu -> Misc -> Sphere¨Ï¥Î¹w³]ªº°Ñ¼Æ¡GRadius³]100¡BLighting (degrees)³]45¡BShadow³]" TRUE"¡BBackground Color³]¶Â¦â¡BSphere Color³]¬õ¦â¡A²£¥Í¥ª¹Ï¡C

l          ¥ª¹Ï¥ú·½¦b45«×¨¤³B¡]¤¤¤ßªº¥k¤W¨¤¡^¡A¬G³±¼v¦b¥ª¤U¨¤¡C¦P®É¡A²yÅ骺¥ª¤U¨¤¸û·t¡C

l          ¦³¥ú¼vªº²yÅé¥Ñµo¥úªº²yÅé¡B³±¼v¡B¥Õ¦âªº­I´º©Ò²Õ¦¨¡C

l          »s§@®É¥u»Ý­n1­Ó¹Ï¼h¡A©ÎªÌ§A¤]¥i¥H¨Ï¥Î3­Ó¹Ï¼h¡C

l          ­Y¥u¥Î1­Ó¹Ï¼h¡A«h»s§@ªº¬yµ{¬°¡G¥Õ¦âªº­I´º -> ³±¼v -> ²yÅé¡C

l          sphere.scmµ{¦¡½X¡A¦³¤@¥bªºµ{¦¡½X¬O¦b­pºâ²yÅ骺¶ê¤ß¡B¥b®|¡B¥ú·½ªº¦ì¸m¡B³±¼vªº¦ì¸m»P¤j¤p¡C

 

        ¨Ï¥ÎGimp¹Ï§Î¬É­±¨Ó½s¿è¼v¹³ªº¨C­Ó°Ê§@³£¦³¬Û¹ïÀ³ªº¨ç¼Æ¡Agimp-edit-copy¡Bgimp-edit-paste¡Bgimp-edit-cut¹ïÀ³ªº«K¬O³Ì±`¨Ï¥Îªº¼v¹³½Æ»s¡B¼v¹³¶K¤W¡B¼v¹³°Å¤Uµ¥°Ê§@¡C

¥H¤U§Ú­Ì¨Ï¥ÎGimp¹Ï§Î¬É­±¡A¤@¨B¤@¨B§@¨Ó²£¥Í¦³¥ú¼vªº²yÅé¡CÂǥѳo¹Lµ{¨ÓÁA¸Ñµ{¦¡½Xªº·N«ä¡C

 

¤G¡B¨Ï¥ÎGimp¹Ï§Î¬É­±¡A¤@¨B¤@¨B§@

¨C­Ó¨BÆJ©Ò²£¥Íªº¼v¹³µøµ¡

¥H¹Ï§Î¨Ï¥ÎªÌ¤¶­±²£¥Í¦³¥ú¼vªº²yÅé¡A»Ý­nªº¨BÆJ¡G

¹ïÀ³¨ìsphere.scmµ{¦¡½X¤¤ªº¨ç¼Æ

¥Õ¦â©³¦âªº­I´º

l          °õ¦æ[GIMP] -> File -> New¡A²£¥Í¤j¤p375x250¥Õ¦â©³¦âªº¼v¹³¡C

l          ¹Ï¼hªº¦W¦r§ó§ï¬°Sphere Layer

l          ²£¥Í¥Õ¦â©³¦âªº¼v¹³¡Aµ{¦¡½X¦Ü¤Ö­n4¦æ¤~¯à°µ¨ì¡A

    gimp-image-new¡G²£¥Í·s¼v¹³

    gimp-layer-new¡G²£¥Í·s¹Ï¼h

gimp-image-add-layer¡G¬°¼v¹³¥[¤W¹Ï¼h

gimp-edit-fill¡G±N¹Ï¼h¶ñ¤W¥Õ¦â

13:(img (car (gimp-image-new width height RGB)))

14: (drawable (car (gimp-layer-new img width height RGB_IMAGE "Sphere Layer" 100 NORMAL)))

27: (gimp-image-add-layer img drawable 0)

28: (gimp-palette-set-foreground sphere-color)

29: (gimp-palette-set-background bg-color)

30: (gimp-edit-fill drawable BG-IMAGE-FILL)

¾ò¶ê¿ï¨ú

l          ¨Ï¥Î¾ò¶ê¿ï¨ú¤u¨ã°é¥X¤@­Ó¾ò¶ê§Îªº¿ï¨ú°Ï°ì¡C¾ò¶ê¿ï¨ú¤u¨ãªº°Ñ¼Æ³]©wFeather³]7.5¡C

l          ¾ò¶ê¿ï¨úªº³»ÂI®y¼Ð¡]10.7¡A190¡^¡A¾ò¶ê¿ï¨úªº¼e176.8¡A¾ò¶ê¿ï¨úªºªø50¡C

l          ¾ò¶ê¿ï¨ú©Ò¨Ï¥Îªº°Ñ¼Æ¬O®Ú¾Úµ{¦¡½X¤¤ªº¤½¦¡ºâ¥X¨Óªº¡C

l          §A¥i¥H®Ú¾Ú§Aªºª½Ä±¤£¥²¤Óºë½T¦a²£¥Í¤@­Ó¾ò¶ê§Îªº¿ï¨ú°Ï°ì¡C

46:(gimp-ellipse-select img shadow-x shadow-y shadow-w shadow-h REPLACE TRUE 7.5)

»s§@³±¼v

l          ¨Ï¥ÎÃC®Æ±í¤u¨ã¬°¶ê§Îªº¿ï¨ú°Ï°ì¤W¦â¡C

l          ¥Ñ©ó¦Ð¤Æ¿ï¨ú°Ï°ìªº¦]¯À¡A¨Ï±o¦r¶Â¦âªº¾ò¶ê§ÎªºÃä½tÅܼҽk¡C

47:(gimp-bucket-fill drawable BG-BUCKET-FILL MULTIPLY 100 0 FALSE 0 0)

¾ò¶ê¿ï¨ú

l          ¨Ï¥Î¾ò¶ê¿ï¨ú¤u¨ã°é¥X¤@­Ó¶ê§Îªº¿ï¨ú°Ï°ì¡C

l          ¶ê¤ß¬°¼v¹³ªº¤¤¤ß¡]187.5¡A125¡^¡B¥b®|100¡A¬G¾ò¶ê¿ï¨úªº³»ÂI®y¼Ð¡]87.5¡A25¡^¡A¾ò¶ê¿ï¨úªº¼e200¡A¾ò¶ê¿ï¨úªºªø200¡C

l          §A¥i¥H®Ú¾Ú§Aªºª½Ä±¤£¥²¤Óºë½T¦a²£¥Í¤@­Ó¶ê§Îªº¿ï¨ú°Ï°ì¡C

50: (gimp-ellipse-select img (- cx radius) (- cy radius) (* 2 radius) (* 2 radius) REPLACE TRUE FALSE 0)

¤u¨ã¿ï¶µ¹ï¸Ü²°

¦³¥ú¼vªº²yÅé

l          º¥¼h¶ñ¦â±í¤u¨ãªº°Ñ¼Æ¿ï¶µ³]©w¦p¥k¡CGradient³]Radial¡A©ñ®gª¬ªºº¥¼h¡C

l          ¦b«e´º¦â¬°¬õ¦â¡B­I´º¦â¬°¶Â¦â¡A¨Ï¥Îº¥¼h¶ñ¦â¤u¨ã¡A¬°¶ê§Îªº¿ï¨ú°Ï°ì¤W¦â¡C±q¶ê¤ßªº¥k¤W¨¤¡]230,82.6¡^³o¤@ÂI¨ì¥ª¤U¨¤¡]116.8¡A195.7¡^³o¤@ÂI¡A©Ô¤@±øª½½u¡C

l          ¥Ñ©ó¬O©ñ®gª¬º¥¼h¡A¶ê¤ßªº¥k¤W¨¤¡]230,82.6¡^³o¤@ÂIªþªñ¬O¸û«Gªº¬õ¦â¡A·|¦³µo¥úªº·Pı¡F¥ª¤U¨¤¡]116.8¡A195.7¡^³o¤@ÂIªþªñ¬O¸û·tªº¬õ¦â©Î¶Â¦â¡A¦³³±¼vªº·Pı¡C

l          ¶ê¤ß»P¥ú·½¦ì¸m¬O®Ú¾Úµ{¦¡½X¤¤ªº¤½¦¡ºâ¥X¨Óªº¡C

l          §A¥i¥H®Ú¾Ú§Aªºª½Ä±¤£¥²¤Óºë½T¦a¥h»s§@¦³¥ú¼vªº²yÅé¡C

51: (gimp-blend drawable FG-BG-RGB NORMAL RADIAL 100 offset REPEAT-NONE FALSE 0 0 light-x light-y light-end-x light-end-y)

52: (gimp-selection-none img)

 

¤T¡B­ì©lµ{¦¡½X¡G

l          µ{¦¡½Xsphere.scm¤À¤T³¡¥÷

l          1~8¦æ¡Gµù¸Ñ

l          9~58¦æ:¡G(define (script-fu-sphere  )) ¡A¦b´ú¸Õµ{¦¡ªº¹Lµ{¤¤¡A§Ú±N¥¦§ï¬°script-fu-sphere2

l          59~71¦æ¡G(script-fu-register "script-fu-sphere"  )

l          §Ú±N¬A¸¹¹ï»ô¡A¤è«K¬ã¨sµ{¦¡½X¡A¬G¦æ¼Æ»P­ì¥»ªºÀɮפ£¤@¼Ë¡C

l          sphere.scmµ{¦¡½X¡A¦³¤@¥bªºµ{¦¡½X¬O¦b­pºâ²yÅ骺¶ê¤ß¡B¥b®|¡B¥ú·½ªº¦ì¸m¡B³±¼vªº¦ì¸m»P¤j¤p¡C

l          §Ú±N³o¨ÇÅܼƭpºâ«á¬ö¿ý¦b¤U­±ªºÄæ¦ì¤¤¡C

1: ;  Create a 3D sphere with optional shadow

2: ;  The sphere's principle color will be the foreground

3: ;  Parameters:

4: ;   bg-color: background color

5: ;   sphere-color: color of sphere

6: ;   radius: radius of the sphere in pixels

7: ;   light:  angle of light source in degrees

8: ;   shadow: whather to create a shadow as well

 

 

¹w³]¿é¤J°Ñ¼Æªº­È

Radius¡×100

Lighting (degrees)¡×45

Shadow¡×" TRUE

Background Color¡× '(255 255 255)

Sphere Color¡×'(255 0 0))

9: (define (script-fu-sphere2 radius light shadow bg-color sphere-color)

10:   (let* (

11:         (width (* radius 3.75))

12:         (height (* radius 2.5))

13:          (img (car (gimp-image-new width height RGB)))

14:          (drawable (car (gimp-layer-new img width height RGB_IMAGE "Sphere Layer" 100 NORMAL)))

15:          (radians (/ (* light *pi*) 180))

16:          (cx (/ width 2))

17:          (cy (/ height 2))

18:         (light-x (+ cx (* radius (* 0.6 (cos radians)))))

19:          (light-y (- cy (* radius (* 0.6 (sin radians)))))

20:          (light-end-x (+ cx (* radius (cos (+ *pi* radians)))))

21:          (light-end-y (- cy (* radius (sin (+ *pi* radians)))))

22:          (offset (* radius 0.1))

23:          (old-fg (car (gimp-palette-get-foreground)))

24:          (old-bg (car (gimp-palette-get-background)))

25       )

26:      (gimp-image-undo-disable img)

27:      (gimp-image-add-layer img drawable 0)

28:      (gimp-palette-set-foreground sphere-color)

29:      (gimp-palette-set-background bg-color)

30:      (gimp-edit-fill drawable BG-IMAGE-FILL)

31:      (gimp-palette-set-background '(20 20 20))

32:      (if (and

33:           (or (and (>= light 45) (<= light 75)) (and (<= light 135) (>= light 105)))

34:           (= shadow TRUE))

35:          (let (

36:             (shadow-w (* (* radius 2.5) (cos (+ *pi* radians))))

37:               (shadow-h (* radius 0.5))

38:               (shadow-x cx)

39:               (shadow-y (+ cy (* radius 0.65)))

40:           )

41:              (if (< shadow-w 0)

42:                 (prog1 (set! shadow-x (+ cx shadow-w))

43:                           (set! shadow-w (- shadow-w))

44:               )

45:            )

46:              (gimp-ellipse-select img shadow-x shadow-y shadow-w shadow-h REPLACE TRUE TRUE 7.5)

47:              (gimp-bucket-fill drawable BG-BUCKET-FILL MULTIPLY 100 0 FALSE 0 0)

48:        )

49:      )

50:      (gimp-ellipse-select img (- cx radius) (- cy radius) (* 2 radius) (* 2 radius) REPLACE TRUE FALSE 0)

51:      (gimp-blend drawable FG-BG-RGB NORMAL RADIAL 100 offset REPEAT-NONE FALSE 0 0 light-x light-y light-end-x light-end-y)

52:    (gimp-selection-none img)

53:    (gimp-palette-set-background old-bg)

54:    (gimp-palette-set-foreground old-fg)

55:    (gimp-image-undo-enable img)

56:    (gimp-display-new img)

57:   )

58: )

 

 

Radius¡×100¡FLighting (degrees)¡×45

width ¡×3.75¡Ñ radius

height¡×2.5¡Ñ radius

 

*pi*¬°Schemeªº¤º³¡Åܼƪí¶ê©P²v¡C

radians¡×*pi*¡Ñlight¡Ò180¡F

cx¡×width¡Ò2

cy¡×height¡Ò2

light-x¡×cx¡Ï0.6¡Ñradius¡Ñcos¡]radians¡^

light-y¡×cy¡Ð0.6¡Ñradius¡Ñsin¡]radians¡^

light-x-end¡×cx¡Ïradius¡Ñcos¡]*pi*¡Ïradians¡^

light-y-end¡×cy¡Ðradius¡Ñsin¡]*pi*¡Ïradians¡^

offset¡×0.1¡Ñradius

width ¡×375

height¡×250

 

 

radians¡×*pi*/4

cx¡×187.5

cy¡×125

light-x¡×230

light-y¡×82.57

light-x-end¡×116.8

light-y-end¡×195.7

offset¡×10

¥H¡]187.5¡A125¡^¬°¶ê¤ß¡A¥ú±q¡]230,82.6¡^³B¨ì¡]116.8¡A195.7¡^³B¡A±q¶ê¤ß45«×¨¤³B¨ì¶ê¤ß225«×¨¤³B¡C

 

 

 

 

 

 

32¦æ¨ì34¦æªº±ø¥ó¦¡¬O¬°­­¨î¥úªº¨¤«×¡A

­­©w¥úªº¨¤«×¬O¬°¤FÁקK²£¥Íªº¼v¤l¤Ó¤j©Î¤Ó¤p¡C

 

let»Plet*¦³¦ó¤£¦P¡H

 

shadow-w¡×2.5¡Ñ radius¡Ñcos (*pi*¡Ïradians)

shadow-h¡×0.5¡Ñradius

shadow-x¡×cx

shadow-y¡×cy¡Ï0.65¡Ñradius

shadow-w¡×-176.8

shadow-h¡×50

shadow-x¡×187.5

shadow-y¡×190

 

shadow-w¡×-176.8 ¡Õ0

shadow-x¡×cx¡Ïshadow-w

shadow-w¡×¡Ðshadow-w

shadow-x¡×10.7

shadow-w¡×176.8

 

prog1¬O¤°»ò¡H

59: (script-fu-register "script-fu-sphere2"

60:                    _"<Toolbox>/Xtns/Script-Fu/Misc/Sphere2..."

61:                    "Simple sphere with a drop shadow"

62:                   "Spencer Kimball"

63:                    "Spencer Kimball"

64:                    "1996"

65:                    ""

66:                    SF-ADJUSTMENT _"Radius (pixels)" '(100 5 500 1 10 0 1)

67:                    SF-ADJUSTMENT _"Lighting (degrees)" '(45 0 360 1 10 0 0)

68:                    SF-TOGGLE _"Shadow" TRUE

69:                    SF-COLOR  _"Background Color" '(255 255 255)

70:                    SF-COLOR  _"Sphere Color" '(255 0 0)

71:  )

 

 

¥|¡B¨ä¥L¨ç¼Æªº»¡©ú¡G

gimp-ellipse-select¨ç¼Æ

46:(gimp-ellipse-select img shadow-x shadow-y shadow-w shadow-h REPLACE TRUE 7.5)

50: (gimp-ellipse-select img (- cx radius) (- cy radius) (* 2 radius) (* 2 radius) REPLACE TRUE FALSE 0)

¥ÑDB Browser¹ï¸Ü²°ªº¸ê®Æ¥i±À¥X²Ä46¦æ¡B²Ä50¦æ¬O¤°»ò·N«ä¡C