It is currently Sun Jun 30, 2024 3:48 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Place a Star on the center of the Canvas (Solved)
PostPosted: Tue May 05, 2020 11:23 am  (#1) 
Offline
GimpChat Member

Joined: Jul 28, 2018
Posts: 1196
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 here and also the Gimp-Forum.net, that are been helping me through out this learning process.

Now, I will like to know the script-fu procedure to place a Star on the center of the canvas using the "Star brush. Thank you in advanced!

_________________
https://www.deviantart.com/pocholo17
Image


Last edited by Pocholo on Tue May 05, 2020 2:38 pm, edited 1 time in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Place a Star on the center of the Canvas
PostPosted: Tue May 05, 2020 2:38 pm  (#2) 
Offline
GimpChat Member

Joined: Jul 28, 2018
Posts: 1196
Ok, I saw an example here
https://stackoverflow.com/questions/490 ... imple-line
and here
https://renenyffenegger.ch/notes/design ... ions/index

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


Image




(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)

_________________
https://www.deviantart.com/pocholo17
Image


Last edited by Pocholo on Wed May 06, 2020 12:15 pm, edited 1 time in total.

Top
 Post subject: Re: Place a Star on the center of the Canvas (Solved)
PostPosted: Wed May 06, 2020 4:42 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Sep 27, 2016
Posts: 345
Location: Germany, BW
Thnks for posting your solution here ... surely helpful for others who come across this topic.
Your link to stackoverflow doesn't lead to the question/answer. If you can still find where it was, can you correct it?

_________________
Regards
nelo

(Gimp 2.10 on Linux Mint MATE 20.1)


Top
 Post subject: Re: Place a Star on the center of the Canvas (Solved)
PostPosted: Wed May 06, 2020 12:08 pm  (#4) 
Offline
GimpChat Member

Joined: Jul 28, 2018
Posts: 1196
I’m not a coder and I don’t really know how to explain it. I search on the web for a hard explanation and I could find much. I use and exemption on what I saw and read from different places. This link gave a little perspective.
https://renenyffenegger.ch/notes/design ... ions/index

I learned from https://www.gimp.org/tutorials/Basic_Scheme2/
How to draw a line procedure, setting the cons-array and setting the coordinate points with this sample.


(set! points (cons-array 4 'double))

(aset points 0 0) ; (x0, y0)
(aset points 1 0)
(aset points 2 320) ; (x1, y1)
(aset points 3 240)
(gimp-paintbrush-default layer 4 points)



I know you need at least two points coordinate x, y in your image to construct an array. With GIMP “aset function” you can fill those coordinates values. I figured that if you make those coordinates points in the same place on the Canvas, it will fill with a value(s). In my case, I have a 700 x 700 square canvas and I set the both points x, y at 350, (center) and used an constant array of doubles. This I figured that will paint the “Star” in the center. I don’t know if that make sense, Like I said I’m new and I know it but don’t know how to put it in words.


P.S I found out that you don’t need to construct a 4 points coordinate to paint, in my case, the “Star” on the center of the Canvas. You need just two to accomplish what I did, thank to Ofnuts.






(define (script-fu-create-a-Star)
    (let* (
         
      (imgWidht 700)
      (ImgHeight 700)
      (points (cons-array 2 '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)
      
      (gimp-paintbrush-default layer 2 points)

_________________
https://www.deviantart.com/pocholo17
Image


Top
 Post subject: Re: Place a Star on the center of the Canvas (Solved)
PostPosted: Wed May 06, 2020 12:48 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: Sep 27, 2016
Posts: 345
Location: Germany, BW
Thank you @pocholo

_________________
Regards
nelo

(Gimp 2.10 on Linux Mint MATE 20.1)


Top
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Center-Based Morphing/Interpolation

2

No new posts Locating exact center of design?

4

No new posts Change canvas size

1

No new posts Attachment(s) How to crop an image and canvas together?

6

No new posts Attachment(s) How do I create a sunflare on a blank canvas?

5



* Login  



Powered by phpBB3 © phpBB Group