NO IDEA WHY I REVERTED

This commit is contained in:
NightlyFox 2018-09-26 01:18:04 -05:00
parent 3e7618a284
commit 63e71a4416

View File

@ -377,49 +377,50 @@ void fontExit()
} }
/*Automatically gives you the desired x-coordinate /*Automatically gives you the desired x-coordinate
*based on the string length and desired alignmenr *based on the string length and desired alignment
*rY=reference point... where to align around *rY=reference point... where to align around
*align='t','b','c' translates too (top,bottom,center) *align='t','b','c' translates to (top,bottom,center)
*'t' aligned, top of text aligns with rY, *'t' aligned, top of text aligns with rY,
*you get the rest.... *you get the rest....
*/ */
uint32_t getYCoordinate(u32 font,uint32_t rY,const char* text, const char align){ uint32_t GetTextYCoordinate(u32 font, uint32_t rY, const char* text, const char align) {
uint32_t height_o,width; uint32_t height_o,width;
GetTextDimensions(font,text,&width,&height_o); GetTextDimensions(font,text,&width,&height_o);
uint32_t height = (uint32_t)height_o; uint32_t height = (uint32_t)height_o;
uint32_t fC = (rY-height); uint32_t fC = (rY-height);
switch(align){ switch(align){
case 't': case 't':
default: default:
return rY; return rY;
case 'c': case 'c':
return (rY+(height/2U)); return (rY+(height>>1));//>>1 is a bitwise shift for dividing by 2
case 'b': case 'b':
if(fC<=0U) return 0U; if(fC<=0) return 0;
else return fC; else return fC;
} }
} }
/*Automatically gives you the desired x-coordinate /*Automatically gives you the desired x-coordinate
*based on the string length and desired alignmenr *based on the string length and desired alignment
*rX=reference point... where to align around *rX=reference point... where to align around
*text=string you want to display *text=string you want to display
*align='r','l','c' translates too (right,left,center) *align='r','l','c' translates to (right,left,center)
*'r' aligned, rX location = end of string, you get the rest... *'r' aligned, rX location = end of string, you get the rest...
*/ */
uint32_t getXCoordinate(u32 font,uint32_t rX, const char* text ,const char align){ uint32_t GetTextXCoordinate(u32 font, uint32_t rX, const char* text, const char align) {
uint32_t height,width_o; uint32_t height,width_o;
GetTextDimensions(font,text,&width_o,&height); GetTextDimensions(font,text,&width_o,&height);
uint32_t fC = (rX-width_o); uint32_t fC = (rX-width_o);
switch(align){ switch(align){
case 'r': case 'r':
if(fC<0U) return 0U; if(fC<0) return 0;
else return fC; else return fC;
case 'c': case 'c':
return (rX+(width_o/2U)); return (rX+(width_o>>1));//>>1 is a bitwise shift for dividing by 2
case 'l': case 'l':
default: default:
return rX; return rX;
} }
} }