From 5d81cac8c217647e620c40128cfa466abeeead17 Mon Sep 17 00:00:00 2001 From: Mads Hagen Date: Fri, 20 Sep 2019 14:51:33 +0200 Subject: [PATCH 1/3] tree begins in botom center of window --- src/tree/Tree.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/tree/Tree.java b/src/tree/Tree.java index f2c2496..9306af1 100644 --- a/src/tree/Tree.java +++ b/src/tree/Tree.java @@ -16,7 +16,7 @@ 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, 10); } // TODO get variables from input @@ -24,9 +24,14 @@ 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 (inputN == n){ + cx = + } + */ // Draw Branch treePane.getChildren().add(new Line(x, y, cx, cy)); From a05488f3ebaa5524cbad94f3a5b9805a32688c4d Mon Sep 17 00:00:00 2001 From: Mads Hagen Date: Fri, 20 Sep 2019 14:55:57 +0200 Subject: [PATCH 2/3] fisrt line is correct but hole tree is stil skewed to the side --- src/tree/Tree.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/tree/Tree.java b/src/tree/Tree.java index 9306af1..ecb2f58 100644 --- a/src/tree/Tree.java +++ b/src/tree/Tree.java @@ -27,11 +27,13 @@ private void tree(int n, double x, double y, double a, double branchLength) { double cx = x + (Math.cos(a) * branchLength); double cy = y + (Math.sin(a) * branchLength); double branchWitherRatio = calculateWitherRatio(n); - /* + + //sett cx og cy til verdier som retter opp treet if (inputN == n){ - cx = + cx = x; + cy = y - branchLength; } - */ + // Draw Branch treePane.getChildren().add(new Line(x, y, cx, cy)); From 403d700b1b36dcd198c14522b67201c726a7527f Mon Sep 17 00:00:00 2001 From: Mads Hagen Date: Fri, 20 Sep 2019 15:13:38 +0200 Subject: [PATCH 3/3] tree apears straight now, but the number used is arived at with trail and error. curently deemd close enoth to straight --- src/tree/Tree.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tree/Tree.java b/src/tree/Tree.java index ecb2f58..002c972 100644 --- a/src/tree/Tree.java +++ b/src/tree/Tree.java @@ -8,7 +8,7 @@ public class Tree { @FXML private Pane treePane; - int inputN = 10; + int inputN = 15; double inputWitherRatio = 0.5; @FXML @@ -16,7 +16,7 @@ private void renderTree() { deleteTree(); // TODO get variables from input - tree(inputN, treePane.getWidth() / 2, treePane.getHeight(), -45, 10); + tree(inputN, treePane.getWidth() / 2, treePane.getHeight(), -45, 50); } // TODO get variables from input @@ -28,10 +28,11 @@ private void tree(int n, double x, double y, double a, double branchLength) { double cy = y + (Math.sin(a) * branchLength); double branchWitherRatio = calculateWitherRatio(n); - //sett cx og cy til verdier som retter opp treet + //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 }