Steve wrote:
Any critique/criticism on the output or coding is welcome
First, extreme kudos on the excellent naming of your variables. It is such a pleasure to read Scheme code that doesn't resort to using CamelCase or under_scores.
One minor niggle is that you use "*" for your menu constraint in the 'script-fu-register' block. This means that your script will be available regardless of whether the currently opened image is RGB, GRAY, or INDEXED. The thing is, your script doesn't need an image to even be opened (it creates its own) so this constraint should properly be empty quotes, "". You might also consider placing the command in the "File->Create" submenu as the "Filters" menu is generally employed for filters that operate on existing images.
Your code conditioned upon the quadrant value could use a little bit of optimization. Firstly, rather than performing the test twice:
(if (= quadrant 0) (set! Xcord (+ X-axis-centre-line (* hypotenuse (sin radian)))))
(if (= quadrant 0) (set! Ycord (+ Y-axis-centre-line (* hypotenuse (cos radian)))))
Just perform the test once and combine the two calculation steps by wrapping them with
(begin...):
(if (= quadrant 0)
(begin
(set! Xcord (+ X-axis-centre-line (* hypotenuse (sin radian)))))
(set! Ycord (+ Y-axis-centre-line (* hypotenuse (cos radian))))))
Better still would be to use
(cond...) or
(case...) so that once a quadrant is matched, no further testing is performed (this will improve your script's speed by about 5-10%).
(case quadrant
((0)
(set! Xcord (+ X-axis-centre-line (* hypotenuse (sin radian))))
(set! Ycord (+ Y-axis-centre-line (* hypotenuse (cos radian)))))
((1)
(set! Xcord (- X-axis-centre-line (* hypotenuse (sin radian))))
(set! Ycord (+ Y-axis-centre-line (* hypotenuse (cos radian)))))
((2)
(set! Xcord (- X-axis-centre-line (* hypotenuse (sin radian))))
(set! Ycord (- Y-axis-centre-line (* hypotenuse (cos radian)))))
((3)
(set! Xcord (+ X-axis-centre-line (* hypotenuse (sin radian))))
(set! Ycord (- Y-axis-centre-line (* hypotenuse (cos radian))))))
Finally, you are setting the same pixels to the same color in four different layers each time through the loop. It would be more efficient to just create a single layer and after you've drawn all of your pixels, create three copies of the layer (this will roughly triple the speed of your script). You may have plans to, in the future, do something different with the layers and thus wish to leave things the way they are, but as things stand your approach is suboptimal.
As a general guideline, I personally try to postpone introducing variables until they are needed, rather than pre-declaring them all at the beginning of the script. This can be helpful in minimizing the likelihood of errors in larger Scheme programs, though for typical Script-fus it is more of a personal preference.