"use strict";

import paper from 'paper';
import 'seedrandom';

class 
 {
    constructor(options) {
        this.options = Object.assign({
            branch: {
                style: {
                    strokeColor: 'black',
                    strokeCap: 'round'
                },
                angle: 0,
                length: 50,
                width: 5
            },
            leaf: {
                style: {
                    fillColor: 'rgba(0,0,0,0.1)'
                },
                radius: 5
            }
        }, options);
    }

    create(position, seed) {
        var point = new paper.Point(0,0);
        var definition = new paper.SymbolDefinition(new paper.Path(Object.assign({
            segments: [
                point,
                point.add(new paper.Point(0,-50))
            ],
            pivot: new paper.Point(0, 0),
            strokeWidth: this.options.branch.width
        }, this.options.branch.style)));

        var groupA = new paper.Group();
        var pathA = new paper.SymbolItem(definition);

        groupA.addChild(pathA);
        groupA.pivot = new paper.Point(0, 0);
        groupA.rotate(10);
        groupA.scale(0.5);
        groupA.position = position;

        var p = new paper.Point().add(new paper.Point(0,-50).rotate(10).multiply(0.5));


        var groupB = new paper.Group();
        var pathB = new paper.SymbolItem(definition);

        groupB.addChild(pathB);
        groupB.pivot = new paper.Point(0, 0);
        groupB.rotate(20);
        groupB.scale(0.5);
        groupB.position = position.add(p);

        groupA.addChild(groupB);
        console.log(groupA);
        p = p.add(new paper.Point(0,-50).rotate(20).multiply(0.5));

        var groupC = new paper.Group();
        var pathC = new paper.SymbolItem(definition);

        groupC.addChild(pathC);
        groupC.pivot = new paper.Point(0, 0);
        groupC.rotate(30);
        groupC.position = position.add(p);
        groupC.scale(0.5);
        groupB.addChild(groupC);

    }
}

export default Tree;

Tree