Check-in [85300fa9ac]
Not logged in

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

Overview
Comment:add optional rotation to materialicons from ticket [2b90520896]
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 85300fa9ac81c7ab91e24f983ccbdbf4873009a6
User & Date: chw 2019-07-05 06:11:48
References
2019-07-05
06:13 Closed ticket [2b90520896]: Add rotation angle to MaterialIcons plus 5 other changes artifact: 1d09c83a57 user: chw
Context
2019-07-05
19:37
add tk upstream changes check-in: 77138bb427 user: chw tags: trunk
06:11
add optional rotation to materialicons from ticket [2b90520896] check-in: 85300fa9ac user: chw tags: trunk
2019-07-04
17:43
add -scaleto option to enhanced photo copy for ticket [7044332162] check-in: 01e4d678d7 user: chw tags: trunk
Changes

Changes to assets/materialicons0.2/materialicons.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
..
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...
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
...
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# Module to on-demand render MaterialIcons-Regular.svg
# into photo images using tksvg.
#
# chw January 2019
# image_ncg contributed by dzach May 2019

package require Tk
package require tdom
package require tksvg

namespace eval ::MaterialIcons {

................................................................................
	}
	set template0 {
	    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
	    <svg id="%%s" width="%g" height="%g" viewBox="%s" version="1.1">
	      <g>
		<path fill="%%s" fill-opacity="%%g"
		 stroke="%%s" stroke-width="%%g"
		 transform="scale(1,-1) translate(0,%g)"
		 d="%%s"/>
	      </g>
	    </svg>
	}
	lassign $bbox x1 y1 x2 y2
	set w [expr {$x2 - $x1}]
	set h [expr {$y2 - $y1}]
................................................................................
	variable glyph
	tailcall lsort [array names glyph $pattern]
    }

    # Return SVG for named icon with optional fill color and opacity.

    proc svg {name {color black} {opacity 1.0}
	{stroke none} {strokewidth 1.0}} {
	variable glyph
	variable template
	if {![info exists glyph($name)]} {
	    return -code error "glyph $name does not exist"
	}
	tailcall format $template $name $color $opacity \
	    $stroke $strokewidth $glyph($name)
    }

    # Return photo image for named icon with optional size, fill color,
    # and opacity. If size is negative, it specifies pixels, else points
    # taking the current tk scaling into account.

    proc image {name {size 16} {color black} {opacity 1.0}} {
................................................................................
	} elseif {$val < 0} {
	    set val [expr {-1.0 * $val}]
	}
	return $val
    }

    # Like the "image_nc" method but accepting many options:
    #   glyph		glyph name to be rendered
    #   name		name of photo image
    #   -size S		size with optional unit suffix
    #   -fill C		fill color
    #   -opacity O	fill opacity
    #   -stroke C	stroke color
    #   -strokewidth S	stroke width with optional unit suffix


    proc image_ncg {name imgname args} {
	variable viewbox
	array set opts {
	    -size 24d -fill black -opacity 1.0 -stroke none -strokewidth 1.0

	}
	array set opts $args
	lassign $viewbox x y w h
	set size [val2px $opts(-size)]
	if {$size == 0} {
	    return -code error "invalid size"
	}
................................................................................
	    # reverse the scale
	    set opts(-strokewidth) \
		[expr {abs([val2px $opts(-strokewidth)] / $scale)}]
	}
	tailcall ::image create photo $imgname \
	    -format [list svg -scale $scale] \
	    -data [svg $name $opts(-fill) $opts(-opacity) $opts(-stroke) \
		$opts(-strokewidth)]
    }

    # Make some procs visible in MaterialIcons ensemble.

    namespace ensemble create -subcommands {
	names svg image image_nc flush rebuild image_ncg
    }

}

package provide MaterialIcons 0.2




|







 







|







 







|






|







 







|
|





>




|
>







 







|











1
2
3
4
5
6
7
8
9
10
11
12
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
..
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...
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
...
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# Module to on-demand render MaterialIcons-Regular.svg
# into photo images using tksvg.
#
# chw January 2019
# image_ncg contributed by dzach May/July 2019

package require Tk
package require tdom
package require tksvg

namespace eval ::MaterialIcons {

................................................................................
	}
	set template0 {
	    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
	    <svg id="%%s" width="%g" height="%g" viewBox="%s" version="1.1">
	      <g>
		<path fill="%%s" fill-opacity="%%g"
		 stroke="%%s" stroke-width="%%g"
		 transform="rotate(%%g,256,256) scale(1,-1) translate(0,%g)"
		 d="%%s"/>
	      </g>
	    </svg>
	}
	lassign $bbox x1 y1 x2 y2
	set w [expr {$x2 - $x1}]
	set h [expr {$y2 - $y1}]
................................................................................
	variable glyph
	tailcall lsort [array names glyph $pattern]
    }

    # Return SVG for named icon with optional fill color and opacity.

    proc svg {name {color black} {opacity 1.0}
	{stroke none} {strokewidth 1.0} {angle 0}} {
	variable glyph
	variable template
	if {![info exists glyph($name)]} {
	    return -code error "glyph $name does not exist"
	}
	tailcall format $template $name $color $opacity \
	    $stroke $strokewidth $angle $glyph($name)
    }

    # Return photo image for named icon with optional size, fill color,
    # and opacity. If size is negative, it specifies pixels, else points
    # taking the current tk scaling into account.

    proc image {name {size 16} {color black} {opacity 1.0}} {
................................................................................
	} elseif {$val < 0} {
	    set val [expr {-1.0 * $val}]
	}
	return $val
    }

    # Like the "image_nc" method but accepting many options:
    #   name		glyph name to be rendered
    #   imgname		name of photo image
    #   -size S		size with optional unit suffix
    #   -fill C		fill color
    #   -opacity O	fill opacity
    #   -stroke C	stroke color
    #   -strokewidth S	stroke width with optional unit suffix
    #   -angle A	angle in degrees

    proc image_ncg {name imgname args} {
	variable viewbox
	array set opts {
	    -size 24d -fill black -opacity 1.0 -stroke none
	    -strokewidth 1.0 -angle 0
	}
	array set opts $args
	lassign $viewbox x y w h
	set size [val2px $opts(-size)]
	if {$size == 0} {
	    return -code error "invalid size"
	}
................................................................................
	    # reverse the scale
	    set opts(-strokewidth) \
		[expr {abs([val2px $opts(-strokewidth)] / $scale)}]
	}
	tailcall ::image create photo $imgname \
	    -format [list svg -scale $scale] \
	    -data [svg $name $opts(-fill) $opts(-opacity) $opts(-stroke) \
		$opts(-strokewidth) $opts(-angle)]
    }

    # Make some procs visible in MaterialIcons ensemble.

    namespace ensemble create -subcommands {
	names svg image image_nc flush rebuild image_ncg
    }

}

package provide MaterialIcons 0.2