; Test-Calc
;
; Created by GnuTux 
; Comments directed to http://gimpchat.com or http://gimpscripts.com
;
; License: GPLv3
;    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 3 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.
;
;    To view a copy of the GNU General Public License
;    visit: http://www.gnu.org/licenses/gpl.html
;
;
; Display Message 
;
; 
(define (display_message 
                 text_message                              ; Message to display
                 output_destination                        ; MESSAGE-BOX (0), CONSOLE (1), ERROR-CONSOLE (2)
        )
   (let* (
          (handler_state (car (gimp-message-get-handler))) ; Save current message handler state
         )
          (gimp-message-set-handler output_destination)    ; Set message handler to the desired output destination    
          (gimp-message text_message)                      ; Display the message
          (gimp-message-set-handler handler_state)         ; Restore message handler to saved state 
   ) ;end let
) ; end define display-message procedure

;
;Define Main Procedure
;
(define (script-fu-test-calc img layer)

;
;Declare & Init Variables
;
    (let* 
     (
      (hpos 0)
      (vpos 0)
     )
;
; Save Context
; 
(gimp-context-push)

; Start Undo Group

(gimp-undo-push-group-start img)


(set! hpos (round (cos (* 0 (/ 3.14 180)))))
(set! vpos (round (sin (* 0 (/ 3.14 180)))))
(display_message (string-append "Angle(0)   horz: " (number->string hpos)"  vert: " (number->string vpos) ) 2)

(set! hpos (round (cos (* 45 (/ 3.14 180)))))
(set! vpos (round (sin (* 45 (/ 3.14 180)))))
(display_message (string-append "Angle(45)   horz: " (number->string hpos)"  vert: " (number->string vpos) ) 2)

(set! hpos (round (cos (* 90 (/ 3.14 180)))))
(set! vpos (round (sin (* 90 (/ 3.14 180)))))
(display_message (string-append "Angle(90)   horz: " (number->string hpos)"  vert: " (number->string vpos) ) 2)

(set! hpos (round (cos (* 135 (/ 3.14 180)))))
(set! vpos (round (sin (* 135 (/ 3.14 180)))))
(display_message (string-append "Angle(135)   horz: " (number->string hpos)"  vert: " (number->string vpos) ) 2)

(set! hpos (round (cos (* 180(/ 3.14 180)))))
(set! vpos (round (sin (* 180(/ 3.14 180)))))
(display_message (string-append "Angle(180)   horz: " (number->string hpos)"  vert: " (number->string vpos) ) 2)

(set! hpos (round (cos (* 225 (/ 3.14 180)))))
(set! vpos (round (sin (* 225(/ 3.14 180)))))
(display_message (string-append "Angle(225)   horz: " (number->string hpos)"  vert: " (number->string vpos) ) 2)

(set! hpos (round (cos (* 270 (/ 3.14 180)))))
(set! vpos (round (sin (* 270 (/ 3.14 180)))))
(display_message (string-append "Angle(270)   horz: " (number->string hpos)"  vert: " (number->string vpos) ) 2)

(set! hpos (round (cos (* 315 (/ 3.14 180)))))
(set! vpos (round (sin (* 315 (/ 3.14 180)))))
(display_message (string-append "Angle(315)   horz: " (number->string hpos)"  vert: " (number->string vpos) ) 2)

(gimp-undo-push-group-end img)

; Update display

(gimp-displays-flush)

; Restore Context 

(gimp-context-pop)

) ; End let
) ; End Main Procedure 

;
; Register Test Script
;
(script-fu-register "script-fu-test-calc"        		    
  "Test Calc"
  "Test Calc"
  "GnuTux"
  "GnuTux"
  "2014"
  "RGB*"
  SF-IMAGE      "image"      0
  SF-DRAWABLE   "drawable"   0
)

(script-fu-menu-register "script-fu-test-calc" "<Image>/Script-Fu/Test Calc")

