FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
gnuplot-old/term/svg.trm at master · gnuplot/gnuplot-old · GitHub
gnuplot
/
gnuplot-old
Public
Notifications
You must be signed in to change notification settings
Fork
56
Star
139
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
gnuplot-old
/
term
/
svg.trm
Copy path
More file actions
More file actions
Latest commit
History
History
History
2260 lines (1973 loc) · 72.5 KB
Breadcrumbs
gnuplot-old
/
term
/
svg.trm
Copy path
File metadata and controls
2260 lines (1973 loc) · 72.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Hello, Emacs, this is -*-C-*-
* $Id: svg.trm,v 1.189 2017-06-28 19:05:33 sfeam Exp $
*/
/*------------------------------------------------------------------------------------------------------------------------------------
GNUPLOT - svg.trm
This file is included by ../term.c.
This terminal driver supports:
W3C Scalable Vector Graphics
AUTHOR
Amedeo Farello
afarello@libero.it
HEAVILY MODIFIED by
Hans-Bernhard Br"oker
broeker@physik.rwth-aachen.de
DomTerm support
Per Bothner <per@bothner.com>
------------------------------------------------------------------------------------------------------------------------------------*/
/* PM3D support by Johannes Zellner <johannes@zellner.org>, May-16-2002 */
/* set_color fixes by Petr Mikulik <mikulik@physics.muni.cz>, June-10-2002 */
/* ISO-Latin encoding, Font selection fixes, option "fixed|dynamic" by
* Wilhelm Braunschober <Wilhelm.Braunschober@t-online.de>, Feb-21-2002 */
/*
* Additional code for gnuplot versions 4.2 and 4.3
* Ethan Merritt <merritt@u.washington.edu>
*
* Tweaked code for compatibility with Sodipodi svg viewer/editor.
* Added enhanced text support.
* Additional line properties.
* Increase resolution by adding a coordinate scale factor.
* Support dashed lines, TC_* color model.
* Change path markup from style='attribute: foo' to attribute='foo'
*
* Additional code for gnuplot versions 4.5
* Ethan Merritt <merritt@u.washington.edu>
*
* Wrap each plot in a named group <g id="name_plot_%02d">
* Set the name using 'set term svg name "foo"'
* Background option
* Bitmap image support by creating and linking to external png files
* Mouse-tracking with coordinate readout.
* Version 4.7 (April 2012) hypertext support
*
* Contributed by <plotter@piments.com>
* Javascript code to toggle plots on/off
*
* Revised font sizing Oct 2012
* specify font-size without "pt" units.
*
* Inline image data in Base64 encoding
* Daniel Sebald May 2016
*
* Transition to SVG 2.0
* remove DTD
* remove option "fontfile" and references to SVG fonts
*/
/*
* Code for gnuplot version 4.5
* Bold -> font-weight:bold
* Italic -> font-style:italic
* Trying to match well with PNG output.
* Rich Seymour <rseymour@usc.edu>
*/
#include
"driver.h"
#ifdef
TERM_REGISTER
register_term
(
svg
)
#endif
#ifdef
TERM_PROTO
TERM_PUBLIC
void
SVG_options
__PROTO
((
void
));
TERM_PUBLIC
void
SVG_init
__PROTO
((
void
));
TERM_PUBLIC
void
SVG_graphics
__PROTO
((
void
));
TERM_PUBLIC
void
SVG_text
__PROTO
((
void
));
TERM_PUBLIC
void
SVG_linetype
__PROTO
((
int
linetype
));
TERM_PUBLIC
void
SVG_dashtype
__PROTO
((
int
type
,
t_dashtype
*
custom_dash_type
));
TERM_PUBLIC
void
SVG_move
__PROTO
((
unsigned
int
x
,
unsigned
int
y
));
TERM_PUBLIC
void
SVG_vector
__PROTO
((
unsigned
int
x
,
unsigned
int
y
));
TERM_PUBLIC
void
SVG_put_text
__PROTO
((
unsigned
int
x
,
unsigned
int
y
,
const
char
*
str
));
TERM_PUBLIC
void
SVG_reset
__PROTO
((
void
));
TERM_PUBLIC
int
SVG_justify_text
__PROTO
((
enum
JUSTIFY
mode
));
TERM_PUBLIC
int
SVG_text_angle
__PROTO
((
int
ang
));
TERM_PUBLIC
void
SVG_point
__PROTO
((
unsigned
int
x
,
unsigned
int
y
,
int
pointstyle
));
TERM_PUBLIC
int
SVG_set_font
__PROTO
((
const
char
*
font
));
/* TERM_PUBLIC void SVG_pointsize __PROTO((double pointsize)); */
TERM_PUBLIC
void
SVG_fillbox
__PROTO
((
int
style
,
unsigned
int
x1
,
unsigned
int
y1
,
unsigned
int
width
,
unsigned
int
height
));
TERM_PUBLIC
void
SVG_linewidth
__PROTO
((
double
linewidth
));
TERM_PUBLIC
int
SVG_make_palette
__PROTO
((
t_sm_palette
*
));
TERM_PUBLIC
void
SVG_previous_palette
__PROTO
((
void
));
TERM_PUBLIC
void
SVG_set_color
__PROTO
((
t_colorspec
*
));
TERM_PUBLIC
void
SVG_filled_polygon
__PROTO
((
int
,
gpiPoint
*
));
TERM_PUBLIC
void
SVG_layer
__PROTO
((
t_termlayer
syncpoint
));
TERM_PUBLIC
void
ENHsvg_OPEN
__PROTO
((
char
*
,
double
,
double
,
TBOOLEAN
,
TBOOLEAN
,
int
));
TERM_PUBLIC
void
ENHsvg_FLUSH
__PROTO
((
void
));
TERM_PUBLIC
void
ENHsvg_put_text
__PROTO
((
unsigned
int
,
unsigned
int
,
const
char
*
));
TERM_PUBLIC
void
ENHsvg_writec
__PROTO
((
int
));
TERM_PUBLIC
void
SVG_path
__PROTO
((
int
p
));
TERM_PUBLIC
void
SVG_hypertext
__PROTO
((
int
,
const
char
*
));
#ifdef
WRITE_PNG_IMAGE
TERM_PUBLIC
void
SVG_image
__PROTO
((
unsigned
m
,
unsigned
n
,
coordval
*
image
,
gpiPoint
*
corner
,
t_imagecolor
color_mode
));
#endif
#define
SVG_SCALE
10.
/* Coordinates accuracy is 1/SVG_SCALE pixel */
#define
PREC
1
/* Decimal places needed for SVG_SCALEd values */
#define
Y
(
y
) ((float)((int)term->ymax - (int)y) / SVG_SCALE)
#define
X
(
x
) ((float)(x) / SVG_SCALE)
#define
SVG_XMAX
(600 * SVG_SCALE)
#define
SVG_YMAX
(480 * SVG_SCALE)
#endif
/* TERM_PROTO */
#ifndef
TERM_PROTO_ONLY
#ifdef
TERM_BODY
static
t_sm_palette
SVG_palette
;
static
unsigned
char
SVG_red
=
0
;
static
unsigned
char
SVG_green
=
0
;
static
unsigned
char
SVG_blue
=
0
;
static
double
SVG_alpha
=
0.0
;
static
unsigned
char
SVG_color_mode
=
TC_DEFAULT
;
static
char
*
SVG_linecolor
=
NULL
;
static
char
*
SVG_name
=
NULL
;
static
char
*
SVG_scriptdir
=
NULL
;
static
TBOOLEAN
SVG_mouseable
=
FALSE;
static
TBOOLEAN
SVG_standalone
=
FALSE;
static
TBOOLEAN
SVG_domterm
=
FALSE;
static
TBOOLEAN
SVG_emit_doctype
=
TRUE;
static
TBOOLEAN
SVG_groupFilledIsOpen
=
FALSE;
/* open pm3d group flag*/
static
TBOOLEAN
SVG_inTextBox
=
FALSE;
struct
SVG_PEN
{
double
width
;
char
color
[
8
];
};
static
unsigned
int
SVG_xSize
=
SVG_XMAX
;
/* plot horizontal size */
static
unsigned
int
SVG_ySize
=
SVG_YMAX
;
/* plot vertical size*/
static
TBOOLEAN
SVG_fixed_size
=
TRUE;
/* make SVG viewer size fixed */
static
unsigned
int
SVG_xLast
=
UINT_MAX
;
/* current pen horizontal position*/
static
unsigned
int
SVG_yLast
=
UINT_MAX
;
/* current pen vertical position*/
static
int
SVG_LineType
=
LT_NODRAW
;
/* current line type*/
static
double
SVG_LineWidth
=
1.0
;
/* current line width*/
static
double
SVG_linewidth_factor
=
1.0
;
/* Multiplier for linewidths */
static
double
SVG_dashlength
=
1.0
;
/* Multiplier for dash patterns */
static
t_linecap
SVG_linecap
=
BUTT
;
/* linejoin and linecap */
static
int
SVG_TextAngle
=
0
;
/* current text orientation*/
static
enum
JUSTIFY
SVG_TextJust
=
LEFT
;
/* current text justification*/
/* default text font family: */
static
char
*
SVG_fontNameDef
=
NULL
;
static
char
*
SVG_fontStyleDef
=
NULL
;
/* default font style */
static
char
*
SVG_fontWeightDef
=
NULL
;
/* default font weight */
static
double
SVG_fontSizeDef
=
12
;
/* default text size*/
/* current text font family: */
static
char
*
SVG_fontNameCur
=
NULL
;
static
char
*
SVG_fontStyleCur
=
NULL
;
/* current font style */
static
char
*
SVG_fontWeightCur
=
NULL
;
/* current font weight */
static
double
SVG_fontSizeCur
=
12
;
/* current text size*/
static
double
SVG_fontscale
=
1.0
;
/* multiplier for nominal font size */
static
TBOOLEAN
SVG_groupIsOpen
=
FALSE;
/* open group flag*/
static
TBOOLEAN
SVG_pathIsOpen
=
FALSE;
/* open path flag*/
static
unsigned
int
SVG_path_count
=
0
;
/* size of current path*/
static
struct
SVG_PEN
SVG_pens
[
16
];
/* pen descriptors*/
static
int
SVG_fillPattern
=
-1
;
/* active fill pattern (-1 == undefined) */
static
unsigned
int
SVG_fillPatternIndex
=
0
;
static
int
SVG_background
=
-1
;
static
int
SVG_imageno
=
0
;
static
int
SVG_plotno
=
0
;
static
TBOOLEAN
SVG_gridline
=
FALSE;
static
TBOOLEAN
SVG_hasgrid
=
FALSE;
static
double
SVG_fontAscent
=
0
;
/* estimated current font ascent*/
static
double
SVG_fontDescent
=
0
;
/* estimated current font descent*/
static
double
SVG_fontLeading
=
0
;
/* estimated current font leading*/
static
double
SVG_fontAvWidth
=
0
;
/* estimated current font char average width*/
static
short
SVG_Pen_RealID
__PROTO
((
int
));
static
void
SVG_PathOpen
__PROTO
((
void
));
static
void
SVG_PathClose
__PROTO
((
void
));
static
void
SVG_AddSpaceOrNewline
__PROTO
((
void
));
static
void
SVG_GroupOpen
__PROTO
((
void
));
static
void
SVG_GroupClose
__PROTO
((
void
));
static
void
SVG_SetFont
__PROTO
((
const
char
*
name
,
double
size
));
static
void
SVG_GroupFilledOpen
__PROTO
((
void
));
static
void
SVG_GroupFilledClose
__PROTO
((
void
));
static
void
SVG_StyleColor
__PROTO
((
const
char
*
));
static
void
SVG_StyleFillColor
__PROTO
((
void
));
static
void
SVG_local_reset
__PROTO
((
void
));
static
void
SVG_DefineFillPattern
__PROTO
((
int
fillpat
));
static
void
SVG_MoveForced
__PROTO
((
unsigned
int
x
,
unsigned
int
y
));
static
void
SVG_write_preamble
__PROTO
((
void
));
/* Stuff for enhanced text mode */
static
int
ENHsvg_string_state
=
0
;
static
double
ENHsvg_x_offset
=
0
;
static
TBOOLEAN
ENHsvg_preserve_spaces
=
FALSE;
/* Support for dashed lines */
#define
SVG_dashtypes
5
static
char
*
SVG_defaultdashpattern
[
SVG_dashtypes
]
=
{
""
,
" 5,8"
,
" 2,4"
,
" 8,4,2,4"
,
" 9,4,1,4,1,4"
};
static
char
*
SVG_axis_dashpattern
=
"2,4"
;
static
int
SVG_dasharray
[
SVG_dashtypes
][
7
]
=
{
{
0
,
0
,
0
,
0
,
0
,
0
,
0
},
{
5
,
8
,
0
,
0
,
0
,
0
,
0
},
{
2
,
4
,
0
,
0
,
0
,
0
,
0
},
{
8
,
4
,
2
,
4
,
0
,
0
,
0
},
{
9
,
4
,
1
,
4
,
1
,
4
,
0
}
};
static
char
*
SVG_dashpattern
=
NULL
;
static
char
SVG_custom_dash_pattern
[
64
];
/* Support for embedded hypertext */
static
char
*
SVG_hypertext_text
=
NULL
;
/*------------------------------------------------------------------------------------------------------------------------------------
SVG_Pen_RealID
------------------------------------------------------------------------------------------------------------------------------------*/
static
short
SVG_Pen_RealID
(
int
inPenCode
)
{
if
(
inPenCode
>=
13
)
inPenCode
%=
13
;
/* normalize pen code*/
inPenCode
+=
3
;
if
(
inPenCode
<
0
)
inPenCode
=
0
;
/* LT_NODRAW or LT_BACKGROUND should use background color */
return
(
inPenCode
);
}
/*------------------------------------------------------------------------------------------------------------------------------------
SVG_GroupOpen
------------------------------------------------------------------------------------------------------------------------------------*/
static
void
SVG_GroupOpen
()
{
SVG_GroupFilledClose
();
if
(!
SVG_groupIsOpen
) {
fprintf
(
gpoutfile
,
"<g fill=\"none\" color=\"%s\" stroke=\""
,
SVG_pens
[
SVG_Pen_RealID
(
SVG_LineType
)].
color
);
if
(
SVG_color_mode
==
TC_RGB
)
fprintf
(
gpoutfile
,
"rgb(%3d, %3d, %3d)"
,
SVG_red
,
SVG_green
,
SVG_blue
);
else
if
(
SVG_color_mode
==
TC_LT
)
fprintf
(
gpoutfile
,
"%s"
,
SVG_linecolor
);
else
fprintf
(
gpoutfile
,
"currentColor"
);
fprintf
(
gpoutfile
,
"\" "
);
fprintf
(
gpoutfile
,
"stroke-width=\"%.2f\" stroke-linecap=\"%s\" stroke-linejoin=\"%s\""
,
SVG_pens
[
SVG_Pen_RealID
(
SVG_LineType
)].
width
*
SVG_linewidth_factor
,
SVG_linecap
==
ROUNDED
?
"round"
:
SVG_linecap
==
SQUARE
?
"square"
:
"butt"
,
SVG_linecap
==
ROUNDED
?
"round"
:
"miter"
);
fprintf
(
gpoutfile
,
">\n"
);
SVG_groupIsOpen
=
TRUE;
}
}
/*------------------------------------------------------------------------------------------------------------------------------------
SVG_GroupClose
------------------------------------------------------------------------------------------------------------------------------------*/
static
void
SVG_GroupClose
()
{
SVG_GroupFilledClose
();
if
(
SVG_groupIsOpen
) {
fputs
(
"</g>\n"
,
gpoutfile
);
SVG_groupIsOpen
=
FALSE;
SVG_fillPattern
=
-1
;
}
}
/*------------------------------------------------------------------------------------------------------------------------------------
SVG_PathOpen
------------------------------------------------------------------------------------------------------------------------------------*/
static
void
SVG_PathOpen
()
{
if
(!
SVG_pathIsOpen
) {
SVG_GroupFilledClose
();
fputs
(
"\t<path "
,
gpoutfile
);
/* Line color */
if
(
SVG_color_mode
==
TC_RGB
)
fprintf
(
gpoutfile
,
"stroke='rgb(%3d, %3d, %3d)' "
,
SVG_red
,
SVG_green
,
SVG_blue
);
else
if
(
SVG_color_mode
==
TC_LT
)
fprintf
(
gpoutfile
,
"stroke='%s' "
,
SVG_linecolor
);
/* Axis is always dotted */
if
(
SVG_LineType
==
LT_AXIS
)
fprintf
(
gpoutfile
,
"stroke-dasharray='2,4' "
);
/* Other patterns were selected by a previous call to SVG_dashtype */
else
if
(
SVG_dashpattern
)
fprintf
(
gpoutfile
,
"stroke-dasharray='%s' "
,
SVG_dashpattern
);
/* RGBA */
if
(
SVG_alpha
!=
0.0
)
fprintf
(
gpoutfile
,
"opacity='%4.2f' "
,
1.0
-
SVG_alpha
);
/* Mark grid lines so that we can toggle them on/off */
if
(
SVG_gridline
)
fprintf
(
gpoutfile
,
"class=\"gridline\" "
);
fputs
(
" d='"
,
gpoutfile
);
SVG_pathIsOpen
=
TRUE;
}
}
/*------------------------------------------------------------------------------------------------------------------------------------
SVG_PathClose
------------------------------------------------------------------------------------------------------------------------------------*/
static
void
SVG_PathClose
()
{
if
(
SVG_pathIsOpen
) {
SVG_GroupFilledClose
();
fprintf
(
gpoutfile
,
" '/>"
);
SVG_path_count
=
0
;
SVG_pathIsOpen
=
FALSE;
}
}
/*------------------------------------------------------------------------------------------------------------------------------------
SVG_AddSpaceOrNewline
------------------------------------------------------------------------------------------------------------------------------------*/
static
void
SVG_AddSpaceOrNewline
()
{
if
(
SVG_path_count
%
8
==
0
)
/* avoid excessive line length*/
fputs
(
"\n\t\t"
,
gpoutfile
);
else
fputs
(
" "
,
gpoutfile
);
}
/*------------------------------------------------------------------------------------------------------------------------------------
SVG_SetFont
------------------------------------------------------------------------------------------------------------------------------------*/
static
void
SVG_SetFont
(
const
char
*
name
,
double
size
)
{
if
(
name
!=
SVG_fontNameCur
) {
free
(
SVG_fontNameCur
);
SVG_fontNameCur
=
gp_strdup
(
name
);
}
SVG_fontSizeCur
=
size
;
/* since we cannot interrogate SVG about text properties and according
* to SVG 1.0 W3C Candidate Recommendation 2 August 2000 the
* "line-height" of the 'text' element is defined to be equal to the
* 'font-size' (!), we have to to define font properties in a less
* than optimal way */
SVG_fontAscent
=
(
SVG_fontSizeCur
*
0.90
*
SVG_SCALE
);
SVG_fontDescent
=
(
SVG_fontSizeCur
*
0.25
*
SVG_SCALE
);
SVG_fontLeading
=
(
SVG_fontSizeCur
*
0.35
*
SVG_SCALE
);
SVG_fontAvWidth
=
(
SVG_fontSizeCur
*
0.70
*
SVG_SCALE
);
term
->
h_char
=
SVG_fontAvWidth
;
term
->
v_char
=
(
SVG_fontAscent
+
SVG_fontDescent
+
SVG_fontLeading
);
}
static
void
SVG_GroupFilledOpen
()
{
if
(!
SVG_groupFilledIsOpen
) {
SVG_PathClose
();
fputs
(
"\t<g stroke='none' shape-rendering='crispEdges'>\n"
,
gpoutfile
);
SVG_groupFilledIsOpen
=
TRUE;
}
}
static
void
SVG_GroupFilledClose
()
{
if
(
SVG_groupFilledIsOpen
) {
fputs
(
"\t</g>\n"
,
gpoutfile
);
SVG_groupFilledIsOpen
=
FALSE;
}
}
static
void
SVG_StyleColor
(
const
char
*
paint
)
{
if
(
SVG_color_mode
==
TC_RGB
)
fprintf
(
gpoutfile
,
"%s = 'rgb(%3d, %3d, %3d)'"
,
paint
,
SVG_red
,
SVG_green
,
SVG_blue
);
else
if
(
SVG_color_mode
==
TC_LT
)
fprintf
(
gpoutfile
,
"%s = '%s'"
,
paint
,
SVG_linecolor
);
else
fprintf
(
gpoutfile
,
"%s = 'currentColor'"
,
paint
);
}
static
void
SVG_StyleFillColor
()
{
SVG_StyleColor
(
"fill"
);
}
static
void
SVG_DefineFillPattern
(
int
fillpat
)
{
char
*
path
;
char
*
style
=
"stroke"
;
fillpat
%=
8
;
if
(
fillpat
!=
SVG_fillPattern
) {
SVG_fillPattern
=
fillpat
;
SVG_PathClose
();
SVG_fillPatternIndex
++
;
fprintf
(
gpoutfile
,
"\t<defs>\n"
"\t\t<pattern id='gpPat%d' patternUnits='userSpaceOnUse' x='0' y='0' width='8' height='8'>\n"
,
SVG_fillPatternIndex
);
switch
(
fillpat
) {
default
:
case
0
:
path
=
""
;
break
;
case
1
:
path
=
"M0,0 L8,8 M0,8 L8,0"
;
break
;
case
2
:
path
=
"M0,0 L8,8 M0,8 L8,0 M0,4 L4,8 L8,4 L4,0 L0,4"
;
break
;
case
3
:
path
=
"M0,0 L0,8 L8,8 L8,0 L0,0"
;
style
=
"fill"
;
break
;
case
4
:
path
=
"M-4,0 L8,12 M0,-4 L12,8"
;
break
;
case
5
:
path
=
"M-4,8 L8,-4 M0,12 L12,0"
;
break
;
case
6
:
path
=
"M-2,8 L4,-4 M0,12 L8,-4 M4,12 L10,0"
;
break
;
case
7
:
path
=
"M-2,0 L4,12 M0,-4 L8,12 M4,-4 L10,8"
;
break
;
}
if
(
*
path
) {
char
*
figure
=
"fill:none;"
;
if
(!
strcmp
(
style
,
"fill"
))
figure
=
"stroke:none;"
;
if
(
SVG_color_mode
==
TC_RGB
)
fprintf
(
gpoutfile
,
"\t\t\t<path style='%s %s:rgb(%d,%d,%d)' d='%s'/>\n"
,
figure
,
style
,
SVG_red
,
SVG_green
,
SVG_blue
,
path
);
else
if
(
SVG_color_mode
==
TC_LT
)
fprintf
(
gpoutfile
,
"\t\t\t<path style = '%s %s:%s' d= '%s'/>\n"
,
figure
,
style
,
SVG_linecolor
,
path
);
else
fprintf
(
gpoutfile
,
"\t\t\t<path style = '%s %s:currentColor' d='%s'/>\n"
,
figure
,
style
,
path
);
}
fputs
(
"\t\t</pattern>\n"
"\t</defs>\n"
,
gpoutfile
);
}
}
static
void
SVG_MoveForced
(
unsigned
int
x
,
unsigned
int
y
)
{
if
(
SVG_path_count
>
512
)
SVG_PathClose
();
SVG_PathOpen
();
fprintf
(
gpoutfile
,
"M%.*f,%.*f"
,
PREC
,
X
(
x
),
PREC
,
Y
(
y
));
SVG_path_count
++
;
SVG_AddSpaceOrNewline
();
SVG_xLast
=
x
;
SVG_yLast
=
y
;
}
/*------------------------------------------------------------------------------------------------------------------------------------
SVG_options
------------------------------------------------------------------------------------------------------------------------------------*/
TERM_PUBLIC
void
SVG_options
()
{
/* Annoying hack to handle the case of 'set termoption' after */
/* we have already initialized the terminal settings. */
if
(!
almost_equals
(
c_token
-
1
,
"termopt$ion"
))
SVG_local_reset
();
if
(
strcmp
(
term
->
name
,
"domterm"
)
==
0
) {
SVG_emit_doctype
=
FALSE;
SVG_domterm
=
TRUE;
}
else
{
SVG_emit_doctype
=
TRUE;
SVG_domterm
=
FALSE;
}
while
(!
END_OF_COMMAND
) {
if
(
almost_equals
(
c_token
,
"s$ize"
)) {
double
value
;
c_token
++
;
if
(
END_OF_COMMAND
)
int_error
(
c_token
,
"expecting x size"
);
value
=
real_expression
();
if
(
value
<
2
)
int_error
(
c_token
,
"x size out of range"
);
SVG_xSize
=
value
*
SVG_SCALE
;
if
(
equals
(
c_token
,
","
))
c_token
++
;
if
(
END_OF_COMMAND
)
int_error
(
c_token
,
"expecting y size"
);
value
=
real_expression
();
if
(
value
<
2
)
int_error
(
c_token
,
"y size out of range"
);
SVG_ySize
=
value
*
SVG_SCALE
;
continue
;
}
if
(
equals
(
c_token
,
"mouse"
)
||
almost_equals
(
c_token
,
"mous$ing"
)) {
c_token
++
;
SVG_mouseable
=
TRUE;
continue
;
}
if
(
almost_equals
(
c_token
,
"stand$alone"
)) {
c_token
++
;
SVG_standalone
=
TRUE;
continue
;
}
if
(
equals
(
c_token
,
"name"
)) {
c_token
++
;
SVG_name
=
try_to_get_string
();
if
(!
SVG_name
)
int_error
(
c_token
,
"expecting a plot name"
);
if
(
SVG_name
[
strspn
(
SVG_name
,
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_1234567890"
)])
int_error
(
c_token
-
1
,
"name must contain only alphanumerics or _"
);
continue
;
}
if
(
equals
(
c_token
,
"jsdir"
)) {
c_token
++
;
SVG_scriptdir
=
try_to_get_string
();
continue
;
}
if
(
almost_equals
(
c_token
,
"d$ynamic"
)) {
c_token
++
;
SVG_fixed_size
=
FALSE;
continue
;
}
if
(
almost_equals
(
c_token
,
"fi$xed"
)){
c_token
++
;
SVG_fixed_size
=
TRUE;
continue
;
}
if
(
almost_equals
(
c_token
,
"enh$anced"
)) {
c_token
++
;
term
->
put_text
=
ENHsvg_put_text
;
term
->
flags
|=
TERM_ENHANCED_TEXT
;
continue
;
}
if
(
almost_equals
(
c_token
,
"noenh$anced"
)) {
c_token
++
;
term
->
put_text
=
SVG_put_text
;
term
->
flags
&= ~
TERM_ENHANCED_TEXT
;
continue
;
}
if
(
almost_equals
(
c_token
,
"fn$ame"
)
||
almost_equals
(
c_token
,
"font"
)) {
char
*
s
,
*
comma
;
c_token
++
;
if
(!(
s
=
try_to_get_string
()))
int_error
(
c_token
,
"expecting font name"
);
comma
=
strrchr
(
s
,
','
);
if
(
comma
&&
(
1
==
sscanf
(
comma
+
1
,
"%lf"
,
&
SVG_fontSizeDef
)))
*
comma
=
'\0'
;
if
(
*
s
) {
char
*
bold
,
*
italic
;
if
(!((
bold
=
strstr
(
s
,
" bold"
))))
bold
=
strstr
(
s
,
" Bold"
);
if
(!((
italic
=
strstr
(
s
,
" italic"
))))
italic
=
strstr
(
s
,
" Italic"
);
free
(
SVG_fontNameDef
);
SVG_fontNameDef
=
s
;
if
(
italic
) {
SVG_fontStyleDef
=
"italic"
;
SVG_fontNameDef
[
strlen
(
s
)
-
strlen
(
italic
)]
=
NUL
;
}
else
{
SVG_fontStyleDef
=
"normal"
;
}
if
(
bold
) {
SVG_fontWeightDef
=
"bold"
;
SVG_fontNameDef
[
strlen
(
s
)
-
strlen
(
bold
)]
=
NUL
;
}
else
{
SVG_fontWeightDef
=
"normal"
;
}
}
else
free
(
s
);
continue
;
}
if
(
equals
(
c_token
,
"fontscale"
)) {
c_token
++
;
SVG_fontscale
=
real_expression
();
if
(
SVG_fontscale
<=
0
)
SVG_fontscale
=
1.0
;
continue
;
}
if
(
almost_equals
(
c_token
,
"linew$idth"
)
||
equals
(
c_token
,
"lw"
)) {
c_token
++
;
SVG_linewidth_factor
=
real_expression
();
if
(
SVG_linewidth_factor
<=
0.0
)
SVG_linewidth_factor
=
1.0
;
continue
;
}
if
(
almost_equals
(
c_token
,
"dashl$ength"
)
||
equals
(
c_token
,
"dl"
)) {
c_token
++
;
SVG_dashlength
=
real_expression
();
if
(
SVG_dashlength
<
0.5
)
SVG_dashlength
=
1.0
;
continue
;
}
if
(
almost_equals
(
c_token
,
"round$ed"
)) {
c_token
++
;
SVG_linecap
=
ROUNDED
;
continue
;
}
if
(
equals
(
c_token
,
"square"
)) {
c_token
++
;
SVG_linecap
=
SQUARE
;
continue
;
}
if
(
equals
(
c_token
,
"butt"
)) {
c_token
++
;
SVG_linecap
=
BUTT
;
continue
;
}
/* Not used in version 5 */
if
(
equals
(
c_token
,
"solid"
)
||
almost_equals
(
c_token
,
"dash$ed"
)) {
c_token
++
;
continue
;
}
if
(
almost_equals
(
c_token
,
"backg$round"
)) {
c_token
++
;
SVG_background
=
parse_color_name
();
continue
;
}
int_error
(
c_token
,
"unrecognized terminal option"
);
}
/* I don't think any error checks on font name are possible; just set it */
SVG_set_font
(
""
);
/* Save options back into options string in normalized format */
sprintf
(
term_options
,
"size %d,%d%s %s font '%s,%g' "
,
(
int
)(
SVG_xSize
/
SVG_SCALE
), (
int
)(
SVG_ySize
/
SVG_SCALE
),
SVG_fixed_size
?
" fixed"
:
" dynamic"
,
term
->
put_text
==
ENHsvg_put_text
?
"enhanced"
:
""
,
SVG_fontNameCur
,
SVG_fontSizeCur
);
if
(
SVG_mouseable
) {
sprintf
(
term_options
+
strlen
(
term_options
),
"mousing "
);
}
if
(
SVG_standalone
) {
sprintf
(
term_options
+
strlen
(
term_options
),
"standalone "
);
}
if
(
SVG_name
) {
sprintf
(
term_options
+
strlen
(
term_options
),
"name \"%s\" "
,
SVG_name
);
}
sprintf
(
term_options
+
strlen
(
term_options
),
SVG_linecap
==
ROUNDED
?
"rounded "
:
SVG_linecap
==
SQUARE
?
"square "
:
"butt "
);
sprintf
(
term_options
+
strlen
(
term_options
),
"dashlength %.1f "
,
SVG_dashlength
);
if
(
SVG_linewidth_factor
!=
1.0
) {
sprintf
(
term_options
+
strlen
(
term_options
),
"linewidth %3.1f "
,
SVG_linewidth_factor
);
}
if
(
SVG_background
>=
0
) {
sprintf
(
term_options
+
strlen
(
term_options
),
"background \"#%06x\" "
,
SVG_background
);
}
}
static
void
SVG_local_reset
()
{
SVG_xSize
=
SVG_XMAX
;
SVG_ySize
=
SVG_YMAX
;
SVG_fixed_size
=
TRUE;
free
(
SVG_fontNameDef
);
SVG_fontNameDef
=
gp_strdup
(
"Arial"
);
SVG_fontSizeDef
=
12
;
SVG_mouseable
=
FALSE;
SVG_standalone
=
FALSE;
free
(
SVG_name
);
SVG_name
=
NULL
;
free
(
SVG_scriptdir
);
SVG_scriptdir
=
NULL
;
SVG_gridline
=
FALSE;
SVG_hasgrid
=
FALSE;
/* Default to enhanced text */
term
->
put_text
=
ENHsvg_put_text
;
term
->
flags
|=
TERM_ENHANCED_TEXT
;
}
/*------------------------------------------------------------------------------------------------------------------------------------
SVG_init
------------------------------------------------------------------------------------------------------------------------------------*/
TERM_PUBLIC
void
SVG_init
()
{
/* setup pens*/
SVG_pens
[
0
].
width
=
SVG_LineWidth
;
strcpy
(
SVG_pens
[
0
].
color
,
"white"
);
/* should really be background */
SVG_pens
[
1
].
width
=
SVG_LineWidth
;
strcpy
(
SVG_pens
[
1
].
color
,
"black"
);
SVG_pens
[
2
].
width
=
SVG_LineWidth
;
strcpy
(
SVG_pens
[
2
].
color
,
"gray"
);
SVG_pens
[
3
].
width
=
SVG_LineWidth
;
strcpy
(
SVG_pens
[
3
].
color
,
"red"
);
SVG_pens
[
4
].
width
=
SVG_LineWidth
;
strcpy
(
SVG_pens
[
4
].
color
,
"green"
);
SVG_pens
[
5
].
width
=
SVG_LineWidth
;
strcpy
(
SVG_pens
[
5
].
color
,
"blue"
);
SVG_pens
[
6
].
width
=
SVG_LineWidth
;
strcpy
(
SVG_pens
[
6
].
color
,
"cyan"
);
SVG_pens
[
7
].
width
=
SVG_LineWidth
;
sprintf
(
SVG_pens
[
7
].
color
,
"#%2.2X%2.2X%2.2X"
,
21
,
117
,
69
);
/* pine green*/
SVG_pens
[
8
].
width
=
SVG_LineWidth
;
sprintf
(
SVG_pens
[
8
].
color
,
"#%2.2X%2.2X%2.2X"
,
0
,
0
,
148
);
/* navy*/
SVG_pens
[
9
].
width
=
SVG_LineWidth
;
sprintf
(
SVG_pens
[
9
].
color
,
"#%2.2X%2.2X%2.2X"
,
255
,
153
,
0
);
/* orange*/
SVG_pens
[
10
].
width
=
SVG_LineWidth
;
sprintf
(
SVG_pens
[
10
].
color
,
"#%2.2X%2.2X%2.2X"
,
0
,
153
,
161
);
/* green blue*/
SVG_pens
[
11
].
width
=
SVG_LineWidth
;
sprintf
(
SVG_pens
[
11
].
color
,
"#%2.2X%2.2X%2.2X"
,
214
,
214
,
69
);
/* olive*/
SVG_pens
[
12
].
width
=
SVG_LineWidth
;
sprintf
(
SVG_pens
[
12
].
color
,
"#%2.2X%2.2X%2.2X"
,
163
,
145
,
255
);
/* cornflower*/
SVG_pens
[
13
].
width
=
SVG_LineWidth
;
sprintf
(
SVG_pens
[
13
].
color
,
"#%2.2X%2.2X%2.2X"
,
255
,
204
,
0
);
/* gold*/
SVG_pens
[
14
].
width
=
SVG_LineWidth
;
sprintf
(
SVG_pens
[
14
].
color
,
"#%2.2X%2.2X%2.2X"
,
214
,
0
,
120
);
/* mulberry*/
SVG_pens
[
15
].
width
=
SVG_LineWidth
;
sprintf
(
SVG_pens
[
15
].
color
,
"#%2.2X%2.2X%2.2X"
,
171
,
214
,
0
);
/* green yellow*/
if
(
SVG_background
>=
0
)
sprintf
(
SVG_pens
[
0
].
color
,
"#%2.2X%2.2X%2.2X"
,
(
SVG_background
>>
16
)
&
0xff
,
(
SVG_background
>>
8
)
&
0xff
,
(
SVG_background
)
&
0xff
);
SVG_LineType
=
LT_NODRAW
;
/* set xmax, ymax*/
term
->
xmax
=
SVG_xSize
;
term
->
ymax
=
SVG_ySize
;
/* set current font, including h_char and v_char */
SVG_SetFont
(
SVG_fontNameCur
,
SVG_fontSizeCur
);
/* set h_tic, v_tic*/
term
->
h_tic
=
term
->
v_char
/
2
;
term
->
v_tic
=
term
->
v_char
/
2
;
}
/* write file header*/
static
void
SVG_write_preamble
()
{
int
len
;
double
stroke_width
;
char
*
svg_encoding
=
""
;
switch
(
encoding
) {
case
S_ENC_ISO8859_1
:
svg_encoding
=
"encoding=\"iso-8859-1\" "
;
break
;
case
S_ENC_ISO8859_2
:
svg_encoding
=
"encoding=\"iso-8859-2\" "
;
break
;
case
S_ENC_ISO8859_9
:
svg_encoding
=
"encoding=\"iso-8859-9\" "
;
break
;
case
S_ENC_ISO8859_15
:
svg_encoding
=
"encoding=\"iso-8859-15\" "
;
break
;
case
S_ENC_CP850
:
svg_encoding
=
"encoding=\"ibm-850\" "
;
break
;
case
S_ENC_CP852
:
svg_encoding
=
"encoding=\"ibm-852\" "
;
break
;
case
S_ENC_CP950
:
svg_encoding
=
"encoding=\"cp950\" "
;
break
;
case
S_ENC_CP1250
:
svg_encoding
=
"encoding=\"windows-1250\" "
;
break
;
case
S_ENC_CP1251
:
svg_encoding
=
"encoding=\"windows-1251\" "
;
break
;
case
S_ENC_CP1252
:
svg_encoding
=
"encoding=\"windows-1252\" "
;
break
;
case
S_ENC_KOI8_R
:
svg_encoding
=
"encoding=\"koi8-r\" "
;
break
;
case
S_ENC_KOI8_U
:
svg_encoding
=
"encoding=\"koi8-u\" "
;
break
;
case
S_ENC_SJIS
:
svg_encoding
=
"encoding=\"Shift_JIS\" "
;
break
;
case
S_ENC_CP437
:
svg_encoding
=
""
;
break
;
default
:
/* UTF-8 */
svg_encoding
=
"encoding=\"utf-8\" "
;
break
;
}
if
(
SVG_domterm
)
fprintf
(
gpoutfile
,
"\033]72;"
);
if
(
SVG_emit_doctype
)
fprintf
(
gpoutfile
,
"<?xml version=\"1.0\" %s standalone=\"no\"?>\n"
,
svg_encoding
);
fprintf
(
gpoutfile
,
"<svg "
);
if
(
SVG_mouseable
)
fprintf
(
gpoutfile
,
" onload=\"if (typeof(gnuplot_svg)!='undefined') gnuplot_svg.Init(evt)\" "
);
if
(
SVG_fixed_size
)
fprintf
(
gpoutfile
,
"\n width=\"%u\" height=\"%u\""
,
(
unsigned
int
) (
term
->
xmax
/
SVG_SCALE
),
(
unsigned
int
) (
term
->
ymax
/
SVG_SCALE
));
fprintf
(
gpoutfile
,
"\n viewBox=\"0 0 %u %u\"\n"
,
(
unsigned
int
) (
term
->
xmax
/
SVG_SCALE
),
(
unsigned
int
) (
term
->
ymax
/
SVG_SCALE
));
fprintf
(
gpoutfile
,
" xmlns=\"http://www.w3.org/2000/svg\"\n"
);
fprintf
(
gpoutfile
,
" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
);
#if
(
0
)
/* This should be required, but Firefox gets it totally wrong */
fprintf
(
gpoutfile
,
" xml:space=\"preserve\"\n"
);
#endif
fprintf
(
gpoutfile
,
">\n\n"
);
/* TODO: It would be nice to print the actual plot title here */
fprintf
(
gpoutfile
,
"<title>%s</title>\n"
,
SVG_name
?
SVG_name
:
"Gnuplot"
);
fprintf
(
gpoutfile
,
"<desc>Produced by GNUPLOT %s patchlevel %s </desc>\n\n"
,
gnuplot_version
,
gnuplot_patchlevel
);
/*
* FIXME: This code could be shared with canvas.trm
* Figure out the full URL to use for xlink:href="gnuplot_svg.js"
*/
if
(
SVG_scriptdir
==
NULL
) {
#ifdef
GNUPLOT_JS_DIR
# if
defined(
_WIN32
)
SVG_scriptdir
=
RelativePathToGnuplot
(
GNUPLOT_JS_DIR
);
# else
/* !_WIN32 */
/* use hardcoded _absolute_ path */
SVG_scriptdir
=
gp_strdup
(
GNUPLOT_JS_DIR
);
# endif
#else
SVG_scriptdir
=
gp_strdup
(
""
);
#endif
/* GNUPLOT_JS_DIR */
}
#if
!defined(
VMS
)
len
=
strlen
(
SVG_scriptdir
);
# if
defined(
_WIN32
)
if
(
*
SVG_scriptdir
&&
SVG_scriptdir
[
len
-
1
]
!=
'\\'
&&
SVG_scriptdir
[
len
-
1
]
!=
'/'
) {
SVG_scriptdir
=
gp_realloc
(
SVG_scriptdir
,
len
+
2
,
"jsdir"
);
if
(
SVG_scriptdir
[
len
-
1
]
==
'\\'
)
/* use backslash if used in jsdir, otherwise slash */
strcat
(
SVG_scriptdir
,
"\\"
);
else
strcat
(
SVG_scriptdir
,
"/"
);
}
# else
if
(
*
SVG_scriptdir
&&
SVG_scriptdir
[
len
-
1
]
!=
'/'
) {
SVG_scriptdir
=
gp_realloc
(
SVG_scriptdir
,
len
+
2
,
"jsdir"
);
strcat
(
SVG_scriptdir
,
"/"
);
}
# endif
#endif
if
(
SVG_mouseable
) {
/* Inclusion of gnuplot_svg.js is sufficient to support toggling plots on/off */
if
(!
SVG_standalone
) {
fprintf
(
gpoutfile
,
"<script type=\"text/javascript\" xlink:href=\"%sgnuplot_svg.js\"/>\n"
,
SVG_scriptdir
);
}
else
{
/* "standalone" option includes the mousing code in the file itself */
char
*
fullname
=
NULL
;
char
*
name
=
"gnuplot_svg.js"
;
char
buf
[
256
];
FILE
*
svg_js_fd
;
fullname
=
gp_alloc
(
strlen
(
SVG_scriptdir
)
+
strlen
(
name
)
+
4
,
"javascript name"
);
strcpy
(
fullname
,
SVG_scriptdir
);
PATH_CONCAT
(
fullname
,
name
);
svg_js_fd
=
fopen
(
fullname
,
"r"
);
if
(!
svg_js_fd
)
int_warn
(
NO_CARET
,
"Failed to insert javascript file %s\n"
,
fullname
);
else
{
fprintf
(
gpoutfile
,
"<script type=\"text/javascript\" > <![CDATA[\n"
);
while
(
fgets
(
buf
,
sizeof
(
buf
),
svg_js_fd
))
fputs
(
buf
,
gpoutfile
);
fprintf
(
gpoutfile
,
"]]>\n</script>\n"
);
fclose
(
svg_js_fd
);
}
free
(
fullname
);
}
}
if
(
SVG_mouseable
) {
/* FIXME: Should only do this for 2D plots */
/* This is extra code to support tracking the mouse coordinates */
fprintf
(
gpoutfile
,
"\n<!-- Tie mousing to entire bounding box of the plot -->\n"
);
fprintf
(
gpoutfile
,
"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\""
,
0
,
0
, (
int
)(
term
->
xmax
/
SVG_SCALE
), (
int
)(
term
->
ymax
/
SVG_SCALE
));
fprintf
(
gpoutfile
,
" fill=\"#%06x\" stroke=\"black\" stroke-width=\"1\"\n"
,
SVG_background
>
0
?
SVG_background
:
0xffffff
);
fprintf
(
gpoutfile
,
"onclick=\"gnuplot_svg.toggleCoordBox(evt)\" onmousemove=\"gnuplot_svg.moveCoordBox(evt)\"/>\n"
);
fprintf
(
gpoutfile
,
"\n<!-- Also track mouse when it is on a plot element -->\n"
);
fprintf
(
gpoutfile
,
"<g id=\"gnuplot_canvas\" onclick=\"gnuplot_svg.toggleCoordBox(evt)\" onmousemove=\"gnuplot_svg.moveCoordBox(evt)\">\n\n"
);
}
else
{
fprintf
(
gpoutfile
,
"<g id=\"gnuplot_canvas\">\n\n"
);
fprintf
(
gpoutfile
,
"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\""
,
0
,
0
, (
int
)(
term
->
xmax
/
SVG_SCALE
), (
int
)(
term
->
ymax
/
SVG_SCALE
));
if
(
SVG_background
>=
0
)
fprintf
(
gpoutfile
,
" fill=\"#%06x\""
,
SVG_background
);
else
fprintf
(
gpoutfile
,
" fill=\"none\""
);
fprintf
(
gpoutfile
,
"/>\n"
);
}
/* Start prologue section of output file, and load fonts if requested */
fprintf
(
gpoutfile
,
"<defs>\n"
);
/* definitions of point symbols */
/* FIXME: SVG scales linewidth along with the marker itself, and
* there seems to be no way to avoid that without copying the
* marker definition into the file, rather than referencing a
* defined one :-( That would make for much larger files */
/* "\t<path id='gpPt3' stroke-width='%.3f' d='M-1,-1 h2 v2 h-2 z'/>\n" */
stroke_width
=
2.0
*
SVG_SCALE
/
term
->
h_tic
;
fprintf
(
gpoutfile
,
"\n"
/* dot: */
"\t<circle id='gpDot' r='0.5' stroke-width='0.5'/>\n"
/* 0 plus */
"\t<path id='gpPt0' stroke-width='%.3f' stroke='currentColor' d='M-1,0 h2 M0,-1 v2'/>\n"
/* 1 X */
"\t<path id='gpPt1' stroke-width='%.3f' stroke='currentColor' d='M-1,-1 L1,1 M1,-1 L-1,1'/>\n"
/* 2 star */
"\t<path id='gpPt2' stroke-width='%.3f' stroke='currentColor' d='M-1,0 L1,0 M0,-1 L0,1 M-1,-1 L1,1 M-1,1 L1,-1'/>\n"
/* 3 box */
"\t<rect id='gpPt3' stroke-width='%.3f' stroke='currentColor' x='-1' y='-1' width='2' height='2'/>\n"
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL