Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Place a Star on the center of the Canvas
#1
Hello everyone, I hope you are fine and staying safe!

I'm still learning how to write script-fu script and  before I ask the question, I will like to thank all the experienced coder that are been helping me through out this learning process. 

Now, I will like to know the script-fu procedure to place a  a Star on the center of the canvas using the "Star brush. Thank you in advanced!
Reply
#2
Take Image width, image height, divide both by two, set the brush (or not, if you expect the used to set the appropriate brush) and then use gimp-paint-brush-default(layer,2,(x,y)).

If you really mean a round dot, you can also create a circle selection and bucket-fill it.
Reply
#3
I meant using the procedure you just mentioned using the Star brush. Is this right?  If I have a 700 x 700 image
Code:
(gimp-paintbrush-default  blue 2 (350,350))
Reply
#4
No, the first parameter is a layer. The color is implicit, it is taken from the "context" (the foreground color from the toolbox, if you didn't change it in your script)
Reply
#5
(05-05-2020, 06:06 PM)Ofnuts Wrote: No, the first parameter is a layer. The color is implicit, it is taken from the "context" (the foreground color from the toolbox, if you didn't change it in your script)

Sorry ofnuts, Let me show you what I got so far in the script. 


Code:
(define (script-fu-create-a-Star)
   (let* (
       
        (imgWidht 700)
        (ImgHeight 700)
        
        
        
        
            
        (img  (car (gimp-image-new imgWidht ImgHeight RGB)))
        (layer (car (gimp-layer-new img imgWidht ImgHeight RGB-IMAGE "Background" 100 LAYER-MODE-NORMAL)))
        
        
        
        )
        
        
        ;Create the Background
        (gimp-image-insert-layer img layer 0 0)
        (gimp-context-set-foreground '(0 0 0))
        (gimp-drawable-fill layer FILL-FOREGROUND)
        (gimp-context-set-brush "2. Star")
        (gimp-context-set-brush-size 210)
        (gimp-context-set-brush-aspect-ratio 2)
        (gimp-context-set-brush-angle 54)
        (gimp-context-get-brush)
        (gimp-context-set-foreground '(255 255 255))
        
        
        
        
        
        (gimp-paintbrush-default  layer 2 (350,350))
            
        
        (gimp-display-new img)
Reply
#6
You are mistaking me for a Scheme expert. I can't hep much, but your parentheses are unbalanced and (gimp-paintbrush-default layer 2 (350,350)) should probably be (gimp-paintbrush-default layer 2 (350 350)) (no comma).
Reply
#7
Ok, I saw an example here https://stackoverflow.com/questions/4905...imple-line

And I was be able to place the Star on the middle of the Canvas. This is what I achieve:

[Image: NPWkF9Ul.jpg]



Code:
(define (script-fu-create-a-Star)
   (let* (
       
        (imgWidht 700)
        (ImgHeight 700)
        (points (cons-array 4 'double) )    
        
        (img  (car (gimp-image-new imgWidht ImgHeight RGB)))
        (layer (car (gimp-layer-new img imgWidht ImgHeight RGB-IMAGE "Background" 100 LAYER-MODE-NORMAL)))
        
        
        
        
        )
        
        
        ;Create the Background
        (gimp-image-insert-layer img layer 0 0)
        (gimp-context-set-foreground '(0 0 0))
        (gimp-drawable-fill layer FILL-FOREGROUND)
        (gimp-context-set-brush "2. Star")
        (gimp-context-set-brush-size 210)
        (gimp-context-set-brush-aspect-ratio 2)
        (gimp-context-set-brush-angle 54)
        (gimp-context-get-brush)
        (gimp-context-set-foreground '(255 255 255))
        
        
        (aset points 0 350)
        (aset points 1 350)
        (aset points 2 350)
        (aset points 3 350)
        (gimp-paintbrush-default layer 4 points)
                    
        
        (gimp-display-new img)

OK Administrators, you can mark this post as "solved"
Reply
#8
Yes, but it works with one points (two coordinates) and you don't need to construct an explicit array.

I use StackOverflow daily (I'm even a solid contributor) and I recommend that you take what you see there with a grain of salt. There are solutions that work, and solutions that work for the right reasons. tThere are many answers that look like "that was a miracle for me, it could be a miracle for you".

You will start to learn only when you go beyond copy/paste and start tinkering.
Reply
#9
(05-05-2020, 07:45 PM)Ofnuts Wrote: Yes, but it works with one points (two coordinates)  and you don't need to construct an explicit array.

I use StackOverflow daily (I'm even a solid contributor) and I recommend that you take what you see there with a grain of salt. There are solutions that work, and solutions that work for the right reasons. tThere are many answers that look like "that was a miracle for me, it could be a miracle for you".

You will start to learn only when you go beyond copy/paste and start tinkering.

OK, and thank ofnuts for your advises and for your time. Be safe!
Reply


Forum Jump: