GIMP Chat http://gimpchat.com/ |
|
python "str()" vs tiny-fu "number->string" http://gimpchat.com/viewtopic.php?f=8&t=12702 |
Page 1 of 1 |
Author: | dinasset [ Mon Jun 22, 2015 9:06 am ] |
Post subject: | python "str()" vs tiny-fu "number->string" |
GIMP Version: 2.8.14 Operating System: Windows GIMP Experience: Basic Level @Ofnuts I came back just a little to Python and it seems to me that the simple use of the Python built-in function str return a decimal number in a format acceptable to G'MIC, without asking any specific editing; I mean: if my filter calculates a value from a,b,c such as value = (a+b)/c the returned value is: iiiiiii.ddddd the whole part + a dot + the decimal part provided c has decimals this consideration came out from a few simple tests using a=1250, b=750, c=3000 the result value seems to be only 0, but using a=1250, b=750, c=3000.00 the result value comes out as 0.666666666 is it really so simple to interface G'MIC from Python? or did I miss something? thanks |
Author: | paynekj [ Mon Jun 22, 2015 9:36 am ] |
Post subject: | Re: python "str()" vs tiny-fu "number->string" |
Make sure at least one of your variables is a float, otherwise they get presumed to be integers: Code: Select all >>> a = 1250 |
Author: | dinasset [ Mon Jun 22, 2015 10:14 am ] |
Post subject: | Re: python "str()" vs tiny-fu "number->string" |
thanks Kevin this confirms my simple test above (where I set c=3000 result was integer 0, where I set c=3000.00 result was float 0.666666...) I'm curious to know from users of python whether: - the integer part is always expressed as a sequence of digits without any "disturbing" editing char - the integer part is always separated by a decimal point (the only format accepted by G'MIC) so that a value of 100000 divided by a value of 3.0 (float) gives in any local system the result as 33333.3333333333333333 |
Author: | ofnuts [ Mon Jun 22, 2015 5:02 pm ] |
Post subject: | Re: python "str()" vs tiny-fu "number->string" |
Yes, as far as I can tell from the docs and some experimenting:
|
Author: | dinasset [ Tue Jun 23, 2015 1:31 am ] |
Post subject: | Re: python "str()" vs tiny-fu "number->string" |
thanks Ofnuts I will prepare my first Python+G'MIC filter soon |
Page 1 of 1 | All times are UTC - 5 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |