我需要能够接受椭圆(计算)画笔参数,例如间距、硬度、圆度、角度和直径,然后根据这些属性计算位图图像。
有谁知道执行此操作的算法(或我在哪里可以找到它)?我在图形编程方面的经验有限,到目前为止我一直找不到。
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:
BuferredImage
of that size and call its createGraphics
method to acquire a drawing context.
ConvolveOp
, and you can find an algorithm for computing the Gaussian kernel in Java.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.
可以在此处找到一个非常有用的椭圆公式列表:http: //xahlee.org/SpecialPlaneCurves_dir/Ellipse_dir/ellipse.html
考虑一下每个公式对位图中的单个像素的含义(无论它是否在椭圆内/椭圆外,是否靠近边缘)以及哪些属性对您有用。