1
2static void
3print_SVG_header(FILE         *fh,
4                const float   scale[2],
5                const float   transform[2],
6                unsigned int  options)
7{
8  fprintf(fh,
9          "%s",
10          SVG_structure_plot_header);
11
12  fprintf(fh,
13          "  <g transform=\"scale(%7f,%7f) translate(%7f,%7f)\">\n",
14          scale[0],
15          scale[1],
16          transform[0],
17          transform[1]);
18}
19
20
21PRIVATE void
22print_SVG_footer(FILE *fh)
23{
24  fprintf(fh,
25          "  </g>\n%s",
26          SVG_structure_plot_footer);
27}
28
29
30PRIVATE void
31print_SVG_bases(FILE          *fh,
32                float         *X,
33                float         *Y,
34                const char    *string,
35                unsigned int  n)
36{
37  unsigned int i;
38
39  fprintf(fh,
40          "    <g transform=\"translate(-4.6, 4)\" id=\"seq\">\n");
41
42  for (i = 0; i < n; i++)
43    fprintf(fh,
44            "      <text class=\"nucleotide\" x=\"%.3f\" y=\"%.3f\">%c</text>\n",
45            X[i], Y[i], string[i]);
46
47  fprintf(fh,
48          "    </g>\n");
49}
50
51PRIVATE void
52print_SVG_backbone(FILE         *fh,
53                   const float  *X,
54                   const float  *Y,
55                   unsigned int n)
56{
57  unsigned int i;
58
59  fprintf(fh,
60          "    <polyline class=\"backbone\" id=\"outline\" points=\"\n");
61
62  for (i = 0; i < n; i++)
63    fprintf(fh,
64            "      %3.3f,%3.3f\n",
65            X[i],
66            Y[i]);
67
68  fprintf(fh,
69          "    \" />\n");
70}
71
72
73PRIVATE void
74print_SVG_pairs(FILE          *fh,
75                const short   *pt,
76                const float   *X,
77                const float   *Y,
78                const float   *CX,
79                const float   *CY,
80                unsigned int  n,
81                unsigned int  plot_type)
82{
83  unsigned int i, j;
84
85  fprintf(fh,
86          "    <g id=\"pairs\">\n");
87
88  for (i = 1; i <= n; i++) {
89    if ((j = (unsigned int)pt[i]) > i) {
90      if (plot_type == VRNA_PLOT_TYPE_CIRCULAR) {
91        fprintf(fh,
92                "      <path class=\"basepairs\" id=\"%u,%u\" d=\"M %6.5f %6.5f C %6.5f,%6.5f %6.5f,%6.5f %6.5f %6.5f\" />\n",
93                i,
94                j,
95                X[i - 1],
96                Y[i - 1],
97                CX[i - 1],
98                CY[i - 1],
99                CX[j - 1],
100                CY[j - 1],
101                X[j - 1],
102                Y[j - 1]);
103       } else {
104        fprintf(fh,
105                "      <line class=\"basepairs\" id=\"%u,%u\" x1=\"%6.5f\" y1=\"%6.5f\" x2=\"%6.5f\" y2=\"%6.5f\" />\n",
106                i, j,
107                X[i - 1], Y[i - 1],
108                X[j - 1], Y[j - 1]);
109      }
110    }
111  }
112  fprintf(fh,
113          "    </g>\n");
114}
115