Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Createjs 有没有办法将形状导出到图像文件?_Createjs_Easeljs - Fatal编程技术网

Createjs 有没有办法将形状导出到图像文件?

Createjs 有没有办法将形状导出到图像文件?,createjs,easeljs,Createjs,Easeljs,我在CreateJS中有一个项目,我想在没有CreateJS的情况下重新制作,但我的所有图像似乎都是一个EaselJS形状的格式。例如: this.shape_1 = new cjs.Shape(); this.shape_1.graphics.f("#465762").s().p("AgOAOQgFgFAAgJQAAgHAFgHQAHgFAHgBQAIABAHAFQAFAHAAAHQAAAJgFAFQgHAHgIgBQgHABgHgHg"); this.

我在CreateJS中有一个项目,我想在没有CreateJS的情况下重新制作,但我的所有图像似乎都是一个EaselJS形状的格式。例如:

this.shape_1 = new cjs.Shape();
this.shape_1.graphics.f("#465762").s().p("AgOAOQgFgFAAgJQAAgHAFgHQAHgFAHgBQAIABAHAFQAFAHAAAHQAAAJgFAFQgHAHgIgBQgHABgHgHg");
this.shape_1.setTransform(43.4,42,0.747,0.747);

有什么方法可以将其导出到图像文件中吗?

您可以通过缓存任何EaselJS DisplayObject,然后导出dataURL来导出它。请注意,您必须知道原始边界。如果您想要更大的缓存,只需增加
scale
参数

this.shape_1.cache(x, y, w, h, [scale]);
var url = this.shape_1.getCacheDataURL();
不幸的是,此方法不支持Canvas.toDataURL()的参数,因此如果需要,可以直接命中缓存:

this.shape_1.target.cacheCanvas.toDataURL(…[type], [encoderOptions]);
然后,您可以通过多种方式使用dataURL。在这上面。或者,只需将生成的缓存放入DOM中,然后右键单击它进行保存

document.body.appendChild(this.shape_1.target.cacheCanvas);
文件: