It is currently Fri Jun 28, 2024 11:09 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: My fullest first python script "Heart"
PostPosted: Thu May 07, 2020 7:03 pm  (#1) 
Offline
GimpChat Member

Joined: Jul 28, 2018
Posts: 1196
Hi again everyone! This is my first complete python script. I'so happy I'm learning some of this stuff! Well, this is the heart that I created out of my script-fu script "Create a heart". Be safe!

The only thing I got stuck is on the color. Some how I could not make change the colors.

Image


Attachments:
render_a_heart.zip [1.15 KiB]
Downloaded 79 times

_________________
https://www.deviantart.com/pocholo17
Image
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: My fullest first python script "Heart"
PostPosted: Fri May 08, 2020 9:12 am  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4751
Pocholo wrote:
Hi again everyone! This is my first complete python script. I'so happy I'm learning some of this stuff! Well, this is the heart that I created out of my script-fu script "Create a heart". Be safe!

The only thing I got stuck is on the color. Some how I could not make change the colors.


You define bgcolor/fgcolor input variables but you don't use them anywhere in your code... Try changing:
pdb.gimp_context_set_foreground ((191, 35, 57))
to
pdb.gimp_context_set_foreground (fgColor)


Likewise you define a "size" input variable but it appears nowhere, instead you use SIZE which is a fixed size(*). In things like
pdb.gimp_image_select_ellipse(img, 2, 60, 105, 385, 285)
, all the numbers should be computed from "size" (and also some other implicit data such as a margin width and an aspect ratio). If you determined these numbers by computing them it is easy since you just write the formulas in python. If you obtained them by tinkering with values until it worked(**) then you are stuck, and you have to wonder how you can determine these values algorithmically instead (ie, how should they change when you change the size and other factors).

By rewriting you thing in Python you have discovered that knowing a prorgramming language is necessary but not sufficient. What really counts is the logical mind, and if you deal with images, some proficiency in math.

(*) and is a capital sin... Using defined constants is nice, but one expects to be able to change only SIZE and get everything else in the code to change accordingly, but you still have plenty of hardcoded numbers elsewhere, so using SIZE is misleading and does more harm than good at this point.

(**) This 44.75 angle, for instance.

_________________
Image


Last edited by ofnuts on Fri May 08, 2020 2:43 pm, edited 1 time in total.

Top
 Post subject: Re: My fullest first python script "Heart"
PostPosted: Fri May 08, 2020 11:55 am  (#3) 
Offline
GimpChat Member

Joined: Jul 28, 2018
Posts: 1196
Thanks a lot, Onuts. I 'm working in the script as I respond! :coolthup

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


Top
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Create a red heart script

16

No new posts Attachment(s) My first Python Script for Gimp

7

No new posts Attachment(s) Learning to do first Python script

6

No new posts .py script not showing under Python-Fu

3

No new posts Does anyone have script fu and python plugins that work on 2.99.19?

1



* Login  



Powered by phpBB3 © phpBB Group