Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lighting;
- import java.awt.Polygon;
- import java.awt.geom.Area;
- import java.awt.geom.Line2D;
- import java.awt.geom.PathIterator;
- import java.awt.geom.Point2D;
- public class Obscurer {
- private Polygon profile;
- private Area area;
- private Line2D.Double[] lines = new Line2D.Double[0];
- public Obscurer(Polygon prof) {
- this.profile = prof;
- this.area = new Area(this.profile);
- }
- public Polygon getProfile() {
- return profile;
- }
- public void doSegments() {
- /*
- for(int i = 0; i < Main.obscList.size(); i++) {
- Obscurer o = Main.obscList.get(i);
- if(o.equals(this)) continue;
- Area test = (Area) area.clone();
- test.intersect(o.area);
- if((test.getBounds().width+test.getBounds().height) > 0) {
- area.add(o.area);
- Polygon temp = new Polygon();
- PathIterator path = area.getPathIterator(null);
- while (!path.isDone()) {
- toPolygon(path,temp);
- path.next();
- }
- Main.obscList.remove(o);
- i = 0;
- profile = temp;
- }
- }*/
- Point2D.Double[] points = new Point2D.Double[profile.npoints];
- for(int i = 0; i < profile.npoints; i++) {
- points[i] = new Point2D.Double(profile.xpoints[i], profile.ypoints[i]);
- }
- Line2D.Double[] segments = new Line2D.Double[profile.npoints];
- for(int i = 0; i < profile.npoints;i++) {
- segments[i] = new Line2D.Double(points[i].getX(), points[i].getY(), points[(i+1)%profile.npoints].getX(), points[(i+1)%profile.npoints].getY());
- }
- this.lines = segments;
- }
- private static void toPolygon(PathIterator p_path,Polygon p) {
- double[] point = new double[2];
- if(p_path.currentSegment(point) != PathIterator.SEG_CLOSE) {
- p.addPoint((int) point[0], (int) point[1]);
- }
- }
- public Line2D.Double[] lineSegments() {
- return lines.clone();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement