DEV Community

Denis
Denis

Posted on

Devlog: How Our AI Agents Built the Gradient & Pattern Accessibility Contrast Analyzer for WCAG Compliance

Devlog: How Our AI Agents Built the Gradient & Pattern Accessibility Contrast Analyzer for WCAG Compliance

In today's digital landscape, web accessibility is not just a regulatory requirement but a crucial factor in ensuring an inclusive online experience. One of the most common challenges for designers and developers is ensuring sufficient contrast for text and UI elements placed over complex backgrounds such as gradients, images, or patterns. Manually checking these cases is time-consuming and prone to errors. This led us to develop a tool that automates this critical process.

Introducing the Gradient & Pattern Accessibility Contrast Analyzer

This essential tool for designers and developers ensures web content meets WCAG accessibility standards, specifically for text and UI elements placed over complex backgrounds like gradients, images, or patterns. Users can upload background images, define CSS gradients, or paste design elements, then add foreground text or UI components. The application performs a pixel-level contrast analysis to identify areas that fail WCAG 2.x standards (AA or AAA), highlighting problematic regions and suggesting adjustments.

The Technical Challenge and AI Agent Collaboration

Developing a tool for pixel-level contrast analysis on complex backgrounds presented a significant technical challenge. Traditional contrast measurement tools fall short when multiple colors exist beneath the text. It was necessary to implement a sophisticated algorithm capable of analyzing the contrast of every pixel beneath the text and evaluating it against WCAG standards.

Jan: The Brain Behind Pixel Analysis

Our AI developer, Jan, dove into the heart of the problem: the contrast analysis algorithm. His task was to create robust logic that could efficiently process image data, detect background and foreground colors at the pixel level, and apply WCAG rules for contrast ratio calculation.

"A key challenge was efficiently processing image data and dynamically determining the 'worst-case' contrast for a given text block on a variable background. We had to implement an algorithm that iterates through pixels under the text, identifies the least contrasting pixel, and then uses that for the final WCAG evaluation. Here's an excerpt from the initialization showing our code structure, including localization support and payment processing crucial for premium features:"

        // Firebase configuration and initialization
        const firebaseConfig = {
            apiKey: "AIzaSyFakeKeyForShowcaseHubAuthTestingOnly",
            authDomain: "pixeloffice-hub.firebaseapp.com",
            projectId: "pixeloffice-hub",
            storageBucket: "pixeloffice-hub.appspot.com",
            messagingSenderId: "1234567890",
            appId: "1:1234567890:web:abcdef123456"
        };
        if (!firebase.apps.length) {
            firebase.initializeApp(firebaseConfig);
        }
        const auth = firebase.auth();
        const googleProvider = new firebase.auth.GoogleAuthProvider();

        const WIDGET_SLUG = "gradient-pattern-contrast-analyzer";
        const ANALYSES_LIMIT = 3;
        const STRIPE_AMOUNT = 199; // $1.99 in cents
        const WHATSAPP_NUMBER = "420607450436";
        const API_BASE_URL = "https://api.pixeloffice.eu/api/pay";

        let i18n = {};
        let currentLang = 'en';
        let isUnlocked = false;
        let anal
// ... and more multi-language translations
Enter fullscreen mode Exit fullscreen mode

Jan's work ensured that the tool can accurately identify problematic areas regardless of background complexity.

Klára: User-Centric Design

While Jan focused on the logic, our AI designer Klára concentrated on the user experience. It was crucial for the tool to be intuitive and provide clear visual feedback. Klára designed an interface where users can easily upload images, define gradients, and visually place text. Most importantly, she focused on results display: heatmaps that clearly mark areas where contrast fails, and suggestions for color adjustments.

Martin: The Quality Guardian

Our AI QA engineer Martin meticulously tested the tool across various scenarios. He examined complex gradients, text on highly detailed photos, and diverse color combinations. His testing identified and helped eliminate edge cases that could lead to inaccurate results, thereby ensuring the tool's reliability.

Tomáš: Secure Deployment

Once all components were ready and tested, our AI DevOps engineer Tomáš ensured the secure and efficient deployment of the application. His work is crucial for smooth operation, scalability, and availability for all users.

How Our Tool Works

  1. Input: Upload an image, define a CSS gradient, or paste a design element as a background.
  2. Add Foreground: Place text or a UI component you wish to analyze.
  3. Analyze: The tool performs pixel-level contrast analysis beneath each character or UI element.
  4. Results: Get an instant Pass/Fail summary according to WCAG 2.x standards (AA or AAA).

Free vs. Premium

  • Free: Get 3 basic analyses with a pass/fail summary.
  • Premium ($1.99 one-time): Get lifetime access to unlimited detailed analyses, interactive visual heatmaps of contrast issues, exportable reports (PDF, JSON) with specific failure points, and advanced color picking and adjustment tools for rectifying issues.

We are thrilled to provide this tool to the web development and design community. We believe it will help create a more accessible and inclusive web.

Try our Gradient & Pattern Accessibility Contrast Analyzer today at https://pixeloffice.eu/showcase/gradient-pattern-contrast-analyzer/.

Top comments (0)