mirror of
https://github.com/opus-tango/B12NumbersV3.git
synced 2026-03-20 12:05:21 +00:00
Compare commits
4 Commits
v0.1.5.8-b
...
v0.2.0.0-b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
400eb0e78b | ||
|
|
7f83b4db59 | ||
|
|
d8297af420 | ||
|
|
a2034715c2 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
windows-amd64
|
||||
@@ -110,7 +110,7 @@ import java.lang.ref.*;
|
||||
public static class MethodRelay {
|
||||
|
||||
/** The object to handle the draw event */
|
||||
private WeakReference reference = null;
|
||||
private WeakReference reference = null; // Replaced the original strong reference with a weak reference so that relays will get garbage collected if the object they call get collected
|
||||
//private Object handlerObject = null;
|
||||
/** The method in drawHandlerObject to execute */
|
||||
private Method handlerMethod = null;
|
||||
|
||||
@@ -210,7 +210,8 @@ class B12Int implements Number {
|
||||
|
||||
|
||||
class B12Float implements Number{
|
||||
private ArrayList<B12Digit> digits;
|
||||
//private ArrayList<B12Digit> digits;
|
||||
private B12Digit[] digits;
|
||||
private float value;
|
||||
private PVector pos;
|
||||
private boolean arrayLoaded;
|
||||
@@ -232,7 +233,20 @@ class B12Float implements Number{
|
||||
PVector getPos(){ return pos; }
|
||||
int getPlaces(){ return places; }
|
||||
B12Int toInt(){return new B12Int(int(value));}
|
||||
|
||||
B12Digit[] getDigits(){ //<>//
|
||||
loadArray();
|
||||
B12Digit[] out = (B12Digit[])reverse(digits);
|
||||
for(int i = out.length-1; i > 0; i--){
|
||||
if(out[i].getValue() == '.'){
|
||||
out = (B12Digit[])shorten(out);
|
||||
break;
|
||||
}
|
||||
if(out[i].getValue() == 0){
|
||||
out = (B12Digit[])shorten(out);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
B12Float setValue(float _value){ value = _value; arrayLoaded = false; return this;}
|
||||
B12Float setPos(PVector _pos){ pos = _pos.copy(); inPosition = false;return this; }
|
||||
@@ -256,8 +270,8 @@ class B12Float implements Number{
|
||||
if(!inPosition){ positionDigits(); }
|
||||
pushMatrix();
|
||||
translate(pos.x,pos.y);
|
||||
for(int i = 0; i < digits.size(); i++){
|
||||
digits.get(i).display();
|
||||
for(int i = 0; i < digits.length; i++){
|
||||
digits[i].display();
|
||||
}
|
||||
popMatrix();
|
||||
}
|
||||
@@ -268,38 +282,38 @@ class B12Float implements Number{
|
||||
if(mode == LEFT){
|
||||
for(int i = 0; i < pointPlace; i++){
|
||||
curPos += -12;
|
||||
digits.get(i).setRefPos(curPos, 0);
|
||||
digits[i].setRefPos(curPos, 0);
|
||||
count++;
|
||||
}
|
||||
|
||||
curPos += -8;
|
||||
digits.get(count).setRefPos(curPos, 0);
|
||||
digits[count].setRefPos(curPos, 0);
|
||||
count++;
|
||||
curPos += -6;
|
||||
digits.get(count).setRefPos(curPos, 0);
|
||||
digits[count].setRefPos(curPos, 0);
|
||||
count++;
|
||||
|
||||
for(int i = count; i < digits.size(); i++){
|
||||
for(int i = count; i < digits.length; i++){
|
||||
curPos += -12;
|
||||
digits.get(i).setRefPos(curPos, 0);
|
||||
digits[i].setRefPos(curPos, 0);
|
||||
}
|
||||
}else if(mode == DECIMAL){
|
||||
curPos = -5;
|
||||
digits.get(pointPlace).setRefPos(curPos,0);
|
||||
digits[pointPlace].setRefPos(curPos,0);
|
||||
curPos += -2;
|
||||
for(int i = pointPlace - 1; i >= 0; i--){
|
||||
curPos += 12;
|
||||
digits.get(i).setRefPos(curPos,0);
|
||||
digits[i].setRefPos(curPos,0);
|
||||
}
|
||||
curPos = -2;
|
||||
|
||||
for(int i = pointPlace + 1; i < digits.size(); i++){
|
||||
for(int i = pointPlace + 1; i < digits.length; i++){
|
||||
curPos += -12;
|
||||
digits.get(i).setRefPos(curPos,0);
|
||||
digits[i].setRefPos(curPos,0);
|
||||
}
|
||||
}else if(mode == RIGHT){
|
||||
for(int i = digits.size() - 1; i >= 0; i--){
|
||||
digits.get(count).setRefPos((12 * i) + 3, 0);
|
||||
for(int i = digits.length - 1; i >= 0; i--){
|
||||
digits[count].setRefPos((12 * i) + 3, 0);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -307,7 +321,8 @@ class B12Float implements Number{
|
||||
}
|
||||
|
||||
private void loadArray(){
|
||||
digits = new ArrayList<B12Digit>();
|
||||
//digits = new ArrayList<B12Digit>();
|
||||
digits = new B12Digit[0];
|
||||
B12Digit[] temp = new B12Digit[places];
|
||||
float mval = abs(value);
|
||||
int whole = int(mval);
|
||||
@@ -320,24 +335,24 @@ class B12Float implements Number{
|
||||
}
|
||||
|
||||
for(int i = places - 1; i >= 0; i--){
|
||||
digits.add(temp[i]);
|
||||
digits = (B12Digit[])append(digits,temp[i]);
|
||||
}
|
||||
|
||||
pointPlace = digits.size();
|
||||
digits.add(new B12Digit('.'));
|
||||
pointPlace = digits.length;
|
||||
digits = (B12Digit[])append(digits,new B12Digit('.'));
|
||||
|
||||
while(whole > 0){
|
||||
if(whole < 12){
|
||||
digits.add(new B12Digit(whole));
|
||||
digits = (B12Digit[])append(digits,new B12Digit(whole));
|
||||
whole = 0;
|
||||
}else{
|
||||
digits.add(new B12Digit(whole % 12));
|
||||
digits = (B12Digit[])append(digits,new B12Digit(whole % 12));
|
||||
whole /= 12;
|
||||
}
|
||||
}
|
||||
|
||||
if(value < 0){
|
||||
digits.add(new B12Digit('-'));
|
||||
digits = (B12Digit[])append(digits,new B12Digit('-'));
|
||||
}
|
||||
|
||||
arrayLoaded = true;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import net.objecthunter.exp4j.*;
|
||||
|
||||
// B12NumbersV3 //
|
||||
float scale = 2;
|
||||
String dbout = new String("");
|
||||
float scale = 4;
|
||||
PVector offset;
|
||||
public static final int DECIMAL = 65;
|
||||
MouseHandler mh; // Mouse event handler
|
||||
@@ -14,7 +17,7 @@ STime48 time;
|
||||
|
||||
|
||||
void setup(){
|
||||
size(400,400);
|
||||
size(800,800);
|
||||
offset = new PVector(width/2, height/2);
|
||||
time = new STime48();
|
||||
mh = new MouseHandler(new MouseData(offset, scale));
|
||||
@@ -22,11 +25,14 @@ void setup(){
|
||||
|
||||
calc = new Calculator(mh, ex);
|
||||
|
||||
mode = new Button(mh).setPos(new PVector(-20,-width/4), new PVector(40,20)).setRadius(2).setColor(#8B687F).autoHighlight().setText("Mode").setFunction(new MethodRelay(this, "changeMode"));
|
||||
mode = new Button(mh).setPos(new PVector(-20,-100), new PVector(40,20)).setRadius(2).setColor(#8B687F).autoHighlight().setText("Mode").setFunction(new MethodRelay(this, "changeMode"));
|
||||
}
|
||||
|
||||
void draw(){
|
||||
background(196);
|
||||
textAlign(LEFT,TOP);
|
||||
textSize(30);
|
||||
text(dbout,0,0);
|
||||
mh.frameUpdate(offset, scale);
|
||||
stroke(0);
|
||||
strokeWeight(1);
|
||||
@@ -38,6 +44,7 @@ void draw(){
|
||||
if(clock != null) clock.display();
|
||||
if(changeTime != null) changeTime.display();
|
||||
mode.display();
|
||||
|
||||
}
|
||||
|
||||
void mouseClicked(){
|
||||
@@ -63,7 +70,7 @@ void changeMode(){
|
||||
}
|
||||
calc = null;
|
||||
clock = new Clock(time).setPos(new PVector(30,0));
|
||||
changeTime = new Button(mh).setPos(new PVector(-40,-width/4 + 30), new PVector(80,20)).setRadius(2).setColor(#B096A7).autoHighlight().setText("Change Time").setFunction(new MethodRelay(clock, "setTime", Time48.class));
|
||||
changeTime = new Button(mh).setPos(new PVector(-40,-60), new PVector(80,20)).setRadius(2).setColor(#B096A7).autoHighlight().setText("Change Time").setFunction(new MethodRelay(clock, "setTime", Time48.class));
|
||||
changeTime.setData(new Time48(12,0,0));
|
||||
Runtime.getRuntime().gc();
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ class B12Expression {
|
||||
|
||||
// GETTERS //
|
||||
B12Digit getDigit(int index){ return expression[index]; }
|
||||
int length(){return expression.length;}
|
||||
int length(){if(expression == null){return 0;} return expression.length;}
|
||||
|
||||
// SETTERS //
|
||||
B12Expression insertChar(int ind, B12Digit _digit){
|
||||
@@ -35,9 +35,11 @@ class B12Expression {
|
||||
}
|
||||
|
||||
void evaluate(){
|
||||
String evalString = parseDigits();
|
||||
println(evalString);
|
||||
//<>// //<>//
|
||||
String evalString = parseDigits(); //<>//
|
||||
Expression exp = new ExpressionBuilder(evalString).build();
|
||||
expression = new B12Float((float)exp.evaluate()).setPlaces(12).getDigits();
|
||||
println(exp.evaluate());
|
||||
dbout = str((float)exp.evaluate());
|
||||
}
|
||||
|
||||
private String parseDigits(){
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
class MathPad{
|
||||
private B12Expression ex;
|
||||
private MouseHandler mh;
|
||||
@@ -41,7 +42,7 @@ class MathPad{
|
||||
buttons = (Button[])append(buttons, new B12Button(mh, new B12Digit('*')).setPos(new PVector(pos.x + 22*4,pos.y)).setFunction(new MethodRelay(this, "addChar", B12Digit.class)).setColor(220,150));
|
||||
buttons = (Button[])append(buttons, new B12Button(mh, new B12Digit('/')).setPos(new PVector(pos.x + 22*4,pos.y + 22)).setFunction(new MethodRelay(this, "addChar", B12Digit.class)).setColor(220,150));
|
||||
buttons = (Button[])append(buttons, new B12Button(mh, new B12Digit('.')).setPos(new PVector(pos.x + 22*4,pos.y + 22*2)).setFunction(new MethodRelay(this, "addChar", B12Digit.class)).setColor(220,150));
|
||||
buttons = (Button[])append(buttons, new Button(mh).setText("Enter").setPos(new PVector(pos.x + 22*4,pos.y + 22*3)).setDim(new PVector(42,20)).setFunction(new MethodRelay(this.ex, "evaluate")).setColor(220,150)); //<>//
|
||||
buttons = (Button[])append(buttons, new Button(mh).setText("Enter").setPos(new PVector(pos.x + 22*4,pos.y + 22*3)).setDim(new PVector(42,20)).setFunction(new MethodRelay(this.ex, "evaluate")).setColor(220,150));
|
||||
buttons = (Button[])append(buttons, new Button(mh).setText("Cl").setPos(new PVector(pos.x + 22*5,pos.y + 22)).setDim(new PVector(20,42)).setFunction(new MethodRelay(this.ex, "clear")).setColor(220,150));
|
||||
buttons = (Button[])append(buttons, new Button(mh).setText("Del").setPos(new PVector(pos.x + 22*5,pos.y)).setDim(new PVector(20,20)).setFunction(new MethodRelay(this.ex, "delete")).setColor(220,150));
|
||||
}
|
||||
|
||||
@@ -3,19 +3,28 @@
|
||||
Beta version of a clock in base 12.
|
||||
by Nayan Sawyer
|
||||
started Mar 2022
|
||||
version 0.1.5.7 April 30 2022
|
||||
version 0.2.0.0 April 30 2022
|
||||
|
||||
Characters are a variation of Kaktovik Inupiaq numerals
|
||||
reversed and in base 12 instead of 20. I take no credit
|
||||
for the design.
|
||||
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 by Quark - see https://forum.processing.org/two/discussion/13093/how-to-call-function-by-string-content.html
|
||||
for more details.
|
||||
|
||||
// TODO add actual math evaluation to B12Expression // Once thiss is done we hit version 0.2.0.0 //
|
||||
// TODO switch B12Int from ArrayList to Array
|
||||
// DONE add actual math evaluation to B12Expression // Once thiss is done we hit version 0.2.0.0 //
|
||||
// TODO add throwing exceptions to all contructors
|
||||
// MAYBE start clock widget structure
|
||||
// MAYBE add additional operations like power, log, and trig functions
|
||||
|
||||
changelog 0.2.0.0
|
||||
- Evaluating expressions has been fully implemented using
|
||||
exp4j. Various things have been added to the base classes
|
||||
to support this.
|
||||
|
||||
changelog 0.1.5.8
|
||||
- Tweaks for first beta release for class presentation
|
||||
|
||||
changelog 0.1.5.7
|
||||
- Presentation display setup done.
|
||||
|
||||
|
||||
@@ -12,3 +12,5 @@ The time system is now complete with robust syncing and offset features. The bas
|
||||
Seconds: there are now 48 seconds in a minute
|
||||
|
||||
The number system is such that horizontal ticks on top represent multiples of four, and vertical ticks represent multiples of one. Decimal 11 is 2 horizontal ticks, and 3 vertical ticks. However, since the project is in an alpha state, I will not go into great detail at this point.
|
||||
|
||||
The calculator input system is now working. For an early beta demo see [releases](https://github.com/GShadow5/B12NumbersBeta1/releases)
|
||||
|
||||
Reference in New Issue
Block a user