Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/tree/Tree.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,34 @@ public class Tree {
@FXML
private Pane treePane;

int inputN = 10;
int inputN = 15;
double inputWitherRatio = 0.5;

@FXML
private void renderTree() {
deleteTree();

// TODO get variables from input
tree(inputN, treePane.getWidth() / 2, treePane.getHeight() / 2, -45, 10);
tree(inputN, treePane.getWidth() / 2, treePane.getHeight(), -45, 50);
}

// TODO get variables from input
private void tree(int n, double x, double y, double a, double branchLength) {
// Fields
final double branchShrinkRatio = 1;
final double branchAngle = Math.toRadians(15);
final double cx = x + (Math.cos(a) * branchLength);
final double cy = y + (Math.sin(a) * branchLength);
double cx = x + (Math.cos(a) * branchLength);
double cy = y + (Math.sin(a) * branchLength);
double branchWitherRatio = calculateWitherRatio(n);

//if this is on creation, ashure the propper start location of the tree
if (inputN == n){
cx = x;
cy = y - branchLength;
a = -45.55; //no idea why this number becomes a straight tree, its arived at buy trail and error
}


// Draw Branch
treePane.getChildren().add(new Line(x, y, cx, cy));

Expand Down