as3delaunay icon indicating copy to clipboard operation
as3delaunay copied to clipboard

Voronoi.regions doesn't work

Open mroglic opened this issue 10 years ago • 0 comments

When I call voronoi.regions in following code the error is thrown:

package {
import com.nodename.Delaunay.Voronoi; import com.nodename.geom.LineSegment;

import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Point;
import flash.geom.Rectangle;

public class HelloVoronoi extends Sprite {
    private var _points:Vector.<Point>;
    private var _plotBounds:Rectangle;
    private var _voronoi:Voronoi;
    private var _segments:Vector.<LineSegment>;

    public function HelloVoronoi() {
        if (stage) init();
        else addEventListener(Event.ADDED_TO_STAGE, init);
    }

    private function init(event:Event = null):void {
        _points = new Vector.<Point>();

        for (var i:uint = 0; i < 50; i++) {
            var point:Point = new Point(Math.random() * stage.stageWidth, Math.random() * stage.stageHeight);
            _points.push(point);
        }

        _plotBounds = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
        _voronoi = new Voronoi(_points, null, _plotBounds);

        _segments = _voronoi.voronoiDiagram();

        for each (var segment:LineSegment in _segments) {
            graphics.lineStyle(1, 0x000000, 1);
            graphics.moveTo(segment.p0.x, segment.p0.y);
            graphics.lineTo(segment.p1.x, segment.p1.y);
        } 

        var regions:Vector.<Vector.<Point>> = _voronoi.regions();

    }
}

}

TypeError: Error #1006: value is not a function. at com.nodename.geom::Polygon/winding() at com.nodename.Delaunay::Site/region() at SiteList/regions() at com.nodename.Delaunay::Voronoi/regions() at HelloVoronoi/init() at HelloVoronoi()

mroglic avatar Mar 10 '14 19:03 mroglic