-
Notifications
You must be signed in to change notification settings - Fork 1
/
FunctionCanvas.java
27 lines (22 loc) · 861 Bytes
/
FunctionCanvas.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import curve.boundable.BoundableCanvas;
import function.Function;
import javafx.scene.paint.Color;
/**
* Expands the curve canvas to directly add functions and their derivatives
*/
public class FunctionCanvas extends BoundableCanvas {
public FunctionCanvas(double width, double height) {
super(width, height);
}
public void addFunction(Function func, double startX, double endX, Color color, int numOfDerivatives) {
addCurve(new FunctionCurve(func, startX, endX, color));
for (int i = 0; i < numOfDerivatives; i++) {
color = color.brighter();
func = func.derive();
addCurve(new FunctionCurve(func, startX, endX, color));
}
}
public void addFunction(Function func, double startX, double endX, Color color) {
addFunction(func, startX, endX, color, 0);
}
}