Crop returns a new Canvas corresponding to the Canvas c with the given lengths added to the minimum and maximum x and y values of the Canvas's Rectangle. Note that cropping the right and top sides of the canvas requires specifying negative values of right and top.
(c Canvas, left, right, bottom, top vg.Length)
| 371 | // Note that cropping the right and top sides of the canvas |
| 372 | // requires specifying negative values of right and top. |
| 373 | func Crop(c Canvas, left, right, bottom, top vg.Length) Canvas { |
| 374 | minpt := vg.Point{ |
| 375 | X: c.Min.X + left, |
| 376 | Y: c.Min.Y + bottom, |
| 377 | } |
| 378 | maxpt := vg.Point{ |
| 379 | X: c.Max.X + right, |
| 380 | Y: c.Max.Y + top, |
| 381 | } |
| 382 | return Canvas{ |
| 383 | Canvas: c, |
| 384 | Rectangle: vg.Rectangle{Min: minpt, Max: maxpt}, |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | // Tiles creates regular subcanvases from a Canvas. |
| 389 | type Tiles struct { |
no outgoing calls