내가 http://yuml.me UML 다이어그램의 지저분한 종이 효과처럼, 바람직 루비하지만, PHP에서 해당하는 알고리즘이 그것은 REBOL에서 같은 일을 쉽게하는 경우, 자바 또는 C#을, 내가보고 싶은 :UML 다이어그램에 "지저분한"종이 효과를 생성하는 알고리즘은 무엇입니까?
http://reboltutorial.com/blog/easy-yuml-dialect-for-mere-mortals2/
내가 http://yuml.me UML 다이어그램의 지저분한 종이 효과처럼, 바람직 루비하지만, PHP에서 해당하는 알고리즘이 그것은 REBOL에서 같은 일을 쉽게하는 경우, 자바 또는 C#을, 내가보고 싶은 :UML 다이어그램에 "지저분한"종이 효과를 생성하는 알고리즘은 무엇입니까?
http://reboltutorial.com/blog/easy-yuml-dialect-for-mere-mortals2/
효과 가지고
매번 동일한 이미지를 얻을 수 있도록 입력 해시로 난수 생성기를 시드 할 수 있습니다. 좋은 사이트/링크
public class ScruffyLines {
static final double WOBBLE_SIZE = 0.5;
static final double WOBBLE_INTERVAL = 16.0;
Random random;
ScruffyLines (long seed) {
random = new Random(seed);
}
public Point2D.Double[] scruffUpPolygon (Point2D.Double[] polygon) {
ArrayList<Point2D.Double> points = new ArrayList<Point2D.Double>();
Point2D.Double prev = polygon[0];
points.add (prev); // no wobble on first point
for (int index = 1; index < polygon.length; ++index) {
final Point2D.Double point = polygon[index];
final double dist = prev.distance (point);
// interpolate between prev and current point if they are more
// than a certain distance apart, adding in extra points to make
// longer lines wobbly
if (dist > WOBBLE_INTERVAL) {
int stepCount = (int) Math.floor (dist/WOBBLE_INTERVAL);
double step = dist/stepCount;
double x = prev.x;
double y = prev.y;
double dx = (point.x - prev.x)/stepCount;
double dy = (point.y - prev.y)/stepCount;
for (int count = 1; count < stepCount; ++count) {
x += dx;
y += dy;
points.add (perturb (x, y));
}
}
points.add (perturb (point.x, point.y));
prev = point;
}
return points.toArray (new Point2D.Double[ points.size() ]);
}
Point2D.Double perturb (double x, double y) {
return new Point2D.Double (
x + random.nextGaussian() * WOBBLE_SIZE,
y + random.nextGaussian() * WOBBLE_SIZE);
}
}
example scruffed up rectangle http://img34.imageshack.us/img34/4743/screenshotgh.png
고맙습니다. –
+1 편리합니다 :) – leppie
방문하여 프로젝트를 찾습니다 :
이 라인을 scruffing에 대한 확인을 작동하는 것 같다 와우 내가 놀라 울뿐입니다. Rebol을 IDE에 포함 시키시겠습니까;) –