diff --git a/B12NumbersV3/B12NumbersV3.pde b/B12NumbersV3/B12NumbersV3.pde index 4efd152..7c49f59 100644 --- a/B12NumbersV3/B12NumbersV3.pde +++ b/B12NumbersV3/B12NumbersV3.pde @@ -3,7 +3,7 @@ Beta version of a clock in base 12. by Nayan Sawyer started Mar 2022 - version 0.1.4.3 April 30 2022 + version 0.1.5.0 April 30 2022 Characters are a variation of Kaktovik Inupiaq numerals reversed and in base 12 instead of 20. I take no credit @@ -11,6 +11,17 @@ Includes method relay code be Quark - see https://forum.processing.org/two/discussion/13093/how-to-call-function-by-string-content.html for more details. + changelog 0.1.5.0 + - Quite a few changes by this point. The readme has been + fixed, the button class has gone through many revisions + and now allows dynamic calls defined at object creation, + the MathPad now works and inputs B12Digits into a + B12Expression, MathDisplay now works and displays the + contents of a B12Expression, and many miscellaneous bugs + and inefficiencies have been fixed. I still need to get + better at version numbering, but it is slowly getting + better. + changelog 0.1.4.0 - Added MethodRelay code from Quark. Some fixes and changes as well. Condesed some things into fewer files @@ -35,22 +46,15 @@ float sMouseY; public static final int DECIMAL = 65; ClickHandler ch; // Mouse event handler -Clock clock; //<>// -B12Digit p; -B12Digit t; -MathPad m; +Calculator calc; //<>// void setup(){ size(400,400); offset = new PVector(width/2, height/2); ch = new ClickHandler(); - m = new MathPad(ch,new B12Math()); - - clock = new Clock(new STime48()); - println("waiting"); - p = new B12Digit('+'); - t = new B12Digit('/'); + calc = new Calculator(ch); + } void draw(){ @@ -59,12 +63,8 @@ void draw(){ sMouseY = (mouseY - offset.y)/scale; translate(offset.x,offset.y); scale(scale); - point(0,0); - m.display(); - clock.display(); - //p.display(); - t.display(); - //println( + " " + ; + + calc.display(); } void mouseClicked(){ diff --git a/B12NumbersV3/guiB12Expression.pde b/B12NumbersV3/guiB12Expression.pde new file mode 100644 index 0000000..73eaf9e --- /dev/null +++ b/B12NumbersV3/guiB12Expression.pde @@ -0,0 +1,28 @@ +class B12Expression { + private B12Digit[] expression; + + B12Expression(){ + expression = new B12Digit[0]; + } + + B12Digit getDigit(int index){ return expression[index]; } + int length(){return expression.length;} + + void setChar(int ind, B12Digit _digit){ + expression = (B12Digit[])append(expression, _digit); // Add the new digit + if(ind < expression.length - 1){ // Swap new digit + for(int i = expression.length - 1; i > ind; i--){ // Start at second to last digit + expression[i] = expression[i-1]; // Swap object one index below i up into index i + } + expression[ind] = _digit; + } + } + + void addChar(B12Digit _digit){ + expression = (B12Digit[])append(expression, _digit); + } + + void evaluate(){ + //TODO set expression to evaluation of expression + } +} diff --git a/B12NumbersV3/guiB12Math.pde b/B12NumbersV3/guiB12Math.pde deleted file mode 100644 index 7a96bbd..0000000 --- a/B12NumbersV3/guiB12Math.pde +++ /dev/null @@ -1,15 +0,0 @@ -class B12Math { - ArrayList expression; - - B12Math(){ - expression = new ArrayList();; - } - - void delete(int pos){ - expression.remove(pos); - } - - void evaluate(){ - //TODO set expression to evaluation of expression - } -} diff --git a/B12NumbersV3/guiCalculator.pde b/B12NumbersV3/guiCalculator.pde new file mode 100644 index 0000000..00c520e --- /dev/null +++ b/B12NumbersV3/guiCalculator.pde @@ -0,0 +1,16 @@ +class Calculator{ + B12Expression ex; + MathPad m; + MathDisplay d; + + Calculator(ClickHandler _ch){ + ex = new B12Expression(); + m = new MathPad(_ch,ex); + d = new MathDisplay(ex); + } + + void display(){ + m.display(); + d.display(); + } +} diff --git a/B12NumbersV3/guiMathDisplay.pde b/B12NumbersV3/guiMathDisplay.pde index b321f9e..8bade12 100644 --- a/B12NumbersV3/guiMathDisplay.pde +++ b/B12NumbersV3/guiMathDisplay.pde @@ -1,14 +1,24 @@ -class MathDisplay{ - B12Math math; +class MathDisplay { + PVector pos; + B12Expression ex; - MathDisplay(B12Math _math){ - math = _math; + MathDisplay(B12Expression _ex){ + ex = _ex; + pos = new PVector(0,0); } - // TODO take expression from math and display it in whatever state it is in + PVector getPos(){ return pos; } + void setPos(PVector _pos){ pos = _pos; } + void display(){ - for(int i = 0; i < math.expression.size(); i++){ - + pushMatrix(); + translate(pos.x,pos.y); + int count = 0; + for(int i = ex.length() - 1; i >= 0 ; i--){ + ex.getDigit(i).setRefPos((-12 * (count+1)), 0); + ex.getDigit(i).display(); + count++; } + popMatrix(); } } diff --git a/B12NumbersV3/guiMathPad.pde b/B12NumbersV3/guiMathPad.pde index 05154cb..554b24f 100644 --- a/B12NumbersV3/guiMathPad.pde +++ b/B12NumbersV3/guiMathPad.pde @@ -1,11 +1,11 @@ class MathPad{ - B12Math math; + B12Expression ex; ClickHandler ch; B12Button[] buttons; PVector pos; - MathPad(ClickHandler _ch, B12Math _math){ - math = _math; + MathPad(ClickHandler _ch, B12Expression _ex){ + ex = _ex; ch = _ch; pos = new PVector(0,0); buttons = new B12Button[12]; @@ -19,15 +19,12 @@ class MathPad{ buttons[i].setColor(220,150); } } - // DONE draw a grid for buttons - // DONE draw characters in grid - // DONE detect mousepresses on the buttons (maybe a global mouse handler?) - // TODO send characters to math + + // TODO send characters to display - void addChar(B12Digit digit){ - //math.addChar(digit); - //math.expression.add(new B12Char('/')); - println("clicked " + digit.getValue()); + void addChar(B12Digit _digit){ + ex.addChar(_digit); + println("clicked " + _digit.getValue()); } void display(){