我刚刚得到一个使用的示例雪碧图形2D对象来自Adobe 的 Flex 3。仅供参考...Flex 3 现已开源。
(来自 Sprite Graphics2D java) 雪碧图形2D是 Java2D 的 Graphics2D API 的 SWF 特定实现。对该类的调用将转换为可用于构造 SWF Sprite 的 TagList。
我通过查看这两个类发现了这一点三次曲线测试.java and SpriteTranscoder.java.
运行此示例所需的唯一两个 jar 是 swfutils.jar 和 batik-awt-util.jar,它们可以在这里下载.
这是我的示例代码...
// Create the SpriteGraphics2D object
SpriteGraphics2D g = new SpriteGraphics2D(100, 100);
// Draw on to the graphics object
Font font = new Font("Serif", Font.PLAIN, 16);
g.setFont(font);
g.drawString("Test swf", 30, 30);
g.draw(new Line2D.Double(5, 5, 50, 60));
g.draw(new Line2D.Double(50, 60, 150, 40));
g.draw(new Line2D.Double(150, 40, 160, 10));
// Create a new empty movie
Movie m = new Movie();
m.version = 7;
m.bgcolor = new SetBackgroundColor(SwfUtils.colorToInt(255, 255, 255));
m.framerate = 12;
m.frames = new ArrayList(1);
m.frames.add(new Frame());
m.size = new Rect(11000, 8000);
// Get the DefineSprite from the graphics object
DefineSprite tag = g.defineSprite("swf-test");
// Place the DefineSprite on the first frame
Frame frame1 = (Frame) m.frames.get(0);
Matrix mt = new Matrix(0, 0);
frame1.controlTags.add(new PlaceObject(mt, tag, 1, null));
TagEncoder tagEncoder = new TagEncoder();
MovieEncoder movieEncoder = new MovieEncoder(tagEncoder);
movieEncoder.export(m);
//Write to file
FileOutputStream fos = new FileOutputStream(new File("/test.swf"));
tagEncoder.writeTo(fos);