-
Notifications
You must be signed in to change notification settings - Fork 244
Fix: Blue color glitch on "Learn Logic Design" page (dark mode rendering issue) #778
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
Open
Ram-sah19
wants to merge
10
commits into
CircuitVerse:master
Choose a base branch
from
Ram-sah19:fix/blue-color-glitch-learn-page
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1700c3f
Fix: shuffle bias, jQuery check, global leaks, console logs, shebang,β¦
Ram-sah19 4a842d2
Fix: shuffle bias, jQuery check, global leaks, console logs, shebang,β¦
Ram-sah19 fae206d
Fix: avoid double scroll counting in getMouse (use pageY correctly)
Ram-sah19 ac7ac2d
feat: add circuit visualization using GIFs and videos
Ram-sah19 aea53ac
fix: resolve CodeRabbit SCSS review issues
Ram-sah19 2252829
refactor: merge duplicate SCSS rules for gate controls
Ram-sah19 a0d0c36
Fix: blue color glitch on Learn Logic Design page (dark mode issue)
Ram-sah19 654e971
Fix: address code review comments (null safety, scroll handling, darkβ¦
Ram-sah19 87d99d2
Refactor: remove unused scroll container logic for coordinate calculaβ¦
Ram-sah19 d86eba1
issue had been solved
Ram-sah19 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 hidden or 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 |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| #!/bin/bash | ||
|
|
||
| const { Octokit } = require("@octokit/rest"); | ||
|
|
||
| const octokit = new Octokit({ | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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,204 @@ | ||
| {% comment %} | ||
| Usage: {% include gate_animation.html gate="AND" %} | ||
| Supported: AND, OR, NOT, NAND, NOR, XOR, XNOR | ||
| {% endcomment %} | ||
|
|
||
| <div class="gate-anim-wrapper" data-gate="{{ include.gate }}"> | ||
| <canvas class="gate-anim-canvas" width="340" height="120" aria-label="{{ include.gate }} gate animation"></canvas> | ||
| <div class="gate-anim-controls"> | ||
| {% if include.gate == "NOT" %} | ||
| <label>A: <input type="checkbox" class="gate-anim-input" data-gate="{{ include.gate }}" data-input="0"> <span class="bit-label">0</span></label> | ||
| {% else %} | ||
| <label>A: <input type="checkbox" class="gate-anim-input" data-gate="{{ include.gate }}" data-input="0"> <span class="bit-label">0</span></label> | ||
| <label>B: <input type="checkbox" class="gate-anim-input" data-gate="{{ include.gate }}" data-input="1"> <span class="bit-label">0</span></label> | ||
| {% endif %} | ||
| <span class="gate-anim-output">Output: <strong class="output-val">β</strong></span> | ||
| </div> | ||
| </div> | ||
|
|
||
| <script> | ||
| (function() { | ||
| var wrapper = document.currentScript && document.currentScript.previousElementSibling; | ||
| if (!wrapper || !wrapper.classList.contains("gate-anim-wrapper")) return; | ||
|
|
||
| var gateId = wrapper.dataset.gate; | ||
| var canvas = wrapper.querySelector(".gate-anim-canvas"); | ||
| if (!canvas) return; | ||
|
|
||
| var ctx = canvas.getContext("2d"); | ||
| var inputs = [false, false]; | ||
| var animProgress = 0; | ||
| var animFrame = null; | ||
|
|
||
| function computeOutput(gate, a, b) { | ||
| switch(gate) { | ||
| case "AND": return a && b; | ||
| case "OR": return a || b; | ||
| case "NOT": return !a; | ||
| case "NAND": return !(a && b); | ||
| case "NOR": return !(a || b); | ||
| case "XOR": return a !== b; | ||
| case "XNOR": return a === b; | ||
| } | ||
| } | ||
|
|
||
| function drawGateShape(gate, cx, cy, active) { | ||
| ctx.strokeStyle = "#333"; | ||
| ctx.lineWidth = 2.5; | ||
| ctx.fillStyle = active ? "#d4edda" : "#f8f9fa"; | ||
|
|
||
| if (gate === "NOT") { | ||
| // Triangle | ||
| ctx.beginPath(); | ||
| ctx.moveTo(cx - 22, cy - 20); | ||
| ctx.lineTo(cx + 18, cy); | ||
| ctx.lineTo(cx - 22, cy + 20); | ||
| ctx.closePath(); | ||
| ctx.fill(); ctx.stroke(); | ||
| // Bubble | ||
| ctx.beginPath(); | ||
| ctx.arc(cx + 24, cy, 6, 0, Math.PI * 2); | ||
| ctx.fillStyle = active ? "#28a745" : "#fff"; | ||
| ctx.fill(); ctx.stroke(); | ||
| } else if (gate === "AND" || gate === "NAND") { | ||
| ctx.beginPath(); | ||
| ctx.moveTo(cx - 22, cy - 22); | ||
| ctx.lineTo(cx, cy - 22); | ||
| ctx.arc(cx, cy, 22, -Math.PI / 2, Math.PI / 2); | ||
| ctx.lineTo(cx - 22, cy + 22); | ||
| ctx.closePath(); | ||
| ctx.fill(); ctx.stroke(); | ||
| if (gate === "NAND") { | ||
| ctx.beginPath(); | ||
| ctx.arc(cx + 28, cy, 6, 0, Math.PI * 2); | ||
| ctx.fillStyle = active ? "#28a745" : "#fff"; | ||
| ctx.fill(); ctx.stroke(); | ||
| } | ||
| } else { | ||
| // OR / NOR / XOR / XNOR β curved body | ||
| ctx.beginPath(); | ||
| ctx.moveTo(cx - 22, cy - 22); | ||
| ctx.quadraticCurveTo(cx - 5, cy, cx - 22, cy + 22); | ||
| ctx.quadraticCurveTo(cx + 5, cy + 22, cx + 22, cy); | ||
| ctx.quadraticCurveTo(cx + 5, cy - 22, cx - 22, cy - 22); | ||
| ctx.fill(); ctx.stroke(); | ||
| if (gate === "XOR" || gate === "XNOR") { | ||
| ctx.beginPath(); | ||
| ctx.moveTo(cx - 28, cy - 22); | ||
| ctx.quadraticCurveTo(cx - 11, cy, cx - 28, cy + 22); | ||
| ctx.stroke(); | ||
| } | ||
| if (gate === "NOR" || gate === "XNOR") { | ||
| ctx.beginPath(); | ||
| ctx.arc(cx + 28, cy, 6, 0, Math.PI * 2); | ||
| ctx.fillStyle = active ? "#28a745" : "#fff"; | ||
| ctx.fill(); ctx.stroke(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function signalColor(on, alpha) { | ||
| return on | ||
| ? "rgba(40,167,69," + alpha + ")" | ||
| : "rgba(180,180,180," + alpha + ")"; | ||
| } | ||
|
|
||
| function drawWire(x1, y1, x2, y2, on, progress) { | ||
| var len = Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)); | ||
| var ex = x1 + (x2 - x1) * progress; | ||
| var ey = y1 + (y2 - y1) * progress; | ||
|
|
||
| // Base wire (grey) | ||
| ctx.beginPath(); | ||
| ctx.moveTo(x1, y1); ctx.lineTo(x2, y2); | ||
| ctx.strokeStyle = "#ccc"; ctx.lineWidth = 3; | ||
| ctx.stroke(); | ||
|
|
||
| // Animated signal | ||
| ctx.beginPath(); | ||
| ctx.moveTo(x1, y1); ctx.lineTo(ex, ey); | ||
| ctx.strokeStyle = signalColor(on, 1); | ||
| ctx.lineWidth = 3; | ||
| ctx.stroke(); | ||
|
|
||
| // Signal dot | ||
| ctx.beginPath(); | ||
| ctx.arc(ex, ey, 5, 0, Math.PI * 2); | ||
| ctx.fillStyle = signalColor(on, 0.9); | ||
| ctx.fill(); | ||
| } | ||
|
|
||
| function draw() { | ||
| ctx.clearRect(0, 0, canvas.width, canvas.height); | ||
| var isNot = (gateId === "NOT"); | ||
| var a = inputs[0], b = inputs[1]; | ||
| var out = computeOutput(gateId, a, b); | ||
| var cx = 185, cy = 60; | ||
| var p = animProgress; | ||
|
|
||
| // Input wires | ||
| if (isNot) { | ||
| drawWire(30, cy, cx - 22, cy, a, Math.min(p * 2, 1)); | ||
| } else { | ||
| drawWire(30, 35, cx - 22, cy - 14, a, Math.min(p * 2, 1)); | ||
| drawWire(30, 85, cx - 22, cy + 14, b, Math.min(p * 2, 1)); | ||
| } | ||
|
|
||
| // Gate body | ||
| var bodyAlpha = Math.max(0, p * 2 - 1); | ||
| ctx.globalAlpha = 0.3 + bodyAlpha * 0.7; | ||
| drawGateShape(gateId, cx, cy, out); | ||
| ctx.globalAlpha = 1; | ||
|
|
||
| // Output wire | ||
| var outX = (gateId === "NOT" || gateId === "NAND" || gateId === "NOR" || gateId === "XNOR") ? cx + 30 : cx + 22; | ||
| var outProgress = Math.max(0, p * 2 - 1); | ||
| drawWire(outX, cy, 310, cy, out, outProgress); | ||
|
|
||
| // Labels | ||
| ctx.fillStyle = "#333"; | ||
| ctx.font = "bold 13px monospace"; | ||
| ctx.fillText("A=" + (a ? "1" : "0"), 5, 39); | ||
| if (!isNot) ctx.fillText("B=" + (b ? "1" : "0"), 5, 89); | ||
| ctx.fillText("Out=" + (out ? "1" : "0"), 315, 64); | ||
|
|
||
| // Update output display | ||
| var outEl = wrapper.querySelector(".output-val"); | ||
| if (outEl) { | ||
| outEl.textContent = out ? "1 (HIGH)" : "0 (LOW)"; | ||
| outEl.style.color = out ? "#28a745" : "#dc3545"; | ||
| } | ||
| } | ||
|
|
||
| function animate() { | ||
| animProgress += 0.03; | ||
| draw(); | ||
| if (animProgress < 1) { | ||
| animFrame = requestAnimationFrame(animate); | ||
| } else { | ||
| animProgress = 1; | ||
| draw(); | ||
| } | ||
| } | ||
|
|
||
| function startAnim() { | ||
| if (animFrame) cancelAnimationFrame(animFrame); | ||
| animProgress = 0; | ||
| animate(); | ||
| } | ||
|
|
||
| // Init | ||
| animProgress = 1; | ||
| draw(); | ||
|
|
||
| // Wire up checkboxes | ||
| wrapper.querySelectorAll(".gate-anim-input").forEach(function(cb) { | ||
| cb.addEventListener("change", function() { | ||
| var idx = parseInt(this.dataset.input); | ||
| inputs[idx] = this.checked; | ||
| this.nextElementSibling.textContent = this.checked ? "1" : "0"; | ||
| startAnim(); | ||
| }); | ||
| }); | ||
| })(); | ||
| </script> | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.