textureAtlas.js
799 字节
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
var fs = require('fs');
var Canvas = require('canvas');
require('zrender/lib/core/util').createCanvas = function () {
return new Canvas(128, 128);
};
var Surface = require('../../src/util/ZRTextureAtlasSurface');
var echarts = require('echarts');
global.document = {
createElement: function () {
return new Canvas(50, 50);
}
};
var surface = new Surface({
width: 128,
height: 128,
devicePixelRatio: 1
});
for (var i = 0; i < 2000; i++) {
var circle = new echarts.graphic.Circle({
shape: {
cx: 10,
cy: 10,
r: 10
},
fill: '#000'
});
surface.add(circle);
}
surface.getZr().refreshImmediately();
fs.writeFile('surface.png', surface.getTexture().image.toBuffer());
surface.getZr().dispose();