Skip to content
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

feat: 에디터에서 노트의 trail을 남기는 기능 추가 #177

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions public/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1298,9 +1298,23 @@ const cntRender = () => {
const f = (1 - (renderNotes[i].beat + renderNotes[i].duration - beats) / (5 / speed)) * 100;
if (renderNotes[i].value != 2 && p < 101) validNote = i;
else if (renderNotes[i].value == 2 && f < 100) validNote = i;
if (i == validNote) drawNote(p, renderNotes[i].x, renderNotes[i].y, selectedCheck(0, i), renderNotes[i].value, renderNotes[i].direction, t, f);
else if (i + 3 >= validNote) {
drawShadow(renderNotes[i].x, renderNotes[i].y, renderNotes[i].value, renderNotes[i].direction, 0.4 - 0.1 * (validNote - i));
const alpha = 0.4 - 0.1 * (validNote - i);
if (i > 0) {
const x1 = (cntCanvas.width / 200) * (renderNotes[i - 1].x + 100);
const y1 = (cntCanvas.height / 200) * (renderNotes[i - 1].y + 100);
const x2 = (cntCanvas.width / 200) * (renderNotes[i].x + 100);
const y2 = (cntCanvas.height / 200) * (renderNotes[i].y + 100);
cntCtx.beginPath();
cntCtx.strokeStyle = `rgba(255,255,255,${alpha})`;
cntCtx.lineWidth = 3;
cntCtx.moveTo(x1, y1);
cntCtx.lineTo(x2, y2);
cntCtx.stroke();
}
Comment on lines +1301 to +1313
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

노트 연결선의 투명도 계산 오류 수정 필요

현재 코드에서 alpha 값이 음수가 될 수 있어 연결선이 올바르게 표시되지 않을 수 있습니다.

alpha 값이 0 이하로 내려가지 않도록 최소값을 설정해야 합니다.

-         const alpha = 0.4 - 0.1 * (validNote - i);
+         const alpha = Math.max(0.4 - 0.1 * (validNote - i), 0);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const alpha = 0.4 - 0.1 * (validNote - i);
if (i > 0) {
const x1 = (cntCanvas.width / 200) * (renderNotes[i - 1].x + 100);
const y1 = (cntCanvas.height / 200) * (renderNotes[i - 1].y + 100);
const x2 = (cntCanvas.width / 200) * (renderNotes[i].x + 100);
const y2 = (cntCanvas.height / 200) * (renderNotes[i].y + 100);
cntCtx.beginPath();
cntCtx.strokeStyle = `rgba(255,255,255,${alpha})`;
cntCtx.lineWidth = 3;
cntCtx.moveTo(x1, y1);
cntCtx.lineTo(x2, y2);
cntCtx.stroke();
}
const alpha = Math.max(0.4 - 0.1 * (validNote - i), 0);
if (i > 0) {
const x1 = (cntCanvas.width / 200) * (renderNotes[i - 1].x + 100);
const y1 = (cntCanvas.height / 200) * (renderNotes[i - 1].y + 100);
const x2 = (cntCanvas.width / 200) * (renderNotes[i].x + 100);
const y2 = (cntCanvas.height / 200) * (renderNotes[i].y + 100);
cntCtx.beginPath();
cntCtx.strokeStyle = `rgba(255,255,255,${alpha})`;
cntCtx.lineWidth = 3;
cntCtx.moveTo(x1, y1);
cntCtx.lineTo(x2, y2);
cntCtx.stroke();
}

if (i == validNote) {
drawNote(p, renderNotes[i].x, renderNotes[i].y, selectedCheck(0, i), renderNotes[i].value, renderNotes[i].direction, t, f);
} else if (i + 3 >= validNote) {
drawShadow(renderNotes[i].x, renderNotes[i].y, renderNotes[i].value, renderNotes[i].direction, alpha);
}
}

Expand Down
Loading