【问题标题】:Convert SVG Co-ordinates to HTML Image Map Co-ordinates将 SVG 坐标转换为 HTML 图像地图坐标
【发布时间】:2013-09-22 21:40:21
【问题描述】:
【问题讨论】:
标签:
html
svg
imagemap
area
【解决方案1】:
要翻译 svg 坐标,必须获取每个坐标并将其移动到总位移图形、组和所有 svg。
svg地图区域翻译示例代码:
$ coord = "";
$ x = $ offset_x * $ scale_x + $ translate_x;
$ y = $ offset_y * $ scale_y + $ translate_y;
foreach ($ coordinates [ 1 ] as $ k => $ a) {
if ($ k% 2 == 0) {
$ coord. = round ($ x). ",";
$ x + = $ a * $ scale_x;
} else {
$ coord. = round ($ y). ",";
$ y + = $ a * $ scale_y;
}
}
$ coord = substr ($ coord, 0, -1) ;
其中translate x/y和scale x/y指的是g,offset x/y坐标为起始偏移图。
一般来说,svg 坐标以正常形式写入,主要要考虑所有偏移量以及 svg 坐标考虑了前一个的事实,但在所有地图区域坐标均取自原点。