12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #include "opendoor.h"
- void DrawHorizontalBar(int nValue, int nMinValue, int nMaxValue,
- int nMaxChars);
- void DrawGraphOfPercentages(int nItems, int *panPercentages,
- char **papszTitles, char bTitleColor, char bGraphColor,
- int nTitleWidth, int nGraphWidth);
- main()
- {
- char *apszTitles[7] = {"Sunday", "Monday", "Tuesday", "Wednesday",
- "Thursday", "Friday", "Saturday"};
- int anValues[7] = {50, 75, 100, 25, 83, 0, 43};
- od_printf("`bright green`Test graph:\n\r");
- DrawGraphOfPercentages(7, anValues, apszTitles, 0x02, 0x0f, 20, 50);
- od_get_key(TRUE);
- return(0);
- }
- void DrawGraphOfPercentages(int nItems, int *panPercentages,
- char **papszTitles, char bTitleColor, char bGraphColor,
- int nTitleWidth, int nGraphWidth)
- {
- int nCurrentItem;
-
- for(nCurrentItem = 0; nCurrentItem < nItems; ++nCurrentItem)
- {
-
- od_set_attrib(bTitleColor);
-
- od_repeat(' ', nTitleWidth - strlen(papszTitles[nCurrentItem]));
-
- od_disp_str(papszTitles[nCurrentItem]);
-
- od_printf(" ");
-
- od_set_attrib(bGraphColor);
-
- DrawHorizontalBar(panPercentages[nCurrentItem], 0, 100, nGraphWidth);
-
- od_printf("\n\r");
- }
- }
- void DrawHorizontalBar(int nValue, int nMinValue, int nMaxValue,
- int nMaxChars)
- {
-
- int nBarChars = ((nValue - nMinValue) * nMaxChars) / nMaxValue;
- if(od_control.user_ansi || od_control.user_avatar)
- {
-
-
-
-
-
- od_repeat(220, nBarChars);
- }
- else
- {
-
- od_repeat('=', nBarChars);
- }
- }
|