Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Voronoi.regions doesn't work #5

Open
mroglic opened this issue Mar 10, 2014 · 0 comments
Open

Voronoi.regions doesn't work #5

mroglic opened this issue Mar 10, 2014 · 0 comments

Comments

@mroglic
Copy link

mroglic commented Mar 10, 2014

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant