mirror of
https://github.com/opus-tango/B12NumbersV3.git
synced 2026-03-20 03:55:20 +00:00
0.1.5.3 - button update, and setter returns
Setters now universally return their object instance. This allows chaining set methods at creation. Much nicer to use now
This commit is contained in:
@@ -12,7 +12,7 @@ class MouseHandler {
|
|||||||
float sMouseY(){return md.sMouseY();}
|
float sMouseY(){return md.sMouseY();}
|
||||||
float pSMouseX(){return md.pSMouseX();}
|
float pSMouseX(){return md.pSMouseX();}
|
||||||
float pSMouseY(){return md.pSMouseY();}
|
float pSMouseY(){return md.pSMouseY();}
|
||||||
void frameUpdate(PVector offset, float scale){md.update(offset, scale); println(mrs.length + " " + millis());}
|
void frameUpdate(PVector offset, float scale){md.update(offset, scale);}// println(mrs.length + " " + millis());}
|
||||||
|
|
||||||
|
|
||||||
void addRelay(LiveMethodRelay r) {
|
void addRelay(LiveMethodRelay r) {
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
abstract interface Number{
|
abstract interface Number{
|
||||||
abstract void setPos(PVector _pos);
|
|
||||||
abstract void setPos(float _x, float _y);
|
|
||||||
abstract PVector getPos();
|
abstract PVector getPos();
|
||||||
|
|
||||||
abstract void setAlignMode(int _mode);
|
|
||||||
abstract void display();
|
abstract void display();
|
||||||
}
|
}
|
||||||
|
|
||||||
class B12Digit{
|
class B12Digit{
|
||||||
byte value;
|
private byte value;
|
||||||
PVector refPos;
|
private PVector refPos;
|
||||||
|
|
||||||
B12Digit(int _value){
|
B12Digit(int _value){
|
||||||
if(_value >= 12 || _value < 0){
|
if(_value >= 12 || _value < 0){
|
||||||
@@ -27,9 +24,9 @@ class B12Digit{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SETTERS
|
// SETTERS
|
||||||
void setRefPos(PVector _refPos){ refPos = _refPos; }
|
B12Digit setRefPos(PVector _refPos){ refPos = _refPos; return this;}
|
||||||
void setRefPos(float _x, float _y){ refPos = new PVector(_x,_y); }
|
B12Digit setRefPos(float _x, float _y){ refPos = new PVector(_x,_y); return this;}
|
||||||
void setValue(int _value){ value = byte(_value); }
|
B12Digit setValue(int _value){ value = byte(_value); return this;}
|
||||||
|
|
||||||
// GETTERS
|
// GETTERS
|
||||||
PVector getRefPos(){ return refPos; }
|
PVector getRefPos(){ return refPos; }
|
||||||
@@ -88,24 +85,24 @@ class B12Digit{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Individual shape components to build any B12 number
|
// Individual shape components to build any B12 number
|
||||||
void line0(){ ellipse(0,-13,8,0); }
|
private void line0(){ ellipse(0,-13,8,0); }
|
||||||
void line1(){ line(6,0,9,-10); }
|
private void line1(){ line(6,0,9,-10); }
|
||||||
void line2(){ line(3,-10,6,0); }
|
private void line2(){ line(3,-10,6,0); }
|
||||||
void line3(){ line(0,0,3,-10); }
|
private void line3(){ line(0,0,3,-10); }
|
||||||
void line4(){ line(9,-10,2,-13); }
|
private void line4(){ line(9,-10,2,-13); }
|
||||||
void line8(){ line(2,-13,9,-16); }
|
private void line8(){ line(2,-13,9,-16); }
|
||||||
|
|
||||||
// Individual shape components to build any B12 character
|
// Individual shape components to build any B12 character
|
||||||
void lineTimes(){ line(4,-7,8,-3); line(4,-3,8,-7); }
|
private void lineTimes(){ line(4,-7,8,-3); line(4,-3,8,-7); }
|
||||||
void dotsDiv(){ point(6,-8); point(6,-2); }
|
private void dotsDiv(){ point(6,-8); point(6,-2); }
|
||||||
void lineMinus(){ line(3,-5,9,-5); }
|
private void lineMinus(){ line(3,-5,9,-5); }
|
||||||
void linePlus(){ line(6,-8,6,-2); }
|
private void linePlus(){ line(6,-8,6,-2); }
|
||||||
void period(){ point(5,0); }
|
private void period(){ point(5,0); }
|
||||||
void colon(){ point(5,-2); point(5,-8); }
|
private void colon(){ point(5,-2); point(5,-8); }
|
||||||
|
|
||||||
|
|
||||||
// HELPER FUNCTIONS //
|
// HELPER FUNCTIONS //
|
||||||
boolean inStr(String st, char _c){
|
private boolean inStr(String st, char _c){
|
||||||
try{
|
try{
|
||||||
int x = st.indexOf(_c);
|
int x = st.indexOf(_c);
|
||||||
return true;
|
return true;
|
||||||
@@ -137,17 +134,17 @@ class B12Int implements Number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int getValue(){ return value; }
|
int getValue(){ return value; }
|
||||||
void setValue(int _value){ value = _value; arrayLoaded = false; }
|
|
||||||
|
|
||||||
void setPos(PVector _pos){ pos = _pos.copy(); inPosition = false; }
|
|
||||||
void setPos(float _x, float _y){ pos = new PVector(_x, _y); inPosition = false; }
|
|
||||||
PVector getPos(){ return pos; }
|
PVector getPos(){ return pos; }
|
||||||
|
|
||||||
void setMinLen(int i){ minLen = i; }
|
|
||||||
|
|
||||||
void setAlignMode(int _mode){
|
B12Int setValue(int _value){ value = _value; arrayLoaded = false; return this;}
|
||||||
|
B12Int setPos(PVector _pos){ pos = _pos.copy(); inPosition = false; return this;}
|
||||||
|
B12Int setPos(float _x, float _y){ pos = new PVector(_x, _y); inPosition = false;return this; }
|
||||||
|
B12Int setMinLen(int i){ minLen = i; return this;}
|
||||||
|
B12Int setAlignMode(int _mode){
|
||||||
if(_mode == DECIMAL || _mode == LEFT || _mode == RIGHT){ mode = _mode; }
|
if(_mode == DECIMAL || _mode == LEFT || _mode == RIGHT){ mode = _mode; }
|
||||||
else{ println("Alignment only accepts LEFT, RIGHT, and DECIMAL"); }
|
else{ println("Alignment only accepts LEFT, RIGHT, and DECIMAL"); }
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void display(){
|
void display(){
|
||||||
@@ -223,24 +220,25 @@ class B12Float implements Number{
|
|||||||
}
|
}
|
||||||
|
|
||||||
float getValue(){ return value; }
|
float getValue(){ return value; }
|
||||||
void setValue(float _value){ value = _value; arrayLoaded = false; }
|
|
||||||
|
|
||||||
PVector getPos(){ return pos; }
|
PVector getPos(){ return pos; }
|
||||||
void setPos(PVector _pos){ pos = _pos.copy(); inPosition = false; }
|
|
||||||
void setPos(float _x, float _y){ pos = new PVector(_x, _y); inPosition = false; }
|
|
||||||
|
|
||||||
int getPlaces(){ return places; }
|
int getPlaces(){ return places; }
|
||||||
void setPlaces(int _places){
|
|
||||||
|
|
||||||
|
B12Float setValue(float _value){ value = _value; arrayLoaded = false; return this;}
|
||||||
|
B12Float setPos(PVector _pos){ pos = _pos.copy(); inPosition = false;return this; }
|
||||||
|
B12Float setPos(float _x, float _y){ pos = new PVector(_x, _y); inPosition = false;return this; }
|
||||||
|
B12Float setPlaces(int _places){
|
||||||
if(_places > 12 || _places < 0){
|
if(_places > 12 || _places < 0){
|
||||||
throw new IllegalArgumentException("B12Float ncan only display to 12 duodecimal points");
|
throw new IllegalArgumentException("B12Float ncan only display to 12 duodecimal points");
|
||||||
}else{
|
}else{
|
||||||
places = _places;
|
places = _places;
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
B12Float setAlignMode(int _mode){
|
||||||
void setAlignMode(int _mode){
|
|
||||||
if(_mode == DECIMAL || _mode == LEFT || _mode == RIGHT){ mode = _mode; }
|
if(_mode == DECIMAL || _mode == LEFT || _mode == RIGHT){ mode = _mode; }
|
||||||
else{ println("Alignment only accepts LEFT, RIGHT, and DECIMAL"); }
|
else{ println("Alignment only accepts LEFT, RIGHT, and DECIMAL"); }
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void display(){
|
void display(){
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ void setup(){
|
|||||||
size(400,400);
|
size(400,400);
|
||||||
offset = new PVector(width/2, height/2);
|
offset = new PVector(width/2, height/2);
|
||||||
mh = new MouseHandler(new MouseData(offset, scale));
|
mh = new MouseHandler(new MouseData(offset, scale));
|
||||||
b = new Button(mh, new PVector(20,-20), new PVector(20,20));
|
b = new Button(mh, new PVector(20,-20), new PVector(40,20),2).setColor(#06BA63).autoHighlight().setText("Reset").setFunction(new MethodRelay(this, "changeMode"));
|
||||||
b.setFunction(new MethodRelay(this, "changeMode"));
|
|
||||||
|
|
||||||
calc = new Calculator(mh);
|
calc = new Calculator(mh);
|
||||||
|
|
||||||
@@ -21,11 +20,17 @@ void setup(){
|
|||||||
void draw(){
|
void draw(){
|
||||||
background(196);
|
background(196);
|
||||||
mh.frameUpdate(offset, scale);
|
mh.frameUpdate(offset, scale);
|
||||||
|
stroke(0);
|
||||||
|
strokeWeight(1);
|
||||||
|
line(width/2,0,width/2,height);
|
||||||
|
line(0,height/2,width,height/2);
|
||||||
translate(offset.x,offset.y);
|
translate(offset.x,offset.y);
|
||||||
scale(scale);
|
scale(scale);
|
||||||
|
|
||||||
if(calc != null) calc.display();
|
if(calc != null) calc.display();
|
||||||
b.display();
|
b.display();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouseClicked(){
|
void mouseClicked(){
|
||||||
|
|||||||
@@ -47,28 +47,32 @@ class Time48 extends Thread{
|
|||||||
Time48 copy(){ return new Time48(this); }
|
Time48 copy(){ return new Time48(this); }
|
||||||
|
|
||||||
// SETTERS //
|
// SETTERS //
|
||||||
void setHour(int h){
|
Time48 setHour(int h){
|
||||||
if(h < 0 || h >= 24) throw new IllegalArgumentException();
|
if(h < 0 || h >= 24) throw new IllegalArgumentException();
|
||||||
hour48 = h;
|
hour48 = h;
|
||||||
flattenOther();
|
flattenOther();
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
void setMin(int m){
|
Time48 setMin(int m){
|
||||||
if(m < 0 || m >= 48) throw new IllegalArgumentException();
|
if(m < 0 || m >= 48) throw new IllegalArgumentException();
|
||||||
min48 = m;
|
min48 = m;
|
||||||
flattenOther();
|
flattenOther();
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
void setSec(int s){
|
Time48 setSec(int s){
|
||||||
if(s < 0 || s >= 48) throw new IllegalArgumentException();
|
if(s < 0 || s >= 48) throw new IllegalArgumentException();
|
||||||
sec48 = s;
|
sec48 = s;
|
||||||
flattenOther();
|
flattenOther();
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
void setTsec(int s){ // TODO add exception
|
Time48 setTsec(int s){ // TODO add exception
|
||||||
tsec48 = s;
|
tsec48 = s;
|
||||||
flattenTSec();
|
flattenTSec();
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// PRIVATE FUNCTIONS //
|
// PRIVATE FUNCTIONS //
|
||||||
@@ -108,10 +112,11 @@ class STime48 extends Time48{
|
|||||||
|
|
||||||
// Public sync functions
|
// Public sync functions
|
||||||
public boolean synced(){return synced;}
|
public boolean synced(){return synced;}
|
||||||
public void syncTime(){ synced = false; } // Allows syncing after time starts running
|
public STime48 syncTime(){ synced = false; return this; } // Allows syncing after time starts running
|
||||||
public void setTime(Time48 _time){
|
public STime48 setTime(Time48 _time){
|
||||||
// To get offset we subtract where the current clock is from where we want it to be
|
// To get offset we subtract where the current clock is from where we want it to be
|
||||||
offset = _time.b10millis() - millis() - tmillis + syncedat;
|
offset = _time.b10millis() - millis() - tmillis + syncedat;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Threaded code
|
// Threaded code
|
||||||
@@ -169,11 +174,11 @@ class Clock {
|
|||||||
|
|
||||||
// GETTERS and SETTERS //
|
// GETTERS and SETTERS //
|
||||||
PVector getPos() { return pos; }
|
PVector getPos() { return pos; }
|
||||||
void setPos(PVector _pos) { pos = _pos.copy(); }
|
Clock setPos(PVector _pos) { pos = _pos.copy(); return this;}
|
||||||
void setPos(float _x, float _y) { pos = new PVector(_x, _y);}
|
Clock setPos(float _x, float _y) { pos = new PVector(_x, _y);return this;}
|
||||||
|
|
||||||
void setTime(Time48 _time) { t48.setTime(_time); }
|
Clock setTime(Time48 _time) { t48.setTime(_time); return this;}
|
||||||
void resetTime() { t48.setTime(new Time48(0)); }
|
Clock resetTime() { t48.setTime(new Time48(0)); return this;}
|
||||||
|
|
||||||
void display() {
|
void display() {
|
||||||
if (t48.synced()) {
|
if (t48.synced()) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class B12Expression {
|
|||||||
B12Digit getDigit(int index){ return expression[index]; }
|
B12Digit getDigit(int index){ return expression[index]; }
|
||||||
int length(){return expression.length;}
|
int length(){return expression.length;}
|
||||||
|
|
||||||
void setChar(int ind, B12Digit _digit){
|
B12Expression setChar(int ind, B12Digit _digit){
|
||||||
expression = (B12Digit[])append(expression, _digit); // Add the new digit
|
expression = (B12Digit[])append(expression, _digit); // Add the new digit
|
||||||
if(ind < expression.length - 1){ // Swap 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
|
for(int i = expression.length - 1; i > ind; i--){ // Start at second to last digit
|
||||||
@@ -16,10 +16,12 @@ class B12Expression {
|
|||||||
}
|
}
|
||||||
expression[ind] = _digit;
|
expression[ind] = _digit;
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addChar(B12Digit _digit){
|
B12Expression addChar(B12Digit _digit){
|
||||||
expression = (B12Digit[])append(expression, _digit);
|
expression = (B12Digit[])append(expression, _digit);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void evaluate(){
|
void evaluate(){
|
||||||
|
|||||||
@@ -1,24 +1,31 @@
|
|||||||
class Button{ // TODO make most of the attributes private
|
class Button{
|
||||||
private LiveMethodRelay listener;
|
private LiveMethodRelay listener;
|
||||||
private MouseHandler mh;
|
private MouseHandler mh;
|
||||||
|
|
||||||
private PVector pos; // Position to render from
|
private PVector pos; // Position to render from
|
||||||
private PVector dim; // Second coordinate for CORNERS or len/wid for CORNER and CENTER
|
private PVector dim; // Second coordinate for CORNERS or len/wid for CORNER and CENTER
|
||||||
private float radius; // Optional corner radius
|
private float radius; // Optional corner radius
|
||||||
private int mode; // Stores rect draw mode for button
|
private int mode; // Stores rect draw mode for button
|
||||||
private color col; // Stores static color
|
private color col; // Stores static color
|
||||||
private color highlight; // Stores mouseover color
|
private color highlight; // Stores mouseover color
|
||||||
|
private String text;
|
||||||
|
|
||||||
private MethodRelay function; // Gets called when button is pressed
|
private MethodRelay function; // Gets called when button is pressed
|
||||||
private boolean mouseOver;
|
private boolean mouseOver;
|
||||||
private Object[] data; // Anything that gets passed to MethodRelay function when key pressed. Must be set manually
|
private Object[] data; // Anything that gets passed to MethodRelay function when key pressed. Must be set manually
|
||||||
|
|
||||||
Button(MouseHandler _mh, PVector _pos, PVector _dim, float _radius){
|
Button(MouseHandler _mh, PVector _pos, PVector _dim, float _radius){
|
||||||
mh = _mh;
|
mh = _mh;
|
||||||
|
|
||||||
pos = _pos.copy();
|
pos = _pos.copy();
|
||||||
dim = _dim.copy();
|
dim = _dim.copy();
|
||||||
radius = _radius;
|
radius = _radius;
|
||||||
mode = CORNER;
|
mode = CORNER;
|
||||||
col = color(200);
|
col = color(200);
|
||||||
highlight = color(100);
|
colorMode(HSB);
|
||||||
|
highlight = color(150);
|
||||||
|
text = "";
|
||||||
|
|
||||||
mouseOver = false;
|
mouseOver = false;
|
||||||
listener = new LiveMethodRelay(this, "clicked", 'p', Object.class);
|
listener = new LiveMethodRelay(this, "clicked", 'p', Object.class);
|
||||||
mh.addRelay(listener);
|
mh.addRelay(listener);
|
||||||
@@ -33,25 +40,22 @@ class Button{ // TODO make most of the attributes private
|
|||||||
float getRadius(){return radius;}
|
float getRadius(){return radius;}
|
||||||
color getColor(){return col;}
|
color getColor(){return col;}
|
||||||
color getHighlight(){return highlight;}
|
color getHighlight(){return highlight;}
|
||||||
|
String getText(){return text;}
|
||||||
MethodRelay getFunction(){return function;}
|
MethodRelay getFunction(){return function;}
|
||||||
int getMode(){return mode; }
|
int getMode(){return mode; }
|
||||||
|
|
||||||
// SETTERS //
|
// SETTERS //
|
||||||
void setRect(PVector _pos, PVector _dim){pos = _pos; dim = _dim; }
|
Button setRect(PVector _pos, PVector _dim){pos = _pos; dim = _dim; return this;}
|
||||||
void setRadius(float rad){radius = rad;}
|
Button setRadius(float rad){radius = rad; return this;}
|
||||||
void setColor(color c){col = c; }
|
Button setColor(color c){col = c; return this;}
|
||||||
void setColor(color c, color h){col = c; highlight = h;}
|
Button setColor(color c, color h){col = c; highlight = h; return this;}
|
||||||
void setHighlight(color h){ highlight = h; }
|
Button autoHighlight(){ colorMode(RGB,255); highlight = color(int(red(col) * .85), int(green(col) * .85), int(blue(col) * .85)); return this; }
|
||||||
void setFunction(MethodRelay _function){function = _function;}
|
Button setHighlight(color h){ highlight = h; return this; }
|
||||||
void setData(Object... _data){ data = _data; } // Data to pass for button presses. Ugh, note that the array already exists because it's passed as such, no need to create a new one. Stupid bug
|
Button setText(String t){text = t; return this;}
|
||||||
|
|
||||||
void setMode(int m){
|
Button setFunction(MethodRelay _function){function = _function;return this;}
|
||||||
if(m == CORNER || m == CORNERS || m == CENTER || m == RADIUS){
|
Button setData(Object... _data){ data = _data; return this;} // Data to pass for button presses. Ugh, note that the array already exists because it's passed as such, no need to create a new one. Stupid bug
|
||||||
mode = m;
|
Button setMode(int m){ if(m == CORNER || m == CORNERS || m == CENTER || m == RADIUS){mode = m;return this;} /*Otherwise*/ return this;}
|
||||||
return;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DISPLAY //
|
// DISPLAY //
|
||||||
void display(){
|
void display(){
|
||||||
@@ -60,14 +64,19 @@ class Button{ // TODO make most of the attributes private
|
|||||||
new MethodRelay(this, "mouseOver" + str(mode), float.class, float.class).execute(mh.sMouseX(),mh.sMouseY());
|
new MethodRelay(this, "mouseOver" + str(mode), float.class, float.class).execute(mh.sMouseX(),mh.sMouseY());
|
||||||
fill(mouseOver ? highlight : col);
|
fill(mouseOver ? highlight : col);
|
||||||
rect(pos.x,pos.y,dim.x,dim.y,radius);
|
rect(pos.x,pos.y,dim.x,dim.y,radius);
|
||||||
|
fill(0);
|
||||||
|
textSize(dim.y * 0.8);
|
||||||
|
textAlign(CENTER,BOTTOM);
|
||||||
|
text(text,pos.x + dim.x/2,pos.y + dim.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MOUSE FUNCTIONS //
|
// MOUSE FUNCTIONS //
|
||||||
void clicked(Object _mp){ // mp[0] is smouseX and m[1] is smouseY
|
void clicked(Object _mp){ // mp[0] is smouseX and m[1] is smouseY
|
||||||
float[] mp = (float[])_mp;
|
float[] mp = (float[])_mp;
|
||||||
if(mouseOver){
|
if(mouseOver && mouseButton == LEFT){
|
||||||
println(mp[0] + " " + mp[1] + " mouse pos");
|
//println(mp[0] + " " + mp[1] + " mouse pos");
|
||||||
|
//println(col + " : " + highlight);
|
||||||
function.execute(data);
|
function.execute(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,60 +84,38 @@ class Button{ // TODO make most of the attributes private
|
|||||||
// DETECT IF MOUSE IS OVER BUTTON //
|
// DETECT IF MOUSE IS OVER BUTTON //
|
||||||
// The numbers in the method name correspond to the mode ids because the method gets called with a relay
|
// The numbers in the method name correspond to the mode ids because the method gets called with a relay
|
||||||
void mouseOver0(float x, float y){ // CORNER
|
void mouseOver0(float x, float y){ // CORNER
|
||||||
//println("CORNER");
|
mouseOver = !(x < pos.x || x > pos.x + dim.x || y < pos.y || y > dim.y + pos.y) ;
|
||||||
if(x < pos.x || x > pos.x + dim.x || y < pos.y || y > dim.y + pos.y)
|
|
||||||
{
|
|
||||||
mouseOver = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mouseOver = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouseOver1(float x, float y){ // CORNERS
|
void mouseOver1(float x, float y){ // CORNERS
|
||||||
//println("CORNERS");
|
//println("CORNERS");
|
||||||
if(x < (pos.x > dim.x ? dim.x : pos.x) ||
|
mouseOver = !(x < (pos.x > dim.x ? dim.x : pos.x) ||
|
||||||
x > (pos.x > dim.x ? pos.x : dim.x) ||
|
x > (pos.x > dim.x ? pos.x : dim.x) ||
|
||||||
y < (pos.y > dim.y ? dim.y : pos.y) ||
|
y < (pos.y > dim.y ? dim.y : pos.y) ||
|
||||||
y > (pos.y > dim.y ? pos.y : dim.y))
|
y > (pos.y > dim.y ? pos.y : dim.y));
|
||||||
{
|
|
||||||
mouseOver = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mouseOver = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouseOver2(float x, float y){ // RADIUS
|
void mouseOver2(float x, float y){ // RADIUS
|
||||||
//println("RADIUS");
|
//println("RADIUS");
|
||||||
if(x < pos.x - dim.x ||
|
mouseOver = !(x < pos.x - dim.x ||
|
||||||
x > pos.x + dim.x ||
|
x > pos.x + dim.x ||
|
||||||
y < pos.x - dim.y ||
|
y < pos.x - dim.y ||
|
||||||
y > pos.x + dim.y)
|
y > pos.x + dim.y);
|
||||||
{
|
|
||||||
mouseOver = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mouseOver = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouseOver3(float x, float y){ // CENTER
|
void mouseOver3(float x, float y){ // CENTER
|
||||||
//println("CENTER");
|
//println("CENTER");
|
||||||
if(x < pos.x - dim.x/2 ||
|
mouseOver = !(x < pos.x - dim.x/2 ||
|
||||||
x > pos.x + dim.x/2 ||
|
x > pos.x + dim.x/2 ||
|
||||||
y < pos.x - dim.y/2 ||
|
y < pos.x - dim.y/2 ||
|
||||||
y > pos.y + dim.y/2)
|
y > pos.y + dim.y/2);
|
||||||
{
|
|
||||||
mouseOver = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mouseOver = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GARBAGE COLLECTION //
|
// GARBAGE COLLECTION //
|
||||||
// kill the mouse listener so it will get removed from the mouse event cascade
|
// kill the mouse listener so it will get removed from the mouse event cascade
|
||||||
@Override
|
@Override
|
||||||
protected void finalize(){
|
protected void finalize(){
|
||||||
println("finalized");
|
//println("finalized");
|
||||||
listener.kill();
|
listener.kill();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class MathDisplay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PVector getPos(){ return pos; }
|
PVector getPos(){ return pos; }
|
||||||
void setPos(PVector _pos){ pos = _pos; }
|
MathDisplay setPos(PVector _pos){ pos = _pos; return this;}
|
||||||
|
|
||||||
void display(){
|
void display(){
|
||||||
pushMatrix();
|
pushMatrix();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class MathPad{
|
class MathPad{
|
||||||
B12Expression ex;
|
B12Expression ex;
|
||||||
MouseHandler mh;
|
MouseHandler mh;
|
||||||
B12Button[] buttons;
|
Button[] buttons;
|
||||||
PVector pos;
|
PVector pos;
|
||||||
|
|
||||||
MathPad(MouseHandler _mh, B12Expression _ex){
|
MathPad(MouseHandler _mh, B12Expression _ex){
|
||||||
@@ -14,9 +14,7 @@ class MathPad{
|
|||||||
|
|
||||||
void initialize(){
|
void initialize(){
|
||||||
for(int i = 0; i < 12; i++){
|
for(int i = 0; i < 12; i++){
|
||||||
buttons[i] = new B12Button(mh, new PVector(25 * int(i%4),25 * floor(i/4)), new PVector(20,20),new B12Digit(i));
|
buttons[i] = new B12Button(mh, new PVector(22 * int(i%4),22 * 2 - 22 * floor(i/4)), new PVector(20,20),new B12Digit(i)).setFunction(new MethodRelay(this, "addChar", B12Digit.class)).setColor(220,150);
|
||||||
buttons[i].setFunction(new MethodRelay(this, "addChar", B12Digit.class));
|
|
||||||
buttons[i].setColor(220,150);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +52,7 @@ class B12Button extends Button{
|
|||||||
|
|
||||||
// GETTERS AND SETTERS //
|
// GETTERS AND SETTERS //
|
||||||
B12Digit getDigit(){ return digit; }
|
B12Digit getDigit(){ return digit; }
|
||||||
void setDigit(B12Digit _digit){ digit = _digit; }
|
B12Button setDigit(B12Digit _digit){ digit = _digit; return this; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void display(){
|
void display(){
|
||||||
|
|||||||
@@ -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.5.2 April 30 2022
|
version 0.1.5.3 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
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
for more details.
|
for more details.
|
||||||
|
|
||||||
// TODO redo position data handling
|
// TODO redo position data handling
|
||||||
// WORKING redo mouse handling
|
|
||||||
// TODO add cursor and dynamic position for MathDisplay (Maybe add a "highlighted" attribute to B12Digit?) might need some restructuring
|
// TODO add cursor and dynamic position for MathDisplay (Maybe add a "highlighted" attribute to B12Digit?) might need some restructuring
|
||||||
// TODO add parsing expression to operable math string (tricky to get base 12 to base 10)
|
// TODO add parsing expression to operable math string (tricky to get base 12 to base 10)
|
||||||
// TODO add operator and action buttons to MathPad
|
// TODO add operator and action buttons to MathPad
|
||||||
@@ -20,6 +19,12 @@
|
|||||||
// MAYBE start clock widget structure
|
// MAYBE start clock widget structure
|
||||||
// MAYBE add additional operations like power, log, and trig functions
|
// MAYBE add additional operations like power, log, and trig functions
|
||||||
|
|
||||||
|
changelog 0.1.5.3
|
||||||
|
- restricted button presses to left mouse button only.
|
||||||
|
Updated button highlight color functionality. Updated all
|
||||||
|
classes to return themselves from their setters. This
|
||||||
|
allows chaining set methods on one line.
|
||||||
|
|
||||||
changelog 0.1.5.2
|
changelog 0.1.5.2
|
||||||
- major changes to mouse handling, and MethodRelay now
|
- major changes to mouse handling, and MethodRelay now
|
||||||
uses weak references rather than strong references so
|
uses weak references rather than strong references so
|
||||||
|
|||||||
Reference in New Issue
Block a user