-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'image_tiles' of github.com:AnkurGel/markpdf into AnkurG…
…el-image_tiles
- Loading branch information
Showing
5 changed files
with
75 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/unidoc/unidoc/pdf/creator" | ||
"math" | ||
) | ||
|
||
// Watermarkable is a common interface for watermarkable image or paragraph | ||
type Watermarkable interface { | ||
creator.VectorDrawable | ||
SetPos(x, y float64) | ||
} | ||
|
||
func repeatTiles(watermark Watermarkable, c *creator.Creator) { | ||
w := watermark.Width() | ||
h := watermark.Height() | ||
pw := c.Context().PageWidth | ||
ph := c.Context().PageHeight | ||
|
||
nw := math.Ceil(pw / w) | ||
nh := math.Ceil(ph / h) | ||
|
||
debugInfo(fmt.Sprintf("Settings tiles of %v x %v", nw, nh)) | ||
for i := 0; i < int(nw); i++ { | ||
x := w * float64(i) | ||
for j := 0; j < int(nh); j++ { | ||
y := h * float64(j) | ||
watermark.SetPos(x + spacing * float64(i), y + spacing * float64(j)) | ||
err := c.Draw(watermark) | ||
if err != nil { | ||
fatalIfError(err, fmt.Sprintf("Error %s", err)) | ||
} | ||
} | ||
} | ||
} |