-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
33 scorecard #130
Open
Snaki009
wants to merge
7
commits into
florczakraf:master
Choose a base branch
from
Snaki009:22-scorecard
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
33 scorecard #130
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
71f8609
Add Scorecard for score view
Snaki009 60bb2b4
Use hash and hide double when no info provided
Snaki009 6888f42
djlint
Snaki009 4d4b59e
Merge branch 'master' into 22-scorecard
Snaki009 47cea77
Removed vars
Snaki009 509e67a
Merge branch '22-scorecard' of https://github.com/Snaki009/boogie-sta…
Snaki009 2c172cc
Fixing typos and minor issues
Snaki009 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,173 @@ | ||
{% load mathfilters %} | ||
<div class="text-center"> | ||
<canvas id="statcard" width="400" height="600"></canvas> | ||
</div> | ||
<script> | ||
function getLines(ctx, text, maxWidth) { | ||
let words = text.split(" "); | ||
let lines = []; | ||
let currentLine = words[0]; | ||
|
||
for (let i = 1; i < words.length; i++) { | ||
let word = words[i]; | ||
let width = ctx.measureText(currentLine + " " + word).width; | ||
if (width < maxWidth) { | ||
currentLine += " " + word; | ||
} else { | ||
lines.push(currentLine); | ||
currentLine = word; | ||
} | ||
} | ||
lines.push(currentLine); | ||
return lines; | ||
} | ||
|
||
function drawCanvas() { | ||
const canvas = document.getElementById('statcard') | ||
const context = canvas.getContext('2d') | ||
const nodec = '{{ score.comment }}'.includes('No Dec/WO') | ||
let diffColor | ||
switch ('{{ score.song.chart_info.diff }}') { | ||
case 'Beginner': | ||
diffColor = '#a355b8' | ||
break | ||
case 'Easy': | ||
diffColor = '#1ec51d' | ||
break | ||
case 'Medium': | ||
diffColor = '#d6db41' | ||
break | ||
case 'Hard': | ||
diffColor = '#ba3049' | ||
break | ||
case 'Challenge': | ||
diffColor = '#2691c5' | ||
break | ||
default: | ||
diffColor = '#ffffff' | ||
break | ||
} | ||
|
||
barWidth = 306 | ||
|
||
const sum = parseInt('{{ score.total_steps }}') | ||
const p = parseInt('{{ score.fantastics_plus }}') / sum * barWidth; | ||
const f = parseInt('{{ score.fantastics }}') / sum * barWidth; | ||
const e = parseInt('{{ score.excellents }}') / sum * barWidth; | ||
const g = parseInt('{{ score.greats }}') / sum * barWidth; | ||
const d = parseInt('{{ score.decents }}') / sum * barWidth; | ||
const w = parseInt('{{ score.wayoffs }}') / sum * barWidth; | ||
const m = parseInt('{{ score.misses }}') / sum * barWidth; | ||
|
||
context.fillStyle = '#000000' | ||
context.fillRect(0, 0, 400, 600) | ||
|
||
context.fillStyle = diffColor | ||
context.fillRect(47, 127, 65, 65) | ||
|
||
context.textAlign = 'center' | ||
if ('{{score.song.gs_ranked}}' === 'True') { | ||
context.fillStyle = '#38abb5' | ||
context.fillRect(350, 20, 30, 30) | ||
context.fillStyle = '#ffffff' | ||
context.font = '30px miso' | ||
context.fillText('GS', 365, 45) | ||
|
||
} | ||
|
||
context.strokeStyle = '#ffffff' | ||
context.rect(47, 210, 306, 30); | ||
context.stroke() | ||
|
||
let start = 47 | ||
context.fillStyle = '#21cce8' | ||
context.fillRect(start, 210, p, 30) | ||
start += p || 0 | ||
context.fillStyle = '#e0e0e0' | ||
context.fillRect(start, 210, f, 30) | ||
start += f || 0 | ||
context.fillStyle = '#e29c18' | ||
context.fillRect(start, 210, e, 30) | ||
start += e || 0 | ||
context.fillStyle = '#66c955' | ||
context.fillRect(start, 210, g, 30) | ||
start += g || 0 | ||
context.fillStyle = '#6365c9' | ||
context.fillRect(start, 210, d, 30) | ||
start += d || 0 | ||
context.fillStyle = '#e08c36' | ||
context.fillRect(start, 210, w, 30) | ||
start += w || 0 | ||
context.fillStyle = '#ff0000' | ||
context.fillRect(start, 210, m, 30) | ||
|
||
context.fillStyle = '#000000' | ||
context.font = '80px Wendy' | ||
context.fillText('{{ score.song.chart_info.diff_number }}' || '?', 86, 180) | ||
context.font = '30px Wendy' | ||
context.fillStyle = '#ffffff' | ||
if('{{ score.song.chart_info.steps_type }}'.includes('single')) context.fillText('SINGLE', 81, 123) | ||
if('{{ score.song.chart_info.steps_type }}'.includes('double')) context.fillText('DOUBLE', 81, 123) | ||
|
||
context.font = '50px miso' | ||
context.fillText('BoogieStats', 200, 45) | ||
context.font = '18px miso' | ||
context.fillText(`Played by {{ score.player.name }}`, 200, 70) | ||
context.fillText('on {{ score.submission_date }}', 200, 85) | ||
context.font = '30px miso' | ||
context.fontWeight = '700' | ||
|
||
const lines = getLines(context, '{{ score.song.chart_info.title }}'.replace(''', `'`) || '{{ score.song.hash }}', 260) | ||
lines.forEach((line, i) => { | ||
context.fillText(line, 270, 170 - (lines.length * 20) + (i * 20)) | ||
}) | ||
context.font = '19px miso' | ||
context.fillText('{{ score.song.chart_info.artist }}'.replace(''', `'`), 270, 170) | ||
context.fillText('{{ score.song.chart_info.pack_name }}'.replace(''', `'`), 270, 190) | ||
|
||
context.font = '30px miso' | ||
context.textAlign = 'right' | ||
|
||
if (nodec) { | ||
context.fillStyle = 'gray' | ||
} | ||
context.fillText('DECENT', 190, 400) | ||
context.fillText('WAY OFF', 190, 440) | ||
|
||
context.fillStyle = '#ffffff' | ||
context.fillText('FANTASTIC', 190, 280) | ||
context.fillText('EXCELLENT', 190, 320) | ||
context.fillText('GREAT', 190, 360) | ||
context.fillText('MISS', 190, 480) | ||
|
||
context.font = '50px Wendy' | ||
context.textAlign = 'left' | ||
context.fillStyle = '#21cce8' | ||
context.fillText(`${parseInt('{{ score.fantastics_plus }}') + parseInt('{{ score.fantastics }}')}`, 210, 283) | ||
context.fillStyle = '#e29c18' | ||
context.fillText('{{ score.excellents }}', 210, 323) | ||
context.fillStyle = '#66c955' | ||
context.fillText('{{ score.greats }}', 210, 363) | ||
context.fillStyle = nodec ? 'gray' : '#6365c9' | ||
context.fillText('{{ score.decents }}', 210, 403) | ||
context.fillStyle = nodec ? 'gray' : '#e08c36' | ||
context.fillText('{{ score.way_offs }} ', 210, 443) | ||
context.fillStyle = '#ff0000' | ||
context.fillText('{{ score.misses }} ', 210, 483) | ||
|
||
context.fillStyle = '#ffffff' | ||
context.font = '140px Wendy' | ||
context.textAlign = 'right' | ||
context.fillText('{{ score.itg_score|div:100|stringformat:".2f" }}', 320, 570) | ||
|
||
context.font = '40px wendy' | ||
context.fillText('EX', 395, 540) | ||
context.fillText('{{ score.ex_score|div:100|stringformat:".2f" }}', 395, 570) | ||
|
||
context.font = '15px miso' | ||
context.textAlign = 'center' | ||
context.fillText(document.location.hostname, 200, 590) | ||
} | ||
|
||
window.addEventListener('load', drawCanvas) | ||
</script> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather avoid basing on external resources. Could we vendor these fonts? What are the licenses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Miso license, source:fontsquirell
L I C E N S E I N F O R M A T I O N
———————————————————-
You can use MISO for free.
You can share MISO with your friends
as long as you include this text file.
You are NOT permitted to sell MISO.
As for wendy: could by unlicensed as most pages skip that part but one page mentions:
EN: Only available for testing the font. Non-commercial and reproduction prohibited. Please contact the author for official purchase of use.
Could be boilerplate, needs doublecheck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a real issue because the fonts don't load reliably as described on PDGC. When browser cache is disabled they never display properly.