RSS/Atom feed Twitter
Site is read-only, email is disabled

How to find out path length?

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

4 of 4 messages available
Toggle history

Please log in to manage your subscriptions.

How to find out path length? Paolo Herms 24 Sep 16:51
  How to find out path length? Sven Neumann 24 Sep 22:06
How to find out path length? saulgoode 25 Sep 04:41
  How to find out path length? Paolo Herms 27 Sep 08:56
Paolo Herms
2006-09-24 16:51:46 UTC (over 18 years ago)

How to find out path length?

Hello,
I've got a cartographic image and I designed a path on it. Is there any way to find out its length? What I want to do is to measure the length of a path in the real landscape. Thanks in advance

Sven Neumann
2006-09-24 22:06:03 UTC (over 18 years ago)

How to find out path length?

Hi,

On Sun, 2006-09-24 at 16:51 +0200, Paolo Herms wrote:

I've got a cartographic image and I designed a path on it. Is there any way to find out its length? What I want to do is to measure the length of a path in the real landscape.

You could write a script that uses the PDB function gimp-vectors-stroke-get-length to do this. I am not sure but I believe that this functionality is new in GIMP 2.3 and not available in GIMP 2.2

Sven

saulgoode
2006-09-25 04:41:01 UTC (over 18 years ago)

How to find out path length?

If you are using Script-fu and your script is for versions 2.2.x of the GIMP then the following function will return the length of a given path. It will work with version 2.3 but will generate some deprecation warnings (and 2.3 provides better methods).

;; 'sflib-path-get-length' returns the length of the specified path ;;
;; NOTE: If the end of the path is a X=0, Y=0 (and the slope ;; is zero there) then the value returned will be ;; slightly shorter (as much as 1.4) than actual. ;; (The path may *start* at 0,0)

(define (sflib-path-get-length image pathname) (let* (
(path (gimp-path-get-points image pathname)) (last-index (* 9 (- (trunc (/ (+ (caddr path) 3) 9)) 1))) (points (cadr (cddr path)))
(point-guess)
(point-lo (list (aref points 0) (aref points 1))) (point-hi (list (aref points last-index) (aref points (+ last-index 1))))
(guess (sqrt (+ (* (- (car point-hi) (car point-lo)) (- (car point-hi) (car point-lo))) (* (- (cadr point-hi) (cadr point-lo)) (- (cadr point-hi) (cadr point-lo))))) )
(guess-lo 0)
(guess-hi (* guess 2))
(Done FALSE)
(pnt (gimp-path-get-point-at-dist image guess-hi)) )
(while (not (and (= (car pnt) 0) (= (cadr pnt) 0) (= (caddr pnt) 0))) (set! guess-hi (* guess-hi 2)) (set! pnt (gimp-path-get-point-at-dist image guess-hi)) )

(while (= Done FALSE)
(set! point-guess (gimp-path-get-point-at-dist image guess)) (if (and (= (car point-guess) 0) (= (cadr point-guess) 0) (= (caddr point-guess) 0))
(begin
(set! point-hi point-guess) (set! guess-hi guess)
(set! guess (/ (+ guess guess-lo) 2)) )
(if (or (and (= (car point-guess) (car point-lo)) (= (cadr point-guess) (cadr point-lo)) )
(and (= (car point-guess) (car point-hi)) (= (cadr point-guess) (cadr point-hi)) ))
(set! Done TRUE)
(begin
(set! point-lo point-guess) (set! guess-lo guess)
(set! guess (/ (+ guess guess-hi) 2)) )
)
)
)
guess
)
)

Paolo Herms
2006-09-27 08:56:15 UTC (over 18 years ago)

How to find out path length?

On Monday, 25. September 2006 04:41, saulgoode wrote:

If you are using Script-fu and your script is for versions 2.2.x of the GIMP then the following function will return the length of a given path. It will work with version 2.3 but will generate some deprecation warnings (and 2.3 provides better methods).

;; 'sflib-path-get-length' returns the length of the specified path ;; [...]

Works great, thanks.