-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fps display, string Utils, rename to Txt
- Loading branch information
Showing
6 changed files
with
70 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
#include "App.h" | ||
#include "Util.h" | ||
|
||
|
||
// Graphics draw | ||
///----------------------------------------------------------------------------- | ||
void App::Graph() | ||
{ | ||
// clear screen | ||
pWindow->clear(); | ||
//Rect(0,0, xWindow,yWindow, 0,0,0); | ||
|
||
// test | ||
Clr(155,215,255); | ||
s = "Cool."; | ||
Text(0, 0); | ||
s = "Fps: " + f2s(1/dt,1,3); | ||
Txt(10, 0); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "Util.h" | ||
#include <sstream> | ||
#include <iomanip> | ||
#include <regex> | ||
using namespace std; | ||
|
||
|
||
// string utils | ||
//------------------------------------------------------------------ | ||
|
||
string i2s(const int v, const char width) | ||
{ | ||
ostringstream s; | ||
if (width != 0) s.width(width); //s.fill(fill); | ||
s << fixed << v; | ||
return s.str(); | ||
} | ||
|
||
string f2s(const float v, const char precision, const char width) | ||
{ | ||
ostringstream s; | ||
if (width != 0) s.width(width); | ||
s << fixed << setprecision(precision) << v; | ||
return s.str(); | ||
} | ||
|
||
|
||
vector<string> split(const string& s, const string& reg) | ||
{ | ||
regex re(reg); | ||
sregex_token_iterator | ||
first{s.begin(), s.end(), re, -1}, // -1 split | ||
last; | ||
return {first, last}; | ||
} | ||
|
||
string strlower(const string& s) | ||
{ | ||
string ss = s; | ||
transform(ss.begin(), ss.end(), ss.begin(), ::tolower); | ||
return ss; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
#include <vector> | ||
#include <string> | ||
#include <algorithm> | ||
|
||
|
||
// format int, float to string | ||
std::string i2s(const int v, const char width=0/*, const char fill=' '*/); | ||
std::string f2s(const float v, const char precision=2, const char width=4); | ||
|
||
// split string | ||
std::vector<std::string> split( | ||
const std::string& s, const std::string& reg); | ||
|
||
// string to lower | ||
std::string strlower(const std::string& s); |