home *** CD-ROM | disk | FTP | other *** search
/ ftp.sunet.sepub/pictures / 2014.11.ftp.sunet.se-pictures.tar / ftp.sunet.se / pub / pictures / ACiD-artpacks / programs / unix / editors / gimp-plugins-unstable-0_99_23_tar.gz / gimp-plugins-unstable-0_99_23_tar / gimp-plugins-unstable-0.99.23 / gimptcl / frags / sphere.tcl < prev    next >
Text File  |  1998-02-20  |  2KB  |  65 lines

  1.  
  2. proc Shadow_Sphere {radius sphere_color bg_color light shadow} {
  3.     global RGB_IMAGE RGB NORMAL TRUE FALSE FG_BG_RGB
  4.     global MULTIPLY REPLACE BG_BUCKET_FILL RADIAL
  5.  
  6. #     puts "radius: $radius"
  7. #     puts "sphere_color: $sphere_color"
  8. #     puts "bg_color: $bg_color"
  9. #     puts "light: $light"
  10. #     puts "shadow: $shadow"
  11.  
  12.     set w [expr $radius * 3.52]
  13.     set h [expr $radius * 2.40]
  14.  
  15.     set img [gimp-image-new $w $h RGB]
  16.     set drawable [gimp-layer-new $img $w $h \
  17.               RGB_IMAGE "Sphere" 100 NORMAL]
  18.  
  19.     set radians [expr ($light * 3.1415926) / 180]
  20.     set cx [expr $w / 2]
  21.     set cy [expr $h / 2]
  22.  
  23.     set light_x [expr $cx + ((cos($radians) * 0.6) * $radius)]
  24.     set light_y [expr $cy - ((sin($radians) * 0.6) * $radius)]
  25.     set light_end_x [expr $cx + ($radius * (cos(3.1415926 + $radians)))]
  26.     set light_end_y [expr $cy - ($radius * (sin(3.1415926 + $radians)))]
  27.     set offset [expr $radius * 0.1]
  28.  
  29.     gimp-image-disable-undo $img
  30.     gimp-image-add-layer $img $drawable 0
  31.     gimp-palette-set-foreground $sphere_color
  32.     gimp-palette-set-background $bg_color
  33.     gimp-edit-fill $img $drawable
  34.     gimp-palette-set-background {20 20 20}
  35.  
  36.     if {((($light >= 45) && ($light <= 75))
  37.      || (($light <= 135) && ($light >= 105)))
  38.     && ($shadow == 1)} {
  39.     set shadow_w [expr ($radius * 2.5) * (cos(3.1415926 * $radians))]
  40.     set shadow_h [expr $radius * 0.5]
  41.     set shadow_x $cx
  42.     set shadow_y [expr $cy + ($radius * 0.65)]
  43.     if {$shadow_w < 0} {
  44.         set shadow_x [expr $cx + $shadow_w]
  45.         set shadow_w [expr -$shadow_w]
  46.     }
  47.     gimp-ellipse-select $img $shadow_x $shadow_y \
  48.         $shadow_w $shadow_h REPLACE TRUE $TRUE 7.5
  49.     gimp-bucket-fill $img $drawable BG_BUCKET_FILL \
  50.         MULTIPLY 100 0 FALSE 0 0
  51.  
  52.     }
  53.     gimp-ellipse-select $img [expr $cx - $radius] \
  54.      [expr $cy - $radius] [expr 2 * $radius] [expr 2 * $radius] \
  55.     REPLACE TRUE FALSE 0
  56.     gimp-blend $img $drawable FG_BG_RGB NORMAL RADIAL 100 \
  57.     $offset FALSE FALSE 0 0 $light_x $light_y $light_end_x $light_end_y
  58.     gimp-selection-none $img
  59.     gimp-image-enable-undo $img
  60.     gimp-display-new $img
  61.     return $img
  62. }
  63.  
  64. Shadow_Sphere 100 {255 0 0} {255 255 255} 45 FALSE
  65.