GIMP Chat http://gimpchat.com/ |
|
Create a red heart script http://gimpchat.com/viewtopic.php?f=9&t=18276 |
Page 1 of 1 |
Author: | Pocholo [ Sun Apr 26, 2020 1:36 am ] | ||
Post subject: | Create a red heart script | ||
Here is my second GIMP script. It creates a nice shape heart with a light reflection. I wrote the script following the "Create an easy heart with GIMP 2.10" by conbagui found at link:http://fav.me/ddvrolq Please expert coder, don't be so hard on me, I'm still in the baby learning process. Have good day and be safe!
|
Author: | ofnuts [ Sun Apr 26, 2020 2:45 am ] |
Post subject: | Re: Create a red heart script |
The code is fine(*). But since there are no parameters, the script will always create the same image, so you might as well distribute the PNG ![]() (*) Well, since you set the colors, you should bracket your code in gimp-context-push/gimp-context-pop call to leaves the premises in the state you found them. |
Author: | nelo [ Sun Apr 26, 2020 2:48 am ] |
Post subject: | Re: Create a red heart script |
Your script should have a Code: Select all (script-fu-menu-register "script-fu-create-heart" "<Image>/File/Create") Otherwise it won't register in GIMP 3.x The script-fu register stuff should read like so, then: Code: Select all (script-fu-register |
Author: | Pocholo [ Sun Apr 26, 2020 7:34 am ] |
Post subject: | Re: Create a red heart script |
@ ofnuts; Thank you for the info. I will try to create the image with parameters, but I need to learn how to do it. ![]() @nelo; Thanks, I will now register my script the way you did it or suppose to be done. ![]() |
Author: | Pocholo [ Tue Apr 28, 2020 11:55 pm ] |
Post subject: | Re: Create a red heart script |
Ofnuts, Idon't know how can I create a parameter that make different sizes. So far I have this: SF-ADJUSTMENT "Layer Size (px)" '(500 50 1000 1 10 0 1). When the dialog pop out, I input a different size but I always get the same size 500 px. Thank you in advanced! |
Author: | ofnuts [ Wed Apr 29, 2020 2:13 am ] |
Post subject: | Re: Create a red heart script |
You need to use arguments in your function definition so that the dialog inputs are passed down to your code. These arguments do behave like variables that you can use instead of your hardcoded "500" value. Can't be more specific since i don't use Scheme. |
Author: | nelo [ Wed Apr 29, 2020 2:33 am ] |
Post subject: | Re: Create a red heart script |
@pocholo: There is a small tutorial series on youtube by monsoonami https://www.youtube.com/watch?v=dAuJJ6P ... 821B2370D4 maybe that helps. It did for me. |
Author: | Pocholo [ Wed Apr 29, 2020 11:14 am ] |
Post subject: | Re: Create a red heart script |
@nelo - Thank you for the link but somehow I'm not understanding how to create and adjustment that will make the image user's choice size. @Ofnuts and nelo - Bear with me, please. I learned how to make the Background and the Heart to change colors. The only thing I need, is to able to create an SF-ADJUSTMENT to make the heart in different sizes. I created the adjustment Height and Width. When I change the width and the height on the dialog box, the layer resize, but the image of the heart don't. Code: Select all ; following steps in Create an easy heart with GIMP 2.10 by conbagui found at link:http://fav.me/ddvrolq |
Author: | ofnuts [ Thu Apr 30, 2020 2:48 am ] |
Post subject: | Re: Create a red heart script |
Most explicit numbers in your script should be replaced by imgWidth, imgHeight or some computation from these (for instance (/ imgWidth 2) or (/ imgHeight 2) instead of 250). |
Author: | nelo [ Thu Apr 30, 2020 12:45 pm ] |
Post subject: | Re: Create a red heart script |
There will be quite a lot of maths necessary, I guess.To see the problem you could: disable this undo line in your script: Code: Select all (gimp-image-undo-disable img) Save it, refresh it. Then run it once with the 500px size and a second time with say 800. Leave both open, so you can compare the steps it takes. Now, having undo enabled you can go through your script step by step using the journal and see where the differences are. You'll probably have to recalculate sizes and positions of your forms. Hope these ideas help nelo |
Author: | nelo [ Sun May 03, 2020 2:09 pm ] |
Post subject: | Re: Create a red heart script |
Still thinkin about this ... how it could be done fairly quick: What if you just keep your 500px settings to work with and at the end scale the image like so: Code: Select all ; scale image Next thought with this would be to just set only one value for width and height so you'll always have something square. Edit: better way: using a scaling factor as attached. Hopefully I didn't oversee stuff, but you'll get the idea. |
Author: | Pocholo [ Sun May 03, 2020 3:47 pm ] |
Post subject: | Re: Create a red heart script |
That is what I'm trying to learn and to do , nelo ![]() ![]() Ok, can you explain a little about the "scaling factor", please? |
Author: | nelo [ Mon May 04, 2020 2:05 am ] |
Post subject: | Re: Create a red heart script |
The scaling factor is just some maths: As all the tutorial was written for a fixed width/height of 500 I need a factor to convert everything for say 800px or 750px or whatever the user enters. So I took the new value divided by the 500 to have a factor for multiplying all the values. As you can see in the script I introduced the variable "scaled" like so Code: Select all (scaled (/ imgSize 500)) I can then use it to convert all the fixed withs, heights and positions. That's why I then have a lot of those Code: Select all (* scaled 500) in the script instead of just "500" |
Author: | ofnuts [ Mon May 04, 2020 2:08 am ] |
Post subject: | Re: Create a red heart script |
nelo wrote: Still thinkin about this ... how it could be done fairly quick: What if you just keep your 500px settings to work with and at the end scale the image like so: Code: Select all ; scale image Next thought with this would be to just set only one value for width and height so you'll always have something square. Edit: better way: using a scaling factor as attached. Hopefully I didn't oversee stuff, but you'll get the idea. IMHO a wrong solution. Above 700px the image will be blurry. Creating a heart at the right size isn't difficult. If Pocholo want to learn how to program that would be definitely the wrong thing to do (but then starting with Scheme was also the wrong thing to do IMHO). |
Author: | Pocholo [ Mon May 04, 2020 12:32 pm ] |
Post subject: | Re: Create a red heart script |
Thank you guys for the explanations and the tips. I'm learning a lot from you, thank you! ![]() Now, I know you guys take your time to answer questions here in GC and I well appreciated. I have another question; How to integrate G'MIC in a script-fu? I'm trying to create a "Orange peel pattern" script and so far I'm learning how to place the functions in the script. I'm not getting any errors, but I get the image with no result. What am I missing here? I suppose to get this result ![]() But getting this ![]() Code: Select all (define (orange-peel-pattern) |
Author: | nelo [ Mon May 04, 2020 2:12 pm ] |
Post subject: | Re: Create a red heart script |
Not sure ... My version of GMIC says there is no "fx_relief_light" ... but I have a function called "fx_light_relief". Maybe changing that helps? |
Author: | Pocholo [ Mon May 04, 2020 2:43 pm ] |
Post subject: | Re: Create a red heart script |
My version is "Relief Light", that is weird. I changed it to "light_relief" and still the same result. I want the same result as the Preview window is showing. ![]() |
Page 1 of 1 | All times are UTC - 5 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |