Index: vg-test.scm ================================================================== --- vg-test.scm +++ vg-test.scm @@ -17,11 +17,19 @@ (vg:add-lib d1 "firstlib" l1) ;; instantiate firstlib/firstcomp as inst1 in drawing d1 at 0,0 (vg:instantiate d1 "firstlib" "firstcomp" "inst1" 0 0) (vg:instantiate d1 "firstlib" "firstcomp" "inst2" 200 200) -;; (vg:drawing-scalex-set! d1 2) +(vg:drawing-scalex-set! d1 1.1) +(vg:drawing-scaley-set! d1 0.5) + +;; (define xtnts (vg:scale-offset-xy +;; (vg:component-get-extents c1) +;; 1.1 1.1 -2 -2)) + +(define xtnts (apply vg:grow-rect 10 10 (vg:components-get-extents c1))) +(vg:add-objs-to-comp c1 (apply vg:make-rect xtnts)) (define cnv #f) (define the-cnv (canvas #:size "500x400" #:expand "YES" Index: vg.scm ================================================================== --- vg.scm +++ vg.scm @@ -107,10 +107,17 @@ (case type ((r)(vg:rect-get-extents obj))))) (define (vg:rect-get-extents obj) (vg:obj-pts obj)) ;; extents are just the points for a rectangle + +(define (vg:grow-rect borderx bordery x1 y1 x2 y2) + (list + (- x1 borderx) + (- y1 bordery) + (+ x2 borderx) + (+ y2 bordery))) ;;====================================================================== ;; components ;;====================================================================== @@ -139,30 +146,32 @@ (define (vg:get-component drawing libname compname) (let* ((lib (hash-table-ref (vg:drawing-libs drawing) libname)) (inst (hash-table-ref (vg:lib-comps lib) compname))) inst)) -(define (vg:component-get-extents comp) +(define (vg:components-get-extents . comps) (let ((llx #f) (lly #f) (ulx #f) - (uly #f) - (objs (vg:comp-objs comp))) + (uly #f)) (for-each - (lambda (obj) - (let* ((extents (vg:get-extents obj)) - (ollx (list-ref extents 0)) - (olly (list-ref extents 1)) - (oulx (list-ref extents 2)) - (ouly (list-ref extents 3))) - (if (or (not llx)(< ollx llx))(set! llx ollx)) - (if (or (not lly)(< olly llx))(set! llx ollx)) - (if (or (not ulx)(< ollx llx))(set! llx ollx)) - (if (or (not uly)(< ollx llx))(set! llx ollx)))) - objs) + (lambda (comp) + (let ((objs (vg:comp-objs comp))) + (for-each + (lambda (obj) + (let* ((extents (vg:obj-get-extents obj)) + (ollx (list-ref extents 0)) + (olly (list-ref extents 1)) + (oulx (list-ref extents 2)) + (ouly (list-ref extents 3))) + (if (or (not llx)(< ollx llx))(set! llx ollx)) + (if (or (not lly)(< olly lly))(set! lly olly)) + (if (or (not ulx)(> oulx ulx))(set! ulx oulx)) + (if (or (not uly)(> ouly uly))(set! uly ouly)))) + objs))) + comps) (list llx lly ulx uly))) - ;;====================================================================== ;; libraries ;;======================================================================