Check-in [e9c252cf1d]

Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:svg usage added and discussion updated
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e9c252cf1d504159e5a3ea8100e5e68f16c61be7faab6d3756497128c35fda05
User & Date: rene 2018-09-18 20:20:01.065
Context
2018-09-19
13:27
Big CFV for multiple TIPs by DKF check-in: ae0cdb79ec user: dkf tags: trunk
2018-09-18
20:20
svg usage added and discussion updated check-in: e9c252cf1d user: rene tags: trunk
2018-09-16
16:23
TIP 517 now in VOTING state check-in: 2b1af3a2c0 user: fvogel tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to tip/507.md.
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
do not scale and are to tiny on high res mobile devices.
The same goes for the image formats provided by the img extension.

There is already an tk image extension at https://github.com/auriocus/tksvg
The implementation is using nanosvg. It has no other external dependencies
and is only 2 header files.










The original nanosvg project is hosted at https://github.com/memononen/nanosvg

# Specification

The already existing tksvg extension will be adapted and included in Tk.
A new image format will be created. The name is **svgnano**.



The **svgnano** image format has the following format suboptions:

**svgnano** *-dpi dpiValue -scale scaleValue -unit unitValue -x xValue -y yValue*

*dpiValue* is used in conversion between given coordiantes and screen resolution. The value must be greater then 0.0. The default value is 96.

*scaleValue* is used to scale the resulting image. The value must be greater then 0.0. The default value is 1.

*unitValue* is the unit of all coordinates in the svg data. Available units are px (default, coordinates in pixel), mm , cm and in.

*xValue* is used to move the created image in x-direction. The default value is 0.

*yValue* is used to move the created image in y-direction. The default value is 0.
.




The svgnano format supports a wide range of SVG features, but something may be missing p.e. text.





















































































# Discussion



- nanosvg is no full svg library

- the name of the image format should mention this (p.e. **nanosvg** or
**svgnano**)
- are there better libraries with our requirements (C only, license)?


# Implementation

A patch implementing these changes will be available in the fossil repository in the [tip-507 branch]
(https://core.tcl.tk/tk/timeline?r=tip-507).

The new format is in the photo.n man page described.

# Example of use

	    # the image data







>
>
>
>
>
>
>
>
>






>
>















>
>
>
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


>
>
|
>
|
<
<
>



|







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
do not scale and are to tiny on high res mobile devices.
The same goes for the image formats provided by the img extension.

There is already an tk image extension at https://github.com/auriocus/tksvg
The implementation is using nanosvg. It has no other external dependencies
and is only 2 header files.

**nanosvg** was choosen because it:

- has a suitable license
- is written in 2 plain C header files and can easily included
- is really lightweight
- is tested with tksvg
- can render images
- has no other external dependencies

The original nanosvg project is hosted at https://github.com/memononen/nanosvg

# Specification

The already existing tksvg extension will be adapted and included in Tk.
A new image format will be created. The name is **svgnano**.
The choosen name hints the usage of a not fully compatible svg parser.
It leaves the image name **svg** open for further usage.

The **svgnano** image format has the following format suboptions:

**svgnano** *-dpi dpiValue -scale scaleValue -unit unitValue -x xValue -y yValue*

*dpiValue* is used in conversion between given coordiantes and screen resolution. The value must be greater then 0.0. The default value is 96.

*scaleValue* is used to scale the resulting image. The value must be greater then 0.0. The default value is 1.

*unitValue* is the unit of all coordinates in the svg data. Available units are px (default, coordinates in pixel), mm , cm and in.

*xValue* is used to move the created image in x-direction. The default value is 0.

*yValue* is used to move the created image in y-direction. The default value is 0.
.
The given format options are only used at creation time of the image and are not preserved in the image.

# Supported SVG

The svgnano format supports a wide range of SVG features, but something may be missing p.e. text.

## Elements

- g
- path
- rect
- circle
- ellipse
- line
- polyline
- polygon
- linearGradient
- radialGradient
- stop
- defs
- svg
- style

## Attributes

- width, height
- viewBox
- preserveAspectRatio with none, xMin, xMid, xMax, yMin, yMid, yMax, slice

## Gradient Attributes

- gradientUnits with objectBoundingBox
- gradientTransform
- cx, cy, r
- fx, fy
- x1, y1, x2, y2
- spreadMethod with pad, reflect or repeat
- xlink:href

## Poly Attributes

- points

## Line Attributes

- x1, y1, x2, xy2

## Ellipse Attributes

- cx, cy
- rx, ry

## Circle Attributes

- cx, cy
- r

## Rectangle Attributes

- x, y
- width, height
- rx, ry

## Path Attributes

- d with m, M, l, L, h, H, v, V, c, C, s, S, q, Q, t, T, a, A, z, Z

## Style Attributes

- display with none, visibility, hidden, visible
- fill with nonzero, evenodd
- opacity
- fill-opacity
- stroke
- stroke-width
- stroke-dasharray
- stroke-dashoffset
- stroke-opacity
- stroke-linecap with butt, round, square
- stroke-linejoin with miter round bevel
- stroke-miterlimit
- fill-rule
- font-size
- transform with matrix, translate, scale, rotate, skewX, skewY
- stop-color
- stop-opacity
- offset
- id
- class

# Discussion

- http://code.activestate.com/lists/tcl-core/19871/
- http://code.activestate.com/lists/tcl-core/19994/

## Open questions



- are all of the above format options necessary? May be remove the *xValue* abd *yValue* options.

# Implementation

A patch implementing these changes is available in the fossil repository in the [tip-507 branch]
(https://core.tcl.tk/tk/timeline?r=tip-507).

The new format is in the photo.n man page described.

# Example of use

	    # the image data