Piecewise Expressions vs. If Then

So I'm drawing a box that will highlight specific parts of the screen. I decided to go overboard with piecewise expressions to save line space so the getKey will update faster. I was wondering if this hurts me in the long run. Below is the code I made with variables added on above it. Some of the project has been removed to keep what I'm making in the dark.

Also the only optimized code is the piecewise expression part, the getKey if then sequences above are for testing. Plus there is more to the figure than just 9 boxes like this program will do, but all calculations using piecewise expressions must be made so it will account for more faces.

So I'm drawing a box that will highlight specific parts of the screen. I decided to go overboard with piecewise expressions to save line space so the getKey will update faster. I was wondering if this hurts me in the long run. Below is the code I made with variables added on above it. Some of the project has been removed to keep what I'm making in the dark.

Also the only optimized code is the piecewise expression part, the getKey if then sequences above are for testing. Plus there is more to the figure than just 9 boxes like this program will do, but all calculations using piecewise expressions must be made so it will account for more faces.

**Code:**```
ClrDraw:ClrHome:BackgroundOn White:AxesOff
```

0->Xmin

264->Xmax

~164->Ymin

0->Ymax

138->D:~88->E:1->F:5->G

D->Q:E->R:F->S:G->T

//Draws Starting Point Box

Line(D,E,D+28,E,LtGray

Line(D,E,D,E-28,LtGray

Line(D+28,E,D+28,E-28,LtGray

Line(D,E-28,D+28,E-28,LtGray

Repeat A=105

getKey->A

If A!=105 and A!=0:Then

//Determining Key Input

If A=24:Then

If G!=1 or G!=4 or G!=7:Then

D-28->Q

G-1->T

End

If G=1 or G=4 or G=7:Then

D+56->Q

G+2->T

End:End

If A=25:Then

If G>3:Then

E+28->R

G-3->T

End

If G<4:Then

E-56->R

G+6->T

End:End

If A=26:Then

If G!=3 or G!=6 or G!=9:Then

D+28->Q

G+1->T

End

If G=3 or G=6 or G=9:Then

D-56->Q

G-2->T

End:End

If A=34:Then

If G<7:Then

E-28->R

G+3->T

End

If G>6:Then

E+56->R

G-6->T

End:End

//Highlight pieces

//Fills in Last Box

If D!=Q or E!=R or F!=S or G!=T:Then

//Up

Line(D,E,(D+28-(15*(F=2)-1*(F=2 and G=2 or F=2 and G=5 or F=2 and G=8))),(E-(13*(F=2)+1*(F=2 and G=2 or F=2 and G=5 or F=2 and G=8))),Black

//Left

Line(D,E,(D+(13*(F=3)+1*(F=3 and G>3 and G<7))),(E-28+(15*(F=3)-1*(F=3 and G>3 and G<7))),Black

//Right

Line((D+28-(15*(F=2)-1*(F=2 and G=2 or F=2 and G=5 or F=2 and G=8))),(E-(13*(F=2)+1*(F=2 and G=2 or F=2 and G=5 or F=2 or G=8))),(D+28-(15*(F=2)-1*(F=2 and G=2 or F=2 and G=5 or F=2 and G=8))),(E-28+(15*(F=3)-1*(F=3 and G>3 and G<7))-(13*(F=2)+1*(F=2 and G=2 or F=2 and G=5 or F=2 or G=8))),Black

//Down

Line((D+(13*(F=3)+1*(F=3 and G>3 and G<7))),(E-28+(15*(F=3)-1*(F=3 and G>3 and G<7))),(D+28-(15*(F=2)-1*(F=2 and G=2 or F=2 and G=5 or F=2 and G=8))+(13*(F=3)+1*(F=3 and G>3 and G<7))),(E-28+(15*(F=3)-1*(F=3 and G>3 and G<7))-(13*(F=2)+1*(F=2 and G=2 or F=2 and G=5 or F=2 and G=8))),Black

Q->D:R->E:S->F:T->G

End

//Creates New Box

//Up

Line(D,E,(D+28-(15*(F=2)-1*(F=2 and G=2 or F=2 and G=5 or F=2 and G=8))),(E-(13*(F=2)+1*(F=2 and G=2 or F=2 and G=5 or F=2 and G=8))),LtGray

//Left

Line(D,E,(D+(13*(F=3)+1*(F=3 and G>3 and G<7))),(E-28+(15*(F=3)-1*(F=3 and G>3 and G<7))),LtGray

//Right

Line((D+28-(15*(F=2)-1*(F=2 and G=2 or F=2 and G=5 or F=2 and G=8))),(E-(13*(F=2)+1*(F=2 and G=2 or F=2 and G=5 or F=2 or G=8))),(D+28-(15*(F=2)-1*(F=2 and G=2 or F=2 and G=5 or F=2 and G=8))),(E-28+(15*(F=3)-1*(F=3 and G>3 and G<7))-(13*(F=2)+1*(F=2 and G=2 or F=2 and G=5 or F=2 or G=8))),LtGray

//Down

Line((D+(13*(F=3)+1*(F=3 and G>3 and G<7))),(E-28+(15*(F=3)-1*(F=3 and G>3 and G<7))),(D+28-(15*(F=2)-1*(F=2 and G=2 or F=2 and G=5 or F=2 and G=8))+(13*(F=3)+1*(F=3 and G>3 and G<7))),(E-28+(15*(F=3)-1*(F=3 and G>3 and G<7))-(13*(F=2)+1*(F=2 and G=2 or F=2 and G=5 or F=2 and G=8))),LtGray

End:End