Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.qscript.*; //<>// //<>//
- import org.qscript.eventsonfire.*;
- import org.qscript.events.*;
- import org.qscript.editor.*;
- import org.qscript.operator.*;
- import org.qscript.errors.*;
- String input = "";
- int main_calc_state = 1;
- float num1;
- float num2;
- float temp_num;
- float ans;
- float trig_ans = 0;
- boolean showAns = false;
- float angle1 = 0;
- float angle2 = 0;
- String side_a;
- String side_b;
- int calc_state = 0;
- int trig_calc_state = 0;
- int trig_calc_state_denoter = 0;
- String trig_ans_error = "Side is less than zero.";
- boolean flag = false;
- boolean calc_flag = false;
- boolean adv_trig_calc_flag = false;
- int x = width/10;
- int y = height/10;
- String a = "";
- String b = "";
- int c = 0;
- String trig_c = "";
- String[] pres1 = match(input, "\\*");
- String[] pres2 = match(input, "/");
- String[] pres3 = match(input, "-");
- String[] pres4 = match(input, "\\+");
- String[] pres5 = match(input, "^");
- //______________________________________// Above is setup for calculator.
- String input1 = "";
- boolean check=false;
- int deltax=0;
- int deltay=0;
- int delx=0;
- int dely=0;
- int inX;
- int inY;
- int whiteout=0;
- boolean check2=true;
- float[] x_coord = new float[10000];
- float[] y_coord = new float[10000];
- float[] tempy = new float[10000];
- String LOG;
- String COS;
- String SIN;
- String TAN;
- Boolean test = false;
- void setup() {
- size(768, 1024);
- background(255);
- frameRate(60);
- fill(0);
- boolean checker=true;
- if (checker==true) {
- check = true;
- checker=false;
- }
- for (int i=0; i<=2999; i++) {
- x_coord[i]=0;
- }
- for (int i=0; i<=2999; i++) {
- y_coord[i]=0;
- }
- }
- void draw() {
- if (main_calc_state == 1) {
- main_operation_draw();
- number_draw();
- fill(150);
- rect(0, 900, 768, 74);
- fill(0);
- if (showAns) {
- text(ans, 50, 945);
- } else {
- text(input, 300, 945);
- text(num1, 50, 945);
- }
- }
- if (main_calc_state == 2) {
- println(a, b, trig_c, flag, calc_flag, adv_trig_calc_flag);
- }
- if (main_calc_state == 3) {
- graph_operation_draw();
- }
- fill(0);
- rect(0, 974, 768/4, 50);
- rect(192, 974, 768/4, 50);
- rect(192*2, 974, 768/4, 50);
- rect(192*3, 974, 768/4, 50);
- fill(255);
- textSize(20);
- text("Standard Calculator", 10, 1000);
- text("Trig Calculator", 307, 1000);
- text("Graphing Calculator", 560, 1000);
- if (mouseX >= 0 && mouseX < 270 && mouseY >= 974) {
- main_calc_state = 1;
- }
- if (mouseX >= 270 && mouseX < 520 && mouseY >= 974) {
- main_calc_state = 2;
- }
- if (mouseX >= 520 && mouseX <= 768 && mouseY >= 974) {
- main_calc_state = 3;
- }
- }
- void mousePressed() {
- if (main_calc_state == 1) {
- standard_calc_draw();
- }
- if (main_calc_state == 2) {
- trig_operation_draw();
- }
- }
- void main_operation_draw() {
- int x = width/10;
- int y = height/10;
- background(255);
- fill(0);
- textSize(25);
- text("n^2", 3*x + 30, y + 40);
- text("sqrt", 4*x + 30, y +40);
- textSize(40);
- text("C", 8*x + 30, y*0 + 40);
- text("Ans", 8*x + 30, y*2 + 40);
- text("=", 8*x + 30, y*3 + 40);
- text("+", 3*x + 30, y*0 + 40);
- text("-", 4*x + 30, y*0 + 40);
- text("*", 5*x + 30, y*0 + 40);
- text("/", 6*x + 30, y*0 + 40);
- }
- void number_draw() {
- int x = width/10;
- int y = height/10;
- text("1", 0*x + 30, y*0 + 40);
- text("2", 0*x + 30, y + 40);
- text("3", 0*x + 30, y*2 + 40);
- text("4", 0*x + 30, y*3 + 40);
- text("5", 0*x + 30, y*4 + 40);
- text("6", x + 30, y*0 + 40);
- text("7", x + 30, y + 40);
- text("8", x + 30, y*2 + 40);
- text("9", x + 30, y*3 + 40);
- text("0", x + 30, y*4 + 40);
- }
- void trig_operation_draw() {
- background(255);
- textSize(30);
- fill(0);
- text("What type of trig question do you need help with?", 20, 60);
- text("Pythagoras", 30, 200);
- text("Sine Rule", 30, 300);
- text("Cosine Rule", 30, 400);
- if (mouseX > 20 && mouseX <= 280 && mouseY > 850 && mouseY <= 950) {
- trig_calc_state = 0;
- }
- if (trig_calc_state == 0) {
- if (mouseX > 20 && mouseX < 220) {
- if (mouseY > 150 && mouseY <= 250) {
- trig_calc_state = 1;
- trig_calc_state_denoter = 0;
- }
- if (mouseY > 250 && mouseY <= 350) {
- trig_calc_state = 2;
- trig_calc_state_denoter = 1;
- }
- if (mouseY > 350 && mouseY <= 450) {
- trig_calc_state = 3;
- trig_calc_state_denoter = 2;
- }
- }
- a = "";
- b = "";
- c = 0;
- trig_c = "";
- flag = false;
- calc_flag = false;
- }
- if (trig_calc_state == 1) {
- background(255);
- fill(0);
- text("Which side are you attempting to find?", 110, 60);
- text("Hypotnuse", 170, 200);
- text("Shorter Side", 420, 200);
- text("BACK TO MENU", 30, 900);
- if (mouseY > 150 && mouseY <= 250) {
- if (mouseX > 120 && mouseX <= 270) {
- trig_calc_state = 4;
- }
- if (mouseX > 370 && mouseX <= 520) {
- trig_calc_state = 5;
- }
- }
- if (mouseX > 10 && mouseX <= 150) {
- if (mouseY > 850 && mouseY <= 950) {
- trig_calc_state = 0;
- }
- }
- }
- if (trig_calc_state == 2 || trig_calc_state == 3) {
- background(255);
- fill(0);
- text("Do you want to solve for a side or angle?", 100, 60);
- text("Side", 220, 200);
- text("Angle", 450, 200);
- text("BACK TO MENU", 30, 900);
- if (mouseY > 150 && mouseY <= 250) {
- if (mouseX > 150 && mouseX <= 300) {
- trig_calc_state = 6;
- }
- if (mouseX > 400 && mouseX <= 550) {
- trig_calc_state = 7;
- }
- if (mouseX > 10 && mouseX <= 150) {
- if (mouseY > 850 && mouseY <= 950) {
- trig_calc_state = 0;
- }
- }
- }
- }
- if (trig_calc_state == 4) {
- background(255);
- fill(0);
- text("Press Enter after you type your number.", 90, 600);
- number_draw();
- text("Enter your known sides:", 200, 60);
- text("Side A:", 200, 150);
- text("Side B:", 200, 200);
- number_operation();
- c = parseInt(a) * parseInt(a) + parseInt(b) * parseInt(b);
- trig_ans = sqrt(c);
- if (a != "" && b != "") {
- text("Missing Side is:", 200, 280);
- text(trig_ans, 420, 280);
- }
- text(a, 350, 150);
- text(b, 350, 200);
- text("BACK TO MENU", 30, 900);
- }
- if (trig_calc_state == 5) {
- background(255);
- fill(0);
- text("Press Enter after you type your number.", 90, 600);
- number_draw();
- text("Enter your known sides:", 200, 60);
- text("Hypotnuse:", 200, 150);
- text("Side B:", 200, 200);
- number_operation();
- c = parseInt(a) * parseInt(a) - parseInt(b) * parseInt(b);
- trig_ans = sqrt(c);
- if (a != "" && b != "") {
- text("Missing Side is:", 200, 280);
- if (c <= 0) {
- text(trig_ans_error, 430, 280);
- } else {
- text(trig_ans, 430, 280);
- }
- }
- text(a, 400, 150);
- text(b, 350, 200);
- text("BACK TO MENU", 30, 900);
- }
- if (trig_calc_state == 6 && trig_calc_state_denoter == 1) {
- background(255);
- fill(0);
- text("Press Enter after you type your number.", 90, 600);
- number_draw();
- text("Enter your two known angles and side:", 120, 60);
- text("Opp. Angle:", 200, 150);
- text("Side 2:", 200, 200);
- text("Angle 2:", 200, 250);
- number_operation();
- side_a = Integer.parseInt(a);
- trig_ans = parseInt(a) * parseInt(b)/parseInt(trig_c);
- text(a, 400, 150);
- text(b, 350, 200);
- text(trig_c, 350, 250);
- text("BACK TO MENU", 30, 900);
- }
- }
- void standard_calc_draw() {
- String[] pres1 = match(input, "\\*");
- String[] pres2 = match(input, "/");
- String[] pres3 = match(input, "-");
- String[] pres4 = match(input, "\\+");
- String[] pres5 = match(input, "^");
- if (mouseX >= 0 && mouseX < 78) {
- if (mouseY >= 0 && mouseY < 70) {
- input = input + 1;
- } else if (mouseY >= 70 && mouseY < 102 + 70) {
- input = input + 2;
- } else if (mouseY >= 70 + 102 && mouseY < 102*2 + 70) {
- input = input + 3;
- } else if (mouseY >= 70 + 102*2 && mouseY < 102*3 + 70) {
- input = input + 4;
- } else if (mouseY >= 70 + 102*3 && mouseY < 102*4 + 70) {
- input = input + 5;
- }
- showAns = false;
- } else if (mouseX >= 78 && mouseX < 78*2) {
- if (mouseY >= 0 && mouseY < 70) {
- input = input + 6;
- } else if (mouseY >= 70 && mouseY < 102 + 70) {
- input = input + 7;
- } else if (mouseY >= 70 + 102 && mouseY < 102*2 + 70) {
- input = input + 8;
- } else if (mouseY >= 70 + 102*2 && mouseY < 102*3 + 70) {
- input = input + 9;
- } else if (mouseY >= 70 + 102*3 && mouseY < 102*4 + 70) {
- input = input + 0;
- }
- showAns = false;
- } else if (mouseX >= 78*3 && mouseX < 78*4) {
- if (mouseY >= 0 && mouseY < 70) {
- if (num1 == 0) {
- num1 = parseInt(input);
- } else if (calc_state == 5) {
- } else if (input != "") {
- temp_num = parseInt(input.substring(1));
- } else {
- if (pres1 == null && pres2 == null && pres3 == null && pres4 == null && pres5 == null) {
- num1 = temp_num + num1;
- } else {
- operation_input_result();
- }
- }
- input = "+";
- calc_state = 1;
- showAns = false;
- } else if (mouseY >= 70 && mouseY < 70 + 102) {
- if (num1 == 0) {
- if (ans == 0) {
- num1 = parseInt(input) * parseInt(input);
- } else {
- num1 = ans * ans;
- }
- } else {
- if (input != "") {
- temp_num = parseInt(input.substring(1));
- }
- if (pres1 == null && pres2 == null && pres3 == null && pres4 == null && pres5 == null) {
- num1 = num1 * num1;
- } else {
- operation_input_result();
- }
- }
- if (num1 < 0) {
- num1 = abs(num1);
- }
- input = "";
- ans = 0;
- text(num1, 50, 995);
- }
- } else if (mouseX >= 78*4 && mouseX < 78*5) {
- if (mouseY >= 0 && mouseY < 70) {
- if (num1 == 0) {
- num1 = parseInt(input);
- } else {
- temp_num = parseInt(input.substring(1));
- if (pres1 == null && pres2 == null && pres3 == null && pres4 == null && pres5 == null) {
- num1 = temp_num * num1;
- } else if (calc_state == 5) {
- } else {
- operation_input_result();
- }
- }
- input = "-";
- calc_state = 2;
- showAns = false;
- } else if (mouseY >= 70 && mouseY < 70 + 102) {
- if (num1 == 0) {
- if (ans == 0) {
- num1 = sqrt(parseInt(input));
- } else {
- num1 = sqrt(ans);
- }
- } else {
- if (input != "") {
- temp_num = parseInt(input.substring(1));
- }
- if (pres1 == null && pres2 == null && pres3 == null && pres4 == null && pres5 == null && num1 >=0) {
- num1 = sqrt(num1);
- } else {
- if (num1 < 0) {
- num1 = abs(num1);
- num1 = sqrt(num1);
- } else {
- operation_input_result();
- }
- }
- }
- input = "";
- showAns = false;
- ans = 0;
- text(num1, 50, 995);
- }
- } else if (mouseX >= 78*5 && mouseX < 78*6) {
- if (mouseY >= 0 && mouseY < 70) {
- if (num1 == 0) {
- num1 = parseInt(input);
- } else {
- temp_num = parseInt(input.substring(1));
- if (pres1 == null && pres2 == null && pres3 == null && pres4 == null && pres5 == null) {
- num1 = temp_num * num1;
- } else if (calc_state == 5) {
- } else {
- operation_input_result();
- }
- }
- input = "*";
- calc_state = 3;
- showAns = false;
- }
- } else if (mouseX >= 78*6 && mouseX < 78*7) {
- if (mouseY >= 0 && mouseY < 70) {
- if (num1 == 0) {
- num1 = parseInt(input);
- } else {
- temp_num = parseInt(input.substring(1));
- if (pres1 == null && pres2 == null && pres3 == null && pres4 == null && pres5 == null) {
- num1 = num1 / temp_num;
- } else if (calc_state == 5) {
- } else {
- operation_input_result();
- }
- }
- input = "/";
- calc_state = 4;
- showAns = false;
- }
- } else if (mouseX >= 77*8 && mouseX < 77*9) {
- if (mouseY >= 70 + 102*2 && mouseY < 70 + 102*3) {
- if (num1 == 0) {
- ans = parseInt(input);
- showAns = true;
- } else if (input != "") {
- num2 = parseInt(input.substring(1));
- input = input + "=";
- if (calc_state == 1) {
- ans = num1 + num2;
- }
- if (calc_state == 2) {
- ans = num1 - num2;
- }
- if (calc_state == 3) {
- ans = num1 * num2;
- }
- if (calc_state == 4) {
- ans = num1 / num2;
- }
- showAns = true;
- input = "";
- num1 = 0;
- num2 = 0;
- calc_state = 0;
- } else {
- ans = num1;
- }
- }
- if (mouseY >= 0 && mouseY < 70) {
- input = "";
- num1 = 0;
- num2 = 0;
- temp_num = 0;
- ans = 0;
- }
- if (mouseY >= 70 + 102 && mouseY < 70 + 102*2) {
- num1 = ans;
- showAns = false;
- ans = 0;
- calc_state = 5;
- }
- }
- }
- void number_operation_adv_trig() {
- if (mouseX >= 0 && mouseX < 78) {
- if (mouseY >= 0 && mouseY < 70) {
- trig_c = trig_c + 1;
- } else if (mouseY >= 70 && mouseY < 102 + 70) {
- trig_c = trig_c + 2;
- } else if (mouseY >= 70 + 102 && mouseY < 102*2 + 70) {
- trig_c = trig_c + 3;
- } else if (mouseY >= 70 + 102*2 && mouseY < 102*3 + 70) {
- trig_c = trig_c + 4;
- } else if (mouseY >= 70 + 102*3 && mouseY < 102*4 + 70) {
- trig_c = trig_c + 5;
- }
- } else if (mouseX >= 78 && mouseX < 78*2) {
- if (mouseY >= 0 && mouseY < 70) {
- trig_c = trig_c + 6;
- } else if (mouseY >= 70 && mouseY < 102 + 70) {
- trig_c = trig_c + 7;
- } else if (mouseY >= 70 + 102 && mouseY < 102*2 + 70) {
- trig_c = trig_c + 8;
- } else if (mouseY >= 70 + 102*2 && mouseY < 102*3 + 70) {
- trig_c = trig_c + 9;
- } else if (mouseY >= 70 + 102*3 && mouseY < 102*4 + 70) {
- trig_c = trig_c + 0;
- }
- }
- }
- void number_operation() {
- if (calc_state == 6) {
- a = side_a;
- }
- if (flag == false) {
- text("Enter numbers:", 470, 150);
- if (mouseX >= 0 && mouseX < 78) {
- if (mouseY >= 0 && mouseY < 70) {
- a = a + 1;
- } else if (mouseY >= 70 && mouseY < 102 + 70) {
- a = a + 2;
- } else if (mouseY >= 70 + 102 && mouseY < 102*2 + 70) {
- a = a + 3;
- } else if (mouseY >= 70 + 102*2 && mouseY < 102*3 + 70) {
- a = a + 4;
- } else if (mouseY >= 70 + 102*3 && mouseY < 102*4 + 70) {
- a = a + 5;
- }
- } else if (mouseX >= 78 && mouseX < 78*2) {
- if (mouseY >= 0 && mouseY < 70) {
- a = a + 6;
- } else if (mouseY >= 70 && mouseY < 102 + 70) {
- a = a + 7;
- } else if (mouseY >= 70 + 102 && mouseY < 102*2 + 70) {
- a = a + 8;
- } else if (mouseY >= 70 + 102*2 && mouseY < 102*3 + 70) {
- a = a + 9;
- } else if (mouseY >= 70 + 102*3 && mouseY < 102*4 + 70) {
- a = a + 0;
- }
- }
- }
- if (flag == true && calc_flag == false) {
- if (mouseX >= 0 && mouseX < 78) {
- if (mouseY >= 0 && mouseY < 70) {
- b = b + 1;
- } else if (mouseY >= 70 && mouseY < 102 + 70) {
- b = b + 2;
- } else if (mouseY >= 70 + 102 && mouseY < 102*2 + 70) {
- b = b + 3;
- } else if (mouseY >= 70 + 102*2 && mouseY < 102*3 + 70) {
- b = b + 4;
- } else if (mouseY >= 70 + 102*3 && mouseY < 102*4 + 70) {
- b = b + 5;
- }
- } else if (mouseX >= 78 && mouseX < 78*2) {
- if (mouseY >= 0 && mouseY < 70) {
- b = b + 6;
- } else if (mouseY >= 70 && mouseY < 102 + 70) {
- b = b + 7;
- } else if (mouseY >= 70 + 102 && mouseY < 102*2 + 70) {
- b = b + 8;
- } else if (mouseY >= 70 + 102*2 && mouseY < 102*3 + 70) {
- b = b + 9;
- } else if (mouseY >= 70 + 102*3 && mouseY < 102*4 + 70) {
- b = b + 0;
- }
- }
- }
- if (calc_flag == true) {
- number_operation_adv_trig();
- }
- keyPressed();
- }
- void keyPressed() {
- if (keyCode == ENTER) {
- if (b == "") {
- flag = true;
- }
- else if (trig_c == "") {
- calc_flag = true;
- }
- else if (trig_c != "" && b != "") {
- adv_trig_calc_flag = true;
- }
- }
- }
- void operation_input_result() {
- String[] pres1 = match(input, "\\*");
- String[] pres2 = match(input, "/");
- String[] pres3 = match(input, "-");
- String[] pres4 = match(input, "\\+");
- String[] pres5 = match(input, "^");
- if (pres1 != null) {
- num1 = temp_num * num1;
- } else if (pres2 != null) {
- num1 = num1 / temp_num;
- } else if (pres3 != null) {
- num1 = num1 - temp_num;
- } else if (pres4 != null) {
- num1 = num1 + temp_num;
- } else if (pres5 != null) {
- num1 = num1 * num1;
- }
- }
- void graph_operation_draw() {
- background(255);
- float[] xline = new float[9];
- float[] yline = new float[9];
- for (int i=0; i<=8; i++) {
- yline[i] = (40-i*10);
- fill(0);
- textSize(10);
- fill(whiteout);
- text(yline[i], (width/2 + 20)+delx, 102.4+102.4*i+dely);
- }
- for (int i=0; i<=8; i++) {
- xline[i] = ((-20+i*10));
- fill(0);
- textSize(10);
- text(xline[i], 179.2+102.4*i+delx, (height/2)+dely-5);
- }
- for (int i =0; i<=9; i++) {
- if (keyPressed && check2==true) {
- if (key == '1' || key == '2' || key == '3' || key == '4' || key == '5' || key == '6' ||
- key == '7' || key == '8' || key == '9' || key == '0' || key == '^' || key == 'x' ||
- key == '*' || key == '/' || key == '+' || key == '-' || key == '(' || key == ')' || key == '.') {
- input1 = input1+key;
- check2 = false;
- }
- if (key == BACKSPACE && check2==true && input1.length()>0) {
- input1 = input1.substring(0, input1.length()-1);
- check2 = false;
- }
- }
- }
- textSize(20);
- LOG = "Ln("+input1+")";
- COS = "cos("+input1+")";
- SIN = "sin("+input1+")";
- TAN = "tan("+input1+")";
- text(LOG, 50, 100);
- text(SIN, 50, 150);
- text(COS, 50, 200);
- text(TAN, 50, 250);
- if (mouseX>10 && mouseX<90 && mouseY>80 && mouseY<=100 && mousePressed==true) {
- for (int i=0; i<=9999; i++) {
- x_coord[i]=(i-3000)*0.01;
- }
- for (int i=0; i<=9999; i++) {
- tempy[i] = (function(input1, x_coord[i]));
- }
- for (int i=0; i<=9999; i++) {
- y_coord[i] = (logfunction(tempy[i]));
- }
- for (int i=0; i<=9999; i++) {
- Point[] p = new Point[10000];
- p[i] = new Point((x_coord[i]/0.1024+384+delx), dely+512-y_coord[i]/0.1024);
- p[i].display();
- if (mousePressed ==true && mouseX == (x_coord[i]/0.1024+384+delx)) {
- p[i].textualise();
- }
- }
- }
- if (mouseX>10 && mouseX<90 && mouseY>130 && mouseY<=150 && mousePressed==true) {
- for (int i=0; i<=9999; i++) {
- x_coord[i]=(i-3000)*0.01;
- }
- for (int i=0; i<=9999; i++) {
- tempy[i] = (function(input1, x_coord[i]));
- }
- for (int i=0; i<=9999; i++) {
- y_coord[i] = (sinfunction(tempy[i]));
- }
- for (int i=0; i<=9999; i++) {
- Point[] p = new Point[10000];
- p[i] = new Point((x_coord[i]/0.1024+384+delx), dely+512-y_coord[i]/0.1024);
- p[i].display();
- if (mousePressed ==true && mouseX == (x_coord[i]/0.1024+384+delx)) {
- p[i].textualise();
- }
- }
- }
- if (mouseX>10 && mouseX<90 && mouseY>180 && mouseY<=200 && mousePressed==true) {
- for (int i=0; i<=9999; i++) {
- x_coord[i]=(i-3000)*0.01;
- }
- for (int i=0; i<=9999; i++) {
- tempy[i] = (function(input1, x_coord[i]));
- }
- for (int i=0; i<=9999; i++) {
- y_coord[i] = (cosfunction(tempy[i]));
- }
- for (int i=0; i<=9999; i++) {
- Point[] p = new Point[10000];
- p[i] = new Point((x_coord[i]/0.1024+384+delx), dely+512-y_coord[i]/0.1024);
- p[i].display();
- if (mousePressed ==true && mouseX == (x_coord[i]/0.1024+384+delx)) {
- p[i].textualise();
- }
- }
- }
- text("Reset Graph to Origin", 550, 50);
- if (mouseX>520 && mouseX<768 && mouseY>0 && mouseY<=80 && mousePressed==true) {
- delx = 0;
- dely = 0;
- }
- if (mouseX>10 && mouseX<90 && mouseY>230 && mouseY<=250 && mousePressed==true) {
- for (int i=0; i<=9999; i++) {
- x_coord[i]=(i-3000)*0.01;
- }
- for (int i=0; i<=9999; i++) {
- tempy[i] = (function(input1, x_coord[i]));
- }
- for (int i=0; i<=9999; i++) {
- y_coord[i] = (tanfunction(tempy[i]));
- }
- for (int i=0; i<=9999; i++) {
- Point[] p = new Point[10000];
- p[i] = new Point((x_coord[i]/0.1024+384+delx), dely+512-y_coord[i]/0.1024);
- p[i].display();
- if (mousePressed ==true && mouseX == (x_coord[i]/0.1024+384+delx)) {
- p[i].textualise();
- }
- }
- }
- if (key == ENTER && check2==true) {
- for (int i=0; i<=9999; i++) {
- x_coord[i]=(i-3000)*0.01;
- }
- for (int i=0; i<=9999; i++) {
- y_coord[i] = (function(input1, x_coord[i]));
- }
- check2=false;
- }
- for (int i=0; i<=9999; i++) {
- Point[] p = new Point[10000];
- p[i] = new Point((x_coord[i]/0.1024+384+delx), dely+512-y_coord[i]/0.1024);
- p[i].display();
- if (mousePressed ==true && mouseX == (x_coord[i]/0.1024+384+delx)) {
- p[i].textualise();
- }
- }
- fill(0);
- textSize(20);
- text(input1, 50, 50);
- if (mousePressed && check == true) {
- inX = mouseX;
- inY = mouseY;
- check=false;
- }
- if (delx<=-234) {
- whiteout = 255;
- }
- if (delx>-234) {
- whiteout =0;
- }
- strokeWeight(5);
- stroke(whiteout);
- line((width/2)+delx, 0, (width/2)+delx, height);
- stroke(0);
- line(150, (height/2)+dely, width, (height/2)+dely);
- strokeWeight(2);
- line(150, 0, 150, height);
- }
- void mouseReleased() {
- deltax = mouseXdelta(inX);
- deltay = mouseYdelta(inY);
- check =true;
- delx=delx+deltax;
- dely=dely+deltay;
- deltax=0;
- deltay=0;
- }
- void keyReleased() {
- check2=true;
- }
- int mouseXdelta(int x) {
- int diff=0;
- diff = x - mouseX;
- return diff;
- }
- int mouseYdelta(int y) {
- int diff=0;
- diff = y - mouseY;
- return diff;
- }
- float function(String function, float Xcord) {
- String func = function;
- String func1 = "";
- float Fy=0;
- if (func == "x" || func == "X") {
- func1 = func.replace("x", str(Xcord));
- Fy = float(func1);
- } else if (func == "" || func == "0" || func == "1" || func == "2" || func == "3" || func == "5" || func == "6"
- || func == "7" || func == "8" || func == "9") {
- Fy=0;
- } else {
- func1 = func.replace("x", str(Xcord));
- Result func2 = (Solver.evaluate(func1));
- Fy = func2.answer.toFloat();
- }
- return Fy;
- }
- float logfunction(float Ycord) {
- float Fy = -1000;
- float y = Ycord;
- if (y>0) {
- Fy = log(y);
- }
- return Fy;
- }
- float sinfunction(float Ycord) {
- float Fy = -1000;
- float y = Ycord;
- Fy = sin(y);
- return Fy;
- }
- float cosfunction(float Ycord) {
- float Fy = -1000;
- float y = Ycord;
- Fy = cos(y);
- return Fy;
- }
- float tanfunction(float Ycord) {
- float Fy = -1000;
- float y = Ycord;
- if (Ycord != 3.14/2) {
- Fy = tan(y);
- }
- return Fy;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement