mirror of
https://github.com/opus-tango/B12NumbersV3.git
synced 2026-03-20 03:55:20 +00:00
0.1.5.0 - Basic input implemented
version update to 0.1.5 as the structure of the code has changed significantly again. Got MathPad and MathDisplay working, and created the Calculator container class to hold them all. Calculator will eventually be the "widget" if you will for calculator functionality. Version numbers are now going to update every commit.
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
Beta version of a clock in base 12.
|
Beta version of a clock in base 12.
|
||||||
by Nayan Sawyer
|
by Nayan Sawyer
|
||||||
started Mar 2022
|
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
|
Characters are a variation of Kaktovik Inupiaq numerals
|
||||||
reversed and in base 12 instead of 20. I take no credit
|
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
|
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.
|
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
|
changelog 0.1.4.0
|
||||||
- Added MethodRelay code from Quark. Some fixes and
|
- Added MethodRelay code from Quark. Some fixes and
|
||||||
changes as well. Condesed some things into fewer files
|
changes as well. Condesed some things into fewer files
|
||||||
@@ -35,22 +46,15 @@ float sMouseY;
|
|||||||
public static final int DECIMAL = 65;
|
public static final int DECIMAL = 65;
|
||||||
ClickHandler ch; // Mouse event handler
|
ClickHandler ch; // Mouse event handler
|
||||||
|
|
||||||
Clock clock; //<>//
|
Calculator calc; //<>//
|
||||||
B12Digit p;
|
|
||||||
B12Digit t;
|
|
||||||
MathPad m;
|
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
size(400,400);
|
size(400,400);
|
||||||
offset = new PVector(width/2, height/2);
|
offset = new PVector(width/2, height/2);
|
||||||
ch = new ClickHandler();
|
ch = new ClickHandler();
|
||||||
|
|
||||||
m = new MathPad(ch,new B12Math());
|
calc = new Calculator(ch);
|
||||||
|
|
||||||
clock = new Clock(new STime48());
|
|
||||||
println("waiting");
|
|
||||||
p = new B12Digit('+');
|
|
||||||
t = new B12Digit('/');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw(){
|
void draw(){
|
||||||
@@ -59,12 +63,8 @@ void draw(){
|
|||||||
sMouseY = (mouseY - offset.y)/scale;
|
sMouseY = (mouseY - offset.y)/scale;
|
||||||
translate(offset.x,offset.y);
|
translate(offset.x,offset.y);
|
||||||
scale(scale);
|
scale(scale);
|
||||||
point(0,0);
|
|
||||||
m.display();
|
calc.display();
|
||||||
clock.display();
|
|
||||||
//p.display();
|
|
||||||
t.display();
|
|
||||||
//println( + " " + ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouseClicked(){
|
void mouseClicked(){
|
||||||
|
|||||||
28
B12NumbersV3/guiB12Expression.pde
Normal file
28
B12NumbersV3/guiB12Expression.pde
Normal file
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
class B12Math {
|
|
||||||
ArrayList <B12Digit> expression;
|
|
||||||
|
|
||||||
B12Math(){
|
|
||||||
expression = new ArrayList<B12Digit>();;
|
|
||||||
}
|
|
||||||
|
|
||||||
void delete(int pos){
|
|
||||||
expression.remove(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
void evaluate(){
|
|
||||||
//TODO set expression to evaluation of expression
|
|
||||||
}
|
|
||||||
}
|
|
||||||
16
B12NumbersV3/guiCalculator.pde
Normal file
16
B12NumbersV3/guiCalculator.pde
Normal file
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,24 @@
|
|||||||
class MathDisplay {
|
class MathDisplay {
|
||||||
B12Math math;
|
PVector pos;
|
||||||
|
B12Expression ex;
|
||||||
|
|
||||||
MathDisplay(B12Math _math){
|
MathDisplay(B12Expression _ex){
|
||||||
math = _math;
|
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(){
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
class MathPad{
|
class MathPad{
|
||||||
B12Math math;
|
B12Expression ex;
|
||||||
ClickHandler ch;
|
ClickHandler ch;
|
||||||
B12Button[] buttons;
|
B12Button[] buttons;
|
||||||
PVector pos;
|
PVector pos;
|
||||||
|
|
||||||
MathPad(ClickHandler _ch, B12Math _math){
|
MathPad(ClickHandler _ch, B12Expression _ex){
|
||||||
math = _math;
|
ex = _ex;
|
||||||
ch = _ch;
|
ch = _ch;
|
||||||
pos = new PVector(0,0);
|
pos = new PVector(0,0);
|
||||||
buttons = new B12Button[12];
|
buttons = new B12Button[12];
|
||||||
@@ -19,15 +19,12 @@ class MathPad{
|
|||||||
buttons[i].setColor(220,150);
|
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
|
|
||||||
|
|
||||||
void addChar(B12Digit digit){
|
// TODO send characters to display
|
||||||
//math.addChar(digit);
|
|
||||||
//math.expression.add(new B12Char('/'));
|
void addChar(B12Digit _digit){
|
||||||
println("clicked " + digit.getValue());
|
ex.addChar(_digit);
|
||||||
|
println("clicked " + _digit.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
void display(){
|
void display(){
|
||||||
|
|||||||
Reference in New Issue
Block a user