Skip to content

Commit

Permalink
Merge pull request #9 from JustinShetty/master
Browse files Browse the repository at this point in the history
Add option to toggle gridlines
  • Loading branch information
Kei18 authored May 21, 2024
2 parents a5f5b74 + 3a9f009 commit f23ec70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/ofApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ofApp : public ofBaseApp
bool flg_snapshot;
bool flg_zoomout;
bool flg_zoomin;
bool flg_grid;

enum struct LINE_MODE { STRAIGHT, PATH, NONE, NUM };
LINE_MODE line_mode;
Expand Down
8 changes: 7 additions & 1 deletion src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ static void printKeys()
std::cout << "- down : speed down" << std::endl;
std::cout << "- i : toggle zoom in" << std::endl;
std::cout << "- o : toggle zoom out" << std::endl;
std::cout << "- G : toggle gridlines" << std::endl;
std::cout << "- space : screenshot (saved in Desktop)" << std::endl;
std::cout << "- esc : terminate" << std::endl;
}
Expand All @@ -50,6 +51,7 @@ ofApp::ofApp(Graph* _G, Solution* _P, bool _flg_capture_only)
flg_snapshot(flg_capture_only),
flg_zoomout(false),
flg_zoomin(false),
flg_grid(true),
line_mode(flg_capture_only ? LINE_MODE::PATH : LINE_MODE::STRAIGHT)
{
}
Expand Down Expand Up @@ -127,7 +129,8 @@ void ofApp::draw()
auto x_draw = x * scale - scale / 2 + window_x_buffer + scale / 2 - 0.15;
auto y_draw =
y * scale - scale / 2 + window_y_top_buffer + scale / 2 - 0.15;
ofDrawRectangle(x_draw, y_draw, scale - 0.3, scale - 0.3);
auto gridline_space = flg_grid ? 0.3 : 0.0;
ofDrawRectangle(x_draw, y_draw, scale - gridline_space, scale - gridline_space);
if (flg_font) {
ofSetColor(Color::font);
font.drawString(std::to_string(index), x_draw + 1,
Expand Down Expand Up @@ -255,6 +258,9 @@ void ofApp::keyPressed(int key)
if (key == 'o') {
flg_zoomout = !flg_zoomout;
}
if (key == 'G') {
flg_grid = !flg_grid;
}
}

void ofApp::keyReleased(int key) {}
Expand Down

0 comments on commit f23ec70

Please sign in to comment.