Skip to content

Commit

Permalink
Workaround for PDF conversions
Browse files Browse the repository at this point in the history
The nice hatch pattern gets rasterized by web browsers/batik when
converting to PDF, leaving a pixely mess. This at least keep the output
clean until that is fixed.
  • Loading branch information
pbnjay committed Sep 18, 2014
1 parent c6a8d15 commit b40ff8d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drawpops.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var (
hideDisordered = flag.Bool("hide-disordered", false, "do not draw disordered regions")
hideMotifs = flag.Bool("hide-motifs", false, "do not draw motifs")
hideAxis = flag.Bool("hide-axis", false, "do not draw the aa position axis")
forPDF = flag.Bool("for-pdf", false, "use solid fill instead of patterns for PDF output")
)

const (
Expand All @@ -39,7 +40,7 @@ const svgHeader = `<?xml version='1.0'?>
<feGaussianBlur result="blurOut" stdDeviation="1" />
<feBlend in="SourceGraphic" in2="blurOut" mode="normal" />
</filter>
<pattern id="hatch" patternUnits="userSpaceOnUse" width="4" height="4">
<pattern id="disordered-hatch" patternUnits="userSpaceOnUse" width="4" height="4">
<path d="M-1,1 l2,-2 M0,4 l4,-4 M3,5 l2,-2" stroke="#000000" opacity="0.3" />
</pattern>
</defs>
Expand Down Expand Up @@ -186,6 +187,10 @@ func DrawSVG(w io.Writer, GraphicWidth int, changelist []string, g *PfamGraphicR
g.Metadata.Identifier, g.Metadata.Description, aaLen,
Padding, startY+(DomainHeight-BackboneHeight)/2, GraphicWidth-(Padding*2), BackboneHeight)

disFill := "url(#disordered-hatch)"
if *forPDF {
disFill = `#000;" opacity="0.15`
}
if !*hideMotifs {
// draw transmembrane, signal peptide, coiled-coil, etc motifs
for _, r := range g.Motifs {
Expand All @@ -204,7 +209,7 @@ func DrawSVG(w io.Writer, GraphicWidth int, changelist []string, g *PfamGraphicR
fmt.Fprintf(w, `<a xlink:title="%s">`, r.Type)
if r.Type == "disorder" {
// draw disordered regions with a understated diagonal hatch pattern
fmt.Fprintf(w, `<rect fill="url(#hatch)" x="%f" y="%d" width="%f" height="%d"/>`,
fmt.Fprintf(w, `<rect fill="%s" x="%f" y="%d" width="%f" height="%d"/>`, disFill,
Padding+sstart, startY+(DomainHeight-BackboneHeight)/2, swidth, BackboneHeight)
} else {
fmt.Fprintf(w, `<rect fill="%s" x="%f" y="%d" width="%f" height="%d" filter="url(#ds)"/>`, BlendColorStrings(r.Color, "#FFFFFF"),
Expand Down

0 comments on commit b40ff8d

Please sign in to comment.