feat: Randomize style generates complementary color palettes, seeded from logo if present#261
Draft
feat: Randomize style generates complementary color palettes, seeded from logo if present#261
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Copilot
AI
changed the title
[WIP] Update randomize style button for complimentary colors
feat: Randomize style generates complementary color palettes, seeded from logo if present
Apr 2, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The "Randomize style" button previously assigned independent random hex colors to each QR code element, producing visually incoherent results. Colors are now generated as a harmonious palette using HSL color theory, and if a logo is loaded its dominant color anchors the scheme.
Color utilities (
src/utils/color.ts)hexToHsl/hslToHex— round-trip HSL ↔ hex conversioncreateComplementaryColors(baseHex?)— randomly selects one of four harmony schemes and derives all four QR colors from a single hue anchor:extractDominantColorFromImage(imageSrc)— Canvas API pixel-sampling to get the average opaque color from a logo imagecreateRandomColorto always emit correctly zero-padded 6-digit hex stringsRandomize handler (
src/components/QRCodeCreate.vue)randomizeStyleSettingsis nowasync; whenimage.valueis set it extracts the logo's dominant color before callingcreateComplementaryColors, so all four color slots derive from a single coherent hue.Tests (
src/utils/color.test.ts)Unit tests added for
hexToHsl,hslToHex,createComplementaryColors(hex validity, harmony relationships, background contrast), andcreateRandomColor. Registered in the node workspace invitest.workspace.ts.