-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsurface.js
41 lines (29 loc) · 1.06 KB
/
surface.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var Class = require('../../core/class');
var Container = require('../../dom/container');
var Element = require('../../dom/native');
var DOM = require('./dom');
var precision = 100;
var VMLSurface = Class(Element, Container, {
initialize: function VMLSurface(width, height, existingElement){
this.element = existingElement || document.createElement('vml');
this.containerElement = DOM.createElement('group');
this.element.appendChild(this.containerElement);
if (width != null && height != null) this.resize(width, height);
},
resize: function(width, height){
this.width = width;
this.height = height;
var style = this.element.style;
style.pixelWidth = width;
style.pixelHeight = height;
style = this.containerElement.style;
style.width = width;
style.height = height;
var halfPixel = (0.5 * precision);
this.containerElement.coordorigin = halfPixel + ',' + halfPixel;
this.containerElement.coordsize = (width * precision) + ',' + (height * precision);
return this;
}
});
VMLSurface.tagName = 'av:vml';
module.exports = VMLSurface;