It is currently Sat Aug 22, 2026 10:50 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Question about "move" function
PostPosted: Thu Dec 22, 2016 8:52 pm  (#1) 
Offline
New Member

Joined: Dec 22, 2016
Posts: 2
I am making script to help align 4096x4096 texture path to make it seamless by hand (using clone/healing tool)
Abstract of first part of script is:
1 resize canvas from 4096 to 8192 (done)
2 copy 4096 original path (done)
3 paste it down and right of original path (stuck)
I am absolute 0 in Scheme programming and I stuck at point of moving pasted path.
Surprisingly, I didn't found move tool in Gimp Procedure Browser, so tried to use transform tool, fail.
Here is code what I did:
; SEAMLESS-PART-1
; Make triple image out of 4096 for work

(script-fu-register
"script-fu-resize4096" ;func name
"resize4096" ;menu label
"Make triple image out of 4096 for work" ;description
"Alexey K" ;author
"GNU" ;copyright notice
"Dexember 21, 2016" ;date created
"" ;image type that the script works on
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)
(script-fu-menu-register "script-fu-resize4096"
"<Image>/Filters/Texture")

(define (script-fu-resize4096 image layer)
(gimp-image-resize
image
8192
8192
0
0
)
(gimp-layer-resize-to-image-size
layer
)
(gimp-image-select-rectangle
image
0
0
0
4096
4096
)
(gimp-edit-copy-visible
image
)
(gimp-drawable-transform-2d-default (gimp-floating-sel-to-layer (car (gimp-edit-paste layer 0))) 0 0 0 0 0 0 4096 FALSE 0)
)
Problem is in last line of script, please help.


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: Question about "move" function
PostPosted: Fri Dec 23, 2016 3:45 am  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
I don't see any "path" in there... (in the Gimp meaning of "path")

To move a layer you just adjust its x,y offsets (there are API calls that deal with this, enter 'offset' in the search window of the procedure browser)

There are calls to copy a layer without involving the clipboard: using them is faster, simpler, and doesn't interfere with the user's clipboard operations.

You should definitely use Python to write your scripts... For what you want to do you may find inspiration in my ofn-symmetries, especially the "quadrilateral" variant. Even if you stick to Scheme, the Python and Scheme APIs are parallel, so that will give you ideas on how to do it in Scheme.

_________________
Image


Top
 Post subject: Re: Question about "move" function
PostPosted: Fri Dec 23, 2016 8:15 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Dec 26, 2014
Posts: 205
I'm not sure if this is what you are wanting, it takes a copy of your original image and moves it to the right

(define (script-fu-resize4096 image layer)

(gimp-rect-select image 0 0 4096 4096 0 FALSE 0)
(gimp-edit-copy layer)
(gimp-image-resize image 8192 8192 0 0)
(gimp-layer-resize-to-image-size layer)
(gimp-edit-paste layer FALSE)
(gimp-layer-translate (car (gimp-image-get-active-drawable image)) 4096 0)
(gimp-floating-sel-anchor (car (gimp-image-get-active-drawable image)))
(gimp-displays-flush)
)


Top
 Post subject: Re: Question about "move" function
PostPosted: Fri Dec 23, 2016 9:06 am  (#4) 
Offline
New Member

Joined: Dec 22, 2016
Posts: 2
You guys a awesome, i didn't expect so much help compare to Russian forums.
ofnuts, thanks for introduthing python scripths, I thought it for Linux only. Offset func give error, if applyed directrly to layer.
Steve, thats exactly what I need, it left to modify this script a bit and it save a lot of nerves. This informatin is enough to build script for other steps of making seamless texture.


Top
 Post subject: Re: Question about "move" function
PostPosted: Fri Dec 23, 2016 10:04 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Dec 26, 2014
Posts: 205
Glad it worked Alexey, it shows how the move/translate works, but it might not be the best way forward, this second version is easier to follow and doesn’t require move/translate

(define (script-fu-resize4096 image layer)

(gimp-rect-select image 0 0 4096 4096 2 FALSE 0)
(gimp-edit-copy layer)
(gimp-image-resize image 8192 8192 0 0)
(gimp-layer-resize-to-image-size layer)
(gimp-rect-select image 4096 0 4096 4096 2 FALSE 0)
(gimp-edit-paste layer FALSE)
(gimp-floating-sel-anchor (car (gimp-image-get-active-drawable image)))
(gimp-displays-flush)
)


Top
 Post subject: Re: Question about "move" function
PostPosted: Fri Dec 23, 2016 1:18 pm  (#6) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
Steve wrote:
Glad it worked Alexey, it shows how the move/translate works, but it might not be the best way forward, this second version is easier to follow and doesn’t require move/translate

(define (script-fu-resize4096 image layer)

(gimp-rect-select image 0 0 4096 4096 2 FALSE 0)
(gimp-edit-copy layer)
(gimp-image-resize image 8192 8192 0 0)
(gimp-layer-resize-to-image-size layer)
(gimp-rect-select image 4096 0 4096 4096 2 FALSE 0)
(gimp-edit-paste layer FALSE)
(gimp-floating-sel-anchor (car (gimp-image-get-active-drawable image)))
(gimp-displays-flush)
)

Way too complicated.... why use the clipboard? All you need to do (Scheme or Python) is:
1) make a copy of the layer,
2) add it to thesame image
3) change the offset

So, in Python:
newlayer=layer.copy()
image.add_layer(newlayer,0)
newlayer.set_offsets(200,200)


Scheme code is not more complicated, just less readable :)

And the clipboard is for humans only!

_________________
Image


Top
 Post subject: Re: Question about "move" function
PostPosted: Fri Dec 23, 2016 3:51 pm  (#7) 
Offline
GimpChat Member
User avatar

Joined: Dec 26, 2014
Posts: 205
ofnuts wrote:
Steve wrote:
Glad it worked Alexey, it shows how the move/translate works, but it might not be the best way forward, this second version is easier to follow and doesn’t require move/translate

(define (script-fu-resize4096 image layer)

(gimp-rect-select image 0 0 4096 4096 2 FALSE 0)
(gimp-edit-copy layer)
(gimp-image-resize image 8192 8192 0 0)
(gimp-layer-resize-to-image-size layer)
(gimp-rect-select image 4096 0 4096 4096 2 FALSE 0)
(gimp-edit-paste layer FALSE)
(gimp-floating-sel-anchor (car (gimp-image-get-active-drawable image)))
(gimp-displays-flush)
)

Way too complicated.... why use the clipboard? All you need to do (Scheme or Python) is:
1) make a copy of the layer,
2) add it to thesame image
3) change the offset

So, in Python:
newlayer=layer.copy()
image.add_layer(newlayer,0)
newlayer.set_offsets(200,200)


Scheme code is not more complicated, just less readable :)

And the clipboard is for humans only!


I usually do things the hard way :roll: until someone teaches me an easier way :bigthup such is life

As regards python, it is more readable than scheme and I have as you once suggested to me started writing scripts with it, but its early days.

Steve


Top
 Post subject: Re: Question about "move" function
PostPosted: Fri Dec 23, 2016 5:11 pm  (#8) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
Steve wrote:
I usually do things the hard way :roll: until someone teaches me an easier way :bigthup such is life


Laziness is a virtue for programmers (the other two are said to be impatience and hubris)

_________________
Image


Top
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group