mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
Use KDCoordinate
This commit is contained in:
21
app/app.cpp
21
app/app.cpp
@@ -35,15 +35,15 @@ void draw_lines_from_center() {
|
||||
}
|
||||
|
||||
void plot(Expression * e, Variable * v, float xMin, float xMax, float yMin, float yMax) {
|
||||
int screenWidth = 240;
|
||||
int screenHeight = 160;
|
||||
KDCoordinate screenWidth = 240;
|
||||
KDCoordinate screenHeight = 160;
|
||||
KDPoint previousPoint;
|
||||
for (int i=0;i<screenWidth; i++) {
|
||||
for (KDCoordinate i=0;i<screenWidth; i++) {
|
||||
float x = xMin + (xMax-xMin)/screenWidth*i;
|
||||
v->setValue(x);
|
||||
float y = e->approximate();
|
||||
int j = ((y-yMin)/(yMax-yMin)*screenHeight);
|
||||
KDPoint currentPoint = KDPointMake(i,j);
|
||||
KDCoordinate j = ((y-yMin)/(yMax-yMin)*screenHeight);
|
||||
KDPoint currentPoint = KDPointMake(i,screenHeight-j);
|
||||
if (i>0) {
|
||||
KDDrawLine(previousPoint, currentPoint, 0xFF);
|
||||
}
|
||||
@@ -89,9 +89,13 @@ void interactive_expression_parsing() {
|
||||
Expression * e = Expression::parse(input);
|
||||
ExpressionLayout * l = e->createLayout(nullptr);
|
||||
l->draw(KDPointMake(0,100));
|
||||
Variable * v = Variable::VariableNamed("x");
|
||||
if (v) {
|
||||
plot(e,v, 0.0f, 3.0f, 0.0f, 2.0f);
|
||||
}
|
||||
|
||||
// FIXME delete l;
|
||||
//FIXME delete e;
|
||||
delete l;
|
||||
delete e;
|
||||
} else {
|
||||
if (index == 0) {
|
||||
KDRect r;
|
||||
@@ -110,8 +114,9 @@ void interactive_expression_parsing() {
|
||||
|
||||
void ion_app() {
|
||||
KDDrawString("Hello, world!", KDPointMake(10,10));
|
||||
interactive_expression_parsing();
|
||||
//parseInlineExpression();
|
||||
funnyPlot();
|
||||
//funnyPlot();
|
||||
//interactive_expression_parsing();
|
||||
while (1) {
|
||||
ion_sleep();
|
||||
|
||||
@@ -8,7 +8,7 @@ char charForKey[ION_NUMBER_OF_KEYS] = {
|
||||
'7', '8', '9', 'S', 'T',
|
||||
'4', '5', '6', '*', '/',
|
||||
'1', '2', '3', '+', '-',
|
||||
'0', '.', '6', '7', 'X'
|
||||
'0', '.', 'x', '7', 'X'
|
||||
};
|
||||
|
||||
char ion_getchar() {
|
||||
|
||||
Reference in New Issue
Block a user