Use new canvas Path rect/SVG support.
This commit is contained in:
parent
adde60a994
commit
57a2d21ddf
2 changed files with 23 additions and 16 deletions
|
@ -480,7 +480,7 @@ var Map = {
|
||||||
controller = Map.df_controller;
|
controller = Map.df_controller;
|
||||||
elsif (typeof(controller) != 'hash')
|
elsif (typeof(controller) != 'hash')
|
||||||
controller = Map.Controller.get(controller);
|
controller = Map.Controller.get(controller);
|
||||||
|
|
||||||
if (controller == nil) {
|
if (controller == nil) {
|
||||||
me.controller = nil;
|
me.controller = nil;
|
||||||
} else {
|
} else {
|
||||||
|
@ -778,6 +778,12 @@ var Path = {
|
||||||
me._last_coord = size(coords) - 1;
|
me._last_coord = size(coords) - 1;
|
||||||
return me;
|
return me;
|
||||||
},
|
},
|
||||||
|
setDataSVG: func(svgPath)
|
||||||
|
{
|
||||||
|
me.reset();
|
||||||
|
me._node.setValues({'svg': svgPath});
|
||||||
|
return me;
|
||||||
|
},
|
||||||
# Add a path segment
|
# Add a path segment
|
||||||
addSegment: func(cmd, coords...)
|
addSegment: func(cmd, coords...)
|
||||||
{
|
{
|
||||||
|
@ -948,7 +954,7 @@ var Path = {
|
||||||
},
|
},
|
||||||
|
|
||||||
setColor: func me.setStroke(_getColor(arg)),
|
setColor: func me.setStroke(_getColor(arg)),
|
||||||
getColor: func me.getStroke(),
|
getColor: func me.getStroke(),
|
||||||
|
|
||||||
setColorFill: func me.setFill(_getColor(arg)),
|
setColorFill: func me.setFill(_getColor(arg)),
|
||||||
getColorFill: func me.getColorFill(),
|
getColorFill: func me.getColorFill(),
|
||||||
|
|
|
@ -502,13 +502,15 @@ var parsesvg = func(group, path, options = nil)
|
||||||
else if( name == "path" or name == "rect" )
|
else if( name == "path" or name == "rect" )
|
||||||
{
|
{
|
||||||
pushElement('path', attr['id']);
|
pushElement('path', attr['id']);
|
||||||
|
var p = stack[-1];
|
||||||
|
|
||||||
if( name == "rect" )
|
if( name == "rect" )
|
||||||
{
|
{
|
||||||
var width = evalCSSNum(attr['width']);
|
p.set('rect/left', evalCSSNum(attr['x']));
|
||||||
var height = evalCSSNum(attr['height']);
|
p.set('rect/top', evalCSSNum(attr['y']));
|
||||||
var x = evalCSSNum(attr['x']);
|
p.set('rect/width', evalCSSNum(attr['width']));
|
||||||
var y = evalCSSNum(attr['y']);
|
p.set('rect/height', evalCSSNum(attr['height']));
|
||||||
|
|
||||||
var rx = attr['rx'];
|
var rx = attr['rx'];
|
||||||
var ry = attr['ry'];
|
var ry = attr['ry'];
|
||||||
|
|
||||||
|
@ -517,15 +519,14 @@ var parsesvg = func(group, path, options = nil)
|
||||||
else if( rx == nil )
|
else if( rx == nil )
|
||||||
rx = ry;
|
rx = ry;
|
||||||
|
|
||||||
var cfg = {};
|
if( rx != nil ) {
|
||||||
if( rx != nil )
|
p.set('border-radius[0]', rx);
|
||||||
cfg["border-radius"] = [evalCSSNum(rx), evalCSSNum(ry)];
|
p.set('border-radius[1]', ry);
|
||||||
|
}
|
||||||
stack[-1].rect(x, y, width, height, cfg);
|
} else {
|
||||||
|
p.setDataSVG(attr['d']);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
parsePath(attr['d']);
|
|
||||||
|
|
||||||
var fillOpacity = style['fill-opacity'];
|
var fillOpacity = style['fill-opacity'];
|
||||||
if( fillOpacity != nil)
|
if( fillOpacity != nil)
|
||||||
stack[-1].set('fill', style['fill'] ~ sprintf("%02x", int(style['fill-opacity']*255)));
|
stack[-1].set('fill', style['fill'] ~ sprintf("%02x", int(style['fill-opacity']*255)));
|
||||||
|
@ -534,13 +535,13 @@ var parsesvg = func(group, path, options = nil)
|
||||||
|
|
||||||
var w = style['stroke-width'];
|
var w = style['stroke-width'];
|
||||||
stack[-1].setStrokeLineWidth( w != nil ? evalCSSNum(w) : 1 );
|
stack[-1].setStrokeLineWidth( w != nil ? evalCSSNum(w) : 1 );
|
||||||
|
|
||||||
var strokeOpacity = style['stroke-opacity'];
|
var strokeOpacity = style['stroke-opacity'];
|
||||||
if(strokeOpacity != nil)
|
if(strokeOpacity != nil)
|
||||||
stack[-1].set('stroke', (style['stroke'] ~ sprintf("%02x", int(style['stroke-opacity']*255))));
|
stack[-1].set('stroke', (style['stroke'] ~ sprintf("%02x", int(style['stroke-opacity']*255))));
|
||||||
else
|
else
|
||||||
stack[-1].set('stroke', style['stroke'] or "none");
|
stack[-1].set('stroke', style['stroke'] or "none");
|
||||||
|
|
||||||
var linecap = style['stroke-linecap'];
|
var linecap = style['stroke-linecap'];
|
||||||
if( linecap != nil )
|
if( linecap != nil )
|
||||||
stack[-1].setStrokeLineCap(style['stroke-linecap']);
|
stack[-1].setStrokeLineCap(style['stroke-linecap']);
|
||||||
|
|
Loading…
Add table
Reference in a new issue