mirror of
https://github.com/opus-tango/B12NumbersV3.git
synced 2026-03-20 03:55:20 +00:00
Deprecated B12Class
B12Class is now officially deprecated. It's functionality has been rolled into the B12Digit class. All references to B12Char have been switched to B12Digit, but the code has not yet been refactored to use B12Digit with total efficiency
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
class B12Char extends B12Digit{
|
/*class B12Char extends B12Digit{
|
||||||
String valid;
|
String valid;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
B12Char(char _c){
|
B12Char(char _c){
|
||||||
super(0);
|
super(0);
|
||||||
valid = "+-*/.:"; // Defines valid input characters
|
valid = "+-*\/.:"; // Defines valid input characters
|
||||||
if(inStr(_c)){
|
if(inStr(_c)){
|
||||||
c = _c;
|
c = _c;
|
||||||
}else{
|
}else{
|
||||||
@@ -52,4 +52,4 @@ class B12Char extends B12Digit{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|||||||
@@ -11,6 +11,15 @@ class B12Digit{
|
|||||||
refPos = new PVector(0,0);
|
refPos = new PVector(0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
B12Digit(char _c){
|
||||||
|
String valid = "+-*/.:"; // Defines valid input characters
|
||||||
|
if(inStr(valid, _c)){
|
||||||
|
value = byte(_c);
|
||||||
|
}else{
|
||||||
|
throw new IllegalArgumentException("B12Char only accepts \'+ - * / . :'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// SETTERS
|
// SETTERS
|
||||||
void setRefPos(PVector _refPos){ refPos = _refPos; }
|
void setRefPos(PVector _refPos){ refPos = _refPos; }
|
||||||
void setRefPos(float _x, float _y){ refPos = new PVector(_x,_y); }
|
void setRefPos(float _x, float _y){ refPos = new PVector(_x,_y); }
|
||||||
@@ -28,6 +37,7 @@ class B12Digit{
|
|||||||
noFill();
|
noFill();
|
||||||
ellipseMode(CORNERS);
|
ellipseMode(CORNERS);
|
||||||
switch(value) {
|
switch(value) {
|
||||||
|
// NUMBERS //
|
||||||
case 0:
|
case 0:
|
||||||
line0(); break;
|
line0(); break;
|
||||||
case 1:
|
case 1:
|
||||||
@@ -52,6 +62,20 @@ class B12Digit{
|
|||||||
line8(); line4(); line1(); line2(); break;
|
line8(); line4(); line1(); line2(); break;
|
||||||
case 11:
|
case 11:
|
||||||
line8(); line4(); line1(); line2(); line3(); break;
|
line8(); line4(); line1(); line2(); line3(); break;
|
||||||
|
|
||||||
|
// CHARACTERS //
|
||||||
|
case '+':
|
||||||
|
lineMinus(); linePlus(); break;
|
||||||
|
case '-':
|
||||||
|
lineMinus(); break;
|
||||||
|
case '*':
|
||||||
|
lineTimes(); break;
|
||||||
|
case '/':
|
||||||
|
lineMinus(); dotsDiv(); break;
|
||||||
|
case '.':
|
||||||
|
strokeWeight(2); period(); break;
|
||||||
|
case ':':
|
||||||
|
strokeWeight(2); colon(); break;
|
||||||
}
|
}
|
||||||
popMatrix();
|
popMatrix();
|
||||||
}
|
}
|
||||||
@@ -63,4 +87,24 @@ class B12Digit{
|
|||||||
void line3(){ line(0,0,3,-10); }
|
void line3(){ line(0,0,3,-10); }
|
||||||
void line4(){ line(9,-10,2,-13); }
|
void line4(){ line(9,-10,2,-13); }
|
||||||
void line8(){ line(2,-13,9,-16); }
|
void line8(){ line(2,-13,9,-16); }
|
||||||
|
|
||||||
|
// Individual shape components to build any B12 character
|
||||||
|
void lineTimes(){ line(4,-7,8,-3); line(4,-3,8,-7); }
|
||||||
|
void dotsDiv(){ point(6,-8); point(6,-2); }
|
||||||
|
void lineMinus(){ line(3,-5,9,-5); }
|
||||||
|
void linePlus(){ line(6,-8,6,-2); }
|
||||||
|
void period(){ point(5,0); }
|
||||||
|
void colon(){ point(5,-2); point(5,-8); }
|
||||||
|
|
||||||
|
|
||||||
|
// HELPER FUNCTIONS //
|
||||||
|
boolean inStr(String st, char _c){
|
||||||
|
try{
|
||||||
|
int x = st.indexOf(_c);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ class B12Float {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pointPlace = digits.size();
|
pointPlace = digits.size();
|
||||||
digits.add(new B12Char('.'));
|
digits.add(new B12Digit('.'));
|
||||||
|
|
||||||
while(whole > 0){
|
while(whole > 0){
|
||||||
if(whole < 12){
|
if(whole < 12){
|
||||||
@@ -124,7 +124,7 @@ class B12Float {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(value < 0){
|
if(value < 0){
|
||||||
digits.add(new B12Char('-'));
|
digits.add(new B12Digit('-'));
|
||||||
}
|
}
|
||||||
|
|
||||||
arrayLoaded = true;
|
arrayLoaded = true;
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class B12Int {
|
|||||||
digits.add(new B12Digit(0));
|
digits.add(new B12Digit(0));
|
||||||
}
|
}
|
||||||
if(value < 0){
|
if(value < 0){
|
||||||
digits.add(new B12Char('-'));
|
digits.add(new B12Digit('-'));
|
||||||
}
|
}
|
||||||
|
|
||||||
arrayLoaded = true;
|
arrayLoaded = true;
|
||||||
|
|||||||
@@ -13,15 +13,15 @@
|
|||||||
public static int DECIMAL = 65;
|
public static int DECIMAL = 65;
|
||||||
|
|
||||||
Clock clock;
|
Clock clock;
|
||||||
B12Char p;
|
B12Digit p;
|
||||||
B12Char t;
|
B12Digit t;
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
size(400,400);
|
size(400,400);
|
||||||
clock = new Clock(new STime48());
|
clock = new Clock(new STime48());
|
||||||
println("waiting");
|
println("waiting");
|
||||||
p = new B12Char('+');
|
p = new B12Digit('+');
|
||||||
t = new B12Char('/');
|
t = new B12Digit('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw(){
|
void draw(){
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class Clock {
|
|||||||
B12Int hours;
|
B12Int hours;
|
||||||
B12Int minutes;
|
B12Int minutes;
|
||||||
B12Int seconds;
|
B12Int seconds;
|
||||||
B12Char sep;
|
B12Digit sep;
|
||||||
B12Int fill;
|
B12Int fill;
|
||||||
int tmillis;
|
int tmillis;
|
||||||
//boolean initialized;
|
//boolean initialized;
|
||||||
@@ -15,7 +15,7 @@ class Clock {
|
|||||||
hours = new B12Int(t48.hours());
|
hours = new B12Int(t48.hours());
|
||||||
minutes = new B12Int(t48.mins());
|
minutes = new B12Int(t48.mins());
|
||||||
seconds = new B12Int(t48.secs());
|
seconds = new B12Int(t48.secs());
|
||||||
sep = new B12Char(':');
|
sep = new B12Digit(':');
|
||||||
fill = new B12Int(0);
|
fill = new B12Int(0);
|
||||||
|
|
||||||
hours.setMinLen(2);
|
hours.setMinLen(2);
|
||||||
@@ -51,8 +51,8 @@ class Clock {
|
|||||||
hours.setPos(-64, 0);
|
hours.setPos(-64, 0);
|
||||||
minutes.setPos(-32, 0);
|
minutes.setPos(-32, 0);
|
||||||
seconds.setPos(0, 0);
|
seconds.setPos(0, 0);
|
||||||
B12Char c1 = new B12Char(':');
|
B12Digit c1 = new B12Digit(':');
|
||||||
B12Char c2 = new B12Char(':');
|
B12Digit c2 = new B12Digit(':');
|
||||||
c1.setRefPos(-34, 0);
|
c1.setRefPos(-34, 0);
|
||||||
c2.setRefPos(-66, 0);
|
c2.setRefPos(-66, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class MathDisplay{
|
|||||||
|
|
||||||
MathDisplay(B12Math _math){
|
MathDisplay(B12Math _math){
|
||||||
math = _math;
|
math = _math;
|
||||||
digits = new ArrayList<B12Digit>();
|
//digits = new ArrayList<B12Digit>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO take expression from math and display it in whatever state it is in
|
// TODO take expression from math and display it in whatever state it is in
|
||||||
|
|||||||
@@ -11,6 +11,6 @@ class MathPad{
|
|||||||
// TODO send characters to math
|
// TODO send characters to math
|
||||||
|
|
||||||
void addchar(){
|
void addchar(){
|
||||||
math.expression.add(new B12Char('/'));
|
//math.expression.add(new B12Char('/'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user