Use expression for brush radius

This commit is contained in:
Jesse Boyd
2018-08-22 02:58:10 +10:00
8 changed files with 126 additions and 45 deletions

View File

@ -80,6 +80,11 @@ public class Expression {
return new Expression(expression, variableNames);
}
public Expression(double constant) {
variableNames = null;
root = new Constant(0, constant);
}
private Expression(String expression, String... variableNames) throws ExpressionException {
this(Lexer.tokenize(expression), variableNames);
}
@ -106,6 +111,9 @@ public class Expression {
}
public double evaluate(double... values) throws EvaluationException {
if (root instanceof Constant) {
return root.getValue();
}
for (int i = 0; i < values.length; i++) {
Variable var = variableArray[i];
var.value = values[i];
@ -124,6 +132,10 @@ public class Expression {
root = root.optimize();
}
public RValue getRoot() {
return root;
}
@Override
public String toString() {
return root.toString();