Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 085641f

Browse files
committed
Add SVG vector graphics
1 parent 9fd352b commit 085641f

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

scripts/9/data.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,45 @@ var tests = [
15501550
]
15511551
}
15521552
]
1553+
}, {
1554+
id: 'svg',
1555+
status: 'stable',
1556+
name: 'Vector graphics',
1557+
items: [
1558+
{
1559+
id: 'image',
1560+
name: 'SVG as an image',
1561+
value: 1,
1562+
urls: [
1563+
[ 'w3c', 'https://www.w3.org/TR/SVG/' ]
1564+
]
1565+
}, {
1566+
id: 'inline',
1567+
name: 'SVG inline in the document',
1568+
value: 1,
1569+
urls: [
1570+
[ 'w3c', 'https://www.w3.org/TR/SVG/' ]
1571+
]
1572+
},
1573+
1574+
'<strong>Features</strong>',
1575+
1576+
{
1577+
id: 'foreignobject',
1578+
name: 'HTML in SVG using foreignObject',
1579+
value: 1,
1580+
urls: [
1581+
[ 'w3c', 'https://www.w3.org/TR/SVG/extend.html#ForeignObjectElement' ]
1582+
]
1583+
}, {
1584+
id: 'filters',
1585+
name: 'SVG Filters',
1586+
value: 1,
1587+
urls: [
1588+
[ 'w3c', 'https://www.w3.org/TR/SVG/filters.html' ],
1589+
]
1590+
}
1591+
]
15531592
}, {
15541593
id: 'canvas',
15551594
name: '2D Graphics',

scripts/9/engine.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2989,6 +2989,67 @@ Test9 = (function () {
29892989
},
29902990

29912991

2992+
/* svg as image */
2993+
2994+
function (results) {
2995+
var item = results.addItem({
2996+
key: 'svg.image',
2997+
passed: false
2998+
});
2999+
3000+
var img = new Image();
3001+
3002+
img.onerror = function () {
3003+
item.stopBackground();
3004+
};
3005+
3006+
img.onload = function () {
3007+
item.stopBackground();
3008+
item.update({
3009+
'passed': img.width == 42 && img.height == 42
3010+
});
3011+
};
3012+
3013+
img.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDIiIGhlaWdodD0iNDIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PC9zdmc+';
3014+
},
3015+
3016+
3017+
/* svg rendering */
3018+
3019+
function (results) {
3020+
var element = document.createElement('div');
3021+
element.innerHTML = '<svg width="42" height="42" xmlns="http://www.w3.org/2000/svg"></svg>';
3022+
document.body.appendChild(element);
3023+
3024+
results.addItem({
3025+
key: 'svg.inline',
3026+
passed: element.firstChild && element.firstChild.clientWidth == 42 && element.firstChild.clientHeight == 42
3027+
});
3028+
3029+
document.body.removeChild(element);
3030+
},
3031+
3032+
3033+
/* svg foreign object */
3034+
3035+
function (results) {
3036+
results.addItem({
3037+
key: 'svg.foreignobject',
3038+
passed: !!(document.createElementNS && typeof SVGForeignObjectElement != 'undefined' && document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject') instanceof SVGForeignObjectElement)
3039+
});
3040+
},
3041+
3042+
3043+
/* svg filters */
3044+
3045+
function (results) {
3046+
results.addItem({
3047+
key: 'svg.filters',
3048+
passed: 'SVGFEColorMatrixElement' in window && SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_SATURATE == 2
3049+
});
3050+
},
3051+
3052+
29923053
/* canvas element and 2d context */
29933054

29943055
function (results) {

0 commit comments

Comments
 (0)