Skip to content

Commit

Permalink
show fps
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobuxstation committed May 16, 2024
1 parent 7b16d44 commit e2df27a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
font-family: 'DIN Next LT', sans-serif;
transition: all 0.5s ease;
overflow: hidden;
outline: none;
}

:root {
Expand Down
19 changes: 16 additions & 3 deletions js/graphicDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* This class handle the graphical behaviour
* of the CAD
*/
var globalfps = 0
function GraphicDisplay(displayName, width, height) {
// Enumerate all available modes
this.MODES = {
Expand Down Expand Up @@ -117,7 +118,7 @@ function GraphicDisplay(displayName, width, height) {
this.cvn = 0; // Canvas HTML element
this.context; // Canvas object

this.tooltipDefault = "WebCAD5"
this.tooltipDefault = "QroCAD Beta"
this.tooltip = this.tooltipDefault;

this.keyboard = null;
Expand Down Expand Up @@ -998,7 +999,7 @@ GraphicDisplay.prototype.setToolTip = function (text) {
GraphicDisplay.prototype.getToolTip = function () {
var text = this.tooltip;

text += " | (" + this.getCursorXLocal() + "," + this.getCursorYLocal() + ")";
text += " (" + this.getCursorXLocal() + "," + this.getCursorYLocal() + ") " + `(${globalfps} FPS)`;

return text;
};
Expand Down Expand Up @@ -1114,8 +1115,20 @@ var initCAD = function (gd) {
gd.performAction(e, gd.MOUSEACTION.UP);
});

var lastSecond = Date.now()
var fps = 0

// Start CAD
setInterval(function () {
var time = Date.now()
if (time - lastSecond > 1000) {
globalfps = fps
fps = 0
lastSecond = time
} else {
fps += 1
}

gd.execute();
}, 100);
}, 0);
};

0 comments on commit e2df27a

Please sign in to comment.