From 7cdcddd28765c8282722cdd7038017f18c86f6a4 Mon Sep 17 00:00:00 2001 From: 61616 <33187059+61616@users.noreply.github.com> Date: Fri, 29 Apr 2022 18:13:04 -0400 Subject: [PATCH] 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 --- B12NumbersV3/B12Char.pde | 6 ++--- B12NumbersV3/B12Digit.pde | 44 +++++++++++++++++++++++++++++++++++ B12NumbersV3/B12Float.pde | 4 ++-- B12NumbersV3/B12Int.pde | 2 +- B12NumbersV3/B12NumbersV3.pde | 8 +++---- B12NumbersV3/Clock.pde | 8 +++---- B12NumbersV3/MathDisplay.pde | 2 +- B12NumbersV3/MathPad.pde | 2 +- 8 files changed, 60 insertions(+), 16 deletions(-) diff --git a/B12NumbersV3/B12Char.pde b/B12NumbersV3/B12Char.pde index 165e73a..cacdaf8 100644 --- a/B12NumbersV3/B12Char.pde +++ b/B12NumbersV3/B12Char.pde @@ -1,10 +1,10 @@ -class B12Char extends B12Digit{ +/*class B12Char extends B12Digit{ String valid; char c; B12Char(char _c){ super(0); - valid = "+-*/.:"; // Defines valid input characters + valid = "+-*\/.:"; // Defines valid input characters if(inStr(_c)){ c = _c; }else{ @@ -52,4 +52,4 @@ class B12Char extends B12Digit{ return false; } } -} +}*/ diff --git a/B12NumbersV3/B12Digit.pde b/B12NumbersV3/B12Digit.pde index 629a602..c93afbe 100644 --- a/B12NumbersV3/B12Digit.pde +++ b/B12NumbersV3/B12Digit.pde @@ -11,6 +11,15 @@ class B12Digit{ 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 void setRefPos(PVector _refPos){ refPos = _refPos; } void setRefPos(float _x, float _y){ refPos = new PVector(_x,_y); } @@ -28,6 +37,7 @@ class B12Digit{ noFill(); ellipseMode(CORNERS); switch(value) { + // NUMBERS // case 0: line0(); break; case 1: @@ -52,6 +62,20 @@ class B12Digit{ line8(); line4(); line1(); line2(); break; case 11: 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(); } @@ -63,4 +87,24 @@ class B12Digit{ void line3(){ line(0,0,3,-10); } void line4(){ line(9,-10,2,-13); } 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; + } + } } diff --git a/B12NumbersV3/B12Float.pde b/B12NumbersV3/B12Float.pde index a208fc0..d4a880d 100644 --- a/B12NumbersV3/B12Float.pde +++ b/B12NumbersV3/B12Float.pde @@ -111,7 +111,7 @@ class B12Float { } pointPlace = digits.size(); - digits.add(new B12Char('.')); + digits.add(new B12Digit('.')); while(whole > 0){ if(whole < 12){ @@ -124,7 +124,7 @@ class B12Float { } if(value < 0){ - digits.add(new B12Char('-')); + digits.add(new B12Digit('-')); } arrayLoaded = true; diff --git a/B12NumbersV3/B12Int.pde b/B12NumbersV3/B12Int.pde index eaed62a..35ac840 100644 --- a/B12NumbersV3/B12Int.pde +++ b/B12NumbersV3/B12Int.pde @@ -73,7 +73,7 @@ class B12Int { digits.add(new B12Digit(0)); } if(value < 0){ - digits.add(new B12Char('-')); + digits.add(new B12Digit('-')); } arrayLoaded = true; diff --git a/B12NumbersV3/B12NumbersV3.pde b/B12NumbersV3/B12NumbersV3.pde index 1348496..a0a8ad9 100644 --- a/B12NumbersV3/B12NumbersV3.pde +++ b/B12NumbersV3/B12NumbersV3.pde @@ -13,15 +13,15 @@ public static int DECIMAL = 65; Clock clock; -B12Char p; -B12Char t; +B12Digit p; +B12Digit t; void setup(){ size(400,400); clock = new Clock(new STime48()); println("waiting"); - p = new B12Char('+'); - t = new B12Char('/'); + p = new B12Digit('+'); + t = new B12Digit('/'); } void draw(){ diff --git a/B12NumbersV3/Clock.pde b/B12NumbersV3/Clock.pde index ed2f74e..6af7fb0 100644 --- a/B12NumbersV3/Clock.pde +++ b/B12NumbersV3/Clock.pde @@ -4,7 +4,7 @@ class Clock { B12Int hours; B12Int minutes; B12Int seconds; - B12Char sep; + B12Digit sep; B12Int fill; int tmillis; //boolean initialized; @@ -15,7 +15,7 @@ class Clock { hours = new B12Int(t48.hours()); minutes = new B12Int(t48.mins()); seconds = new B12Int(t48.secs()); - sep = new B12Char(':'); + sep = new B12Digit(':'); fill = new B12Int(0); hours.setMinLen(2); @@ -51,8 +51,8 @@ class Clock { hours.setPos(-64, 0); minutes.setPos(-32, 0); seconds.setPos(0, 0); - B12Char c1 = new B12Char(':'); - B12Char c2 = new B12Char(':'); + B12Digit c1 = new B12Digit(':'); + B12Digit c2 = new B12Digit(':'); c1.setRefPos(-34, 0); c2.setRefPos(-66, 0); diff --git a/B12NumbersV3/MathDisplay.pde b/B12NumbersV3/MathDisplay.pde index 3ff4682..a0cf251 100644 --- a/B12NumbersV3/MathDisplay.pde +++ b/B12NumbersV3/MathDisplay.pde @@ -4,7 +4,7 @@ class MathDisplay{ MathDisplay(B12Math _math){ math = _math; - digits = new ArrayList(); + //digits = new ArrayList(); } // TODO take expression from math and display it in whatever state it is in diff --git a/B12NumbersV3/MathPad.pde b/B12NumbersV3/MathPad.pde index f308113..beaf929 100644 --- a/B12NumbersV3/MathPad.pde +++ b/B12NumbersV3/MathPad.pde @@ -11,6 +11,6 @@ class MathPad{ // TODO send characters to math void addchar(){ - math.expression.add(new B12Char('/')); + //math.expression.add(new B12Char('/')); } }