2

我需要能够接受椭圆(计算)画笔参数,例如间距、硬度、圆度、角度和直径,然后根据这些属性计算位图图像。

有谁知道执行此操作的算法(或我在哪里可以找到它)?我在图形编程方面的经验有限,到目前为止我一直找不到。

4

2 回答 2

1

This is the kind of thing you want to use a library for, most likely the Java 2D API. It includes facilities for fills, strokes, transforms, and filters. Its model is similar to many libraries in that you trace out a path with operators moveTo and lineTo or curveTo, which are abstracted in shapes like Ellipse2D; and then you fill or stroke the resultant path with a paint operator. I highly recommend reading the Java 2D tutorial and understanding how the different parts fit together.

I would take roughly the following steps to create this drawing:

  • Compute the final dimensions of the rotated ellipse after blurring.
  • Create a BuferredImage of that size and call its createGraphics method to acquire a drawing context.
    • Rotate the graphics object
    • Draw the ellipse
    • Fill it with black
  • Implement the Gaussian blur filter. This is not built in to the API, but it includes a framework for doing filters called ConvolveOp, and you can find an algorithm for computing the Gaussian kernel in Java.
  • Apply the filter to the image, and then return the results.

Another option might be Apache’s Batik SVG library, since you can declaratively express the drawing you want (including transformations and filters) and have it rasterized for you.

于 2010-03-15T20:53:04.930 回答
0

可以在此处找到一个非常有用的椭圆公式列表:http: //xahlee.org/SpecialPlaneCurves_dir/Ellipse_dir/ellipse.html

考虑一下每个公式对位图中的单个像素的含义(无论它是否在椭圆内/椭圆外,是否靠近边缘)以及哪些属性对您有用。

于 2010-07-04T07:13:49.650 回答