diff options
author | Michael Kuhn <suraia@ikkoku.de> | 2017-11-22 17:08:26 +0100 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-11-23 00:08:26 +0800 |
commit | 42d781a709f2919b13f9f75be83e53910f5a6c83 (patch) | |
tree | 55119b4f202a520fb6b3a8b6eb9cdf0090ca38a7 /public | |
parent | 2cb6c51158aece9285059db72e5f28b1b8aadb45 (diff) | |
download | gitea-42d781a709f2919b13f9f75be83e53910f5a6c83.tar.gz gitea-42d781a709f2919b13f9f75be83e53910f5a6c83.zip |
Update gitgraph.js to fix blurry commit graph on HiDPI screens (#2957)
Diffstat (limited to 'public')
-rw-r--r-- | public/vendor/VERSIONS | 2 | ||||
-rw-r--r-- | public/vendor/plugins/gitgraph/gitgraph.js | 23 |
2 files changed, 21 insertions, 4 deletions
diff --git a/public/vendor/VERSIONS b/public/vendor/VERSIONS index 356c35ec7c..e1e09a87ec 100644 --- a/public/vendor/VERSIONS +++ b/public/vendor/VERSIONS @@ -15,7 +15,7 @@ File(s): /vendor/plugins/clipboard/clipboard.min.js Version: 1.5.9 File(s): /vendor/plugins/gitgraph/gitgraph.js -Version: 5fcc26b +Version: 9b492e8bf1ddf7908a4997b8f83fa38a809a9da3 File(s): /vendor/plugins/autolink/autolink.js Version: 741f66f diff --git a/public/vendor/plugins/gitgraph/gitgraph.js b/public/vendor/plugins/gitgraph/gitgraph.js index f6c73a2ec4..bab36e7701 100644 --- a/public/vendor/plugins/gitgraph/gitgraph.js +++ b/public/vendor/plugins/gitgraph/gitgraph.js @@ -44,6 +44,15 @@ var gitGraph = function (canvas, rawGraphList, config) { var ctx = canvas.getContext("2d"); + var devicePixelRatio = window.devicePixelRatio || 1; + var backingStoreRatio = ctx.webkitBackingStorePixelRatio || + ctx.mozBackingStorePixelRatio || + ctx.msBackingStorePixelRatio || + ctx.oBackingStorePixelRatio || + ctx.backingStorePixelRatio || 1; + + var ratio = devicePixelRatio / backingStoreRatio; + var init = function () { var maxWidth = 0; var i; @@ -61,12 +70,20 @@ var gitGraph = function (canvas, rawGraphList, config) { graphList.unshift(row); } - canvas.width = maxWidth * config.unitSize; - canvas.height = graphList.length * config.unitSize; + var width = maxWidth * config.unitSize; + var height = graphList.length * config.unitSize; + + canvas.width = width * ratio; + canvas.height = height * ratio; + + canvas.style.width = width + 'px'; + canvas.style.height = height + 'px'; ctx.lineWidth = config.lineWidth; ctx.lineJoin = "round"; ctx.lineCap = "round"; + + ctx.scale(ratio, ratio); }; var genRandomStr = function () { @@ -186,7 +203,7 @@ var gitGraph = function (canvas, rawGraphList, config) { } } - y = canvas.height - config.unitSize * 0.5; + y = (canvas.height / ratio) - config.unitSize * 0.5; //iterate for (i = 0, l = graphList.length; i < l; i++) { |