1

I am drawing a complex path to render a 3D image from scratch. It is the task and use of 3D engines is not allowed.

I am using:

GraphicsContext gc = getGraphicsContext2D();
gc.clearRect(x, y, w, h);
gc.appendSVGPath(svg);
gc.stroke();

svg is a very long string that contains svg graphic.

What I have noticed is that the value of gc.path.pointTypes.length keeps increasing by > 400k each time graphics are rendered and that slows down simulation with each loop.

How can I clear the path of GraphicsContext?

ps: It is package-private, no access.

4

1 回答 1

1

Call beginPath() before appendSVGPath().

https://docs.oracle.com/javase/8/javafx/api/javafx/scene/canvas/GraphicsContext.html#beginPath--

于 2017-04-12T09:25:27.283 回答