On Thursday 02 June 2005 04.13, Joao S. O. Bueno Calligaris wrote:
> #!/usr/bin/python
>
> #use Gimp qw( :auto );
> #use Gimp::Fu;
> # I don't know what this "auto:" means,
> #but we normally just import gimpfu in python scripts/
>
> from gimpfu import *
>
> #register        "center_guide",
> # the register call in python must come after the function definition
> #itself. Ok - this is  thasy perl way, in which the function was
> #defined inside the funcion call for register. Python is  a clean
> #language - the only way of doing this is with short functions
> #that can be written as lambdas.
>
> #        sub {
> #                my ($img, $layer, $center) = @_;
> def center_guide (img, layer, center):
>      #beware of indentation from this point on
>
>      #$w = $img->width();
>      #$h = $img->height();
>      #$hc = int($h/2 + 0.5);
>      #$vc = int($w/2 + 0.5);
>
>      w = img.width
>      h = img.height
>      hc = int (h / 2.0 + 0.5)
>      vc = int (w / 2.0 + 0.5)
>
>      #if ($center == 1) {
>      #      $hc = int(($h / 2.6179) + 0.5);
>      #    };
>      if center == 1:
>           hc = int (h / 2.6179 + 0.5)
>
>      #          $bit_bucket = $img->add_hguide($hc);
>      #          $bit_bucket = $img->add_vguide($vc);
>      #          gimp_drawable_update($layer, 0, 0, $w, $h);
>      img.add_hguide (hc)
>      img.add_vguide (vc)
>      gimp.displays_flush()      
>
>      #   };
>
> register   ("center_guide",
>             "Creates h- & v-guides at the center of the image.",
>             "Physical center = width/2 and height/2; Optical center =
> the Golden Mean.",
>              "Claes G Lindblad <[EMAIL PROTECTED]>",
>              "Claes G Lindblad, pythonified by Joao S. O. Bueno
> Calligaris",
>               "990323",
>               "<Image>/Center Guides",
>               "*",
>               [
>                 [PF_RADIO,
>                         "center",
>                         "center",
>                          0,
>                          (("Physical", 0), ("Optical", 1))
>                 ]
>                      
>               ],
>               [],
>               center_guide
>               )  
>                
>
> #exit main;
> main ()

Very nice! Thank you Very much!

Works as expected. (almost)
The image is flagged edited if i use the guides.
How do i set something so it isn't edited? (Its just a guide, no change in the 
image)
Also, i was thinking of extending the script to use a choice "Thirds" too. 
(the rule of thirds), but i failed to get the hang of how to use the if 
statement... 

I am not much of a programmer (as i have stated before), so i need all the 
"babytalk help" i can get...

I do understand more and more for each time.. Maybe in time when i get my new 
SGI machine ill be able to write my own code...

-- 

         /Rikard

" Sharing knowledge is the most fundamental act of friendship. 
Because it is a way you can give something without loosing something." 
                -R. Stallman 

---------------------------------------------------------------
Rikard Johnels          email   : [EMAIL PROTECTED]
                        Mob     : +46 763 19 76 25
                        PGP     : 0x461CEE56
---------------------------------------------------------------
_______________________________________________
Gimp-user mailing list
Gimp-user@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-user

Reply via email to