Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › C# Programming › C# Simple Gradient Class

C# Simple Gradient Class

Posts 1–2 of 2 · Page 1 of 1
Zaczero
Zaczero
C# Simple Gradient Class

Example usage:
Code:
using Zaczero;
(..)

var gradient = new Gradient();

gradient.Add(new GradientColor(0.0, "#ED4264"));
gradient.Add(new GradientColor(0.4, "#4286fF"));
gradient.Add(new GradientColor(1.0, "#FFEDBC"));

var coolColor = gradient.Calculate(0.65);
OFFSET RANGE: (double) 0.000 - 1.000


Source code:
Code:
using System;
using System.Collections.Generic;
using System.Globalization;

namespace Zaczero
{
    public struct GradientColor : IComparable<GradientColor>
    {
        public double Offset;

        public double R;
        public double G;
        public double B;
        public double A;

        public GradientColor(double offset, double r, double g, double b, double a)
        {
            Offset = offset;

            R = r;
            G = g;
            B = b;
            A = a;
        }

        public GradientColor(double offset, double r, double g, double b)
        {
            Offset = offset;

            R = r;
            G = g;
            B = b;
            A = 1d;
        }

        public GradientColor(double offset, string code)
        {
            const string invalidColorCode = "Invalid color code";

            Offset = offset;

            code = code.TrimStart('#');

            foreach (var c in code)
            {
                if (!char.IsLetterOrDigit(c))
                {
                    throw new ArgumentException(invalidColorCode);
                }
            }

            if (code.Length == 6)
            {
                code += "FF";
            }

            if (code.Length == 8)
            {
                var r = code.Substring(0, 2);
                var g = code.Substring(2, 2);
                var b = code.Substring(4, 2);
                var a = code.Substring(6, 2);

                R = byte.Parse(r, NumberStyles.HexNumber) / 255d;
                G = byte.Parse(g, NumberStyles.HexNumber) / 255d;
                B = byte.Parse(b, NumberStyles.HexNumber) / 255d;
                A = byte.Parse(a, NumberStyles.HexNumber) / 255d;
            }
            else
            {
                throw new ArgumentException(invalidColorCode);
            }
        }

        public int CompareTo(GradientColor other)
        {
            return Offse*****mpareTo(other.Offset);
        }
    }

    public class Gradient
    {
        private readonly List<GradientColor> _colors;

        public Gradient()
        {
            _colors = new List<GradientColor>();
        }

        public void Add(GradientColor color)
        {
            _colors.Add(color);
            _colors.Sort();
        }

        public GradientColor Calculate(double offset)
        {
            var colorStart = default(GradientColor);
            var colorEnd = default(GradientColor);

            for (var i = 1; i < _colors.Count; i++)
            {
                if (_colors[i].Offset > offset)
                {
                    colorStart = _colors[i - 1];
                    colorEnd = _colors[i];
                    break;
                }
            }

            var offsetRange = colorEnd.Offset - colorStart.Offset;

            var offsetPercentage = (offset - colorStart.Offset) / offsetRange;
            var offsetPercentageInv = 1 - offsetPercentage;

            return new GradientColor(offset,
                colorStart.R * offsetPercentageInv + colorEnd.R * offsetPercentage,
                colorStart.G * offsetPercentageInv + colorEnd.G * offsetPercentage,
                colorStart.B * offsetPercentageInv + colorEnd.B * offsetPercentage,
                colorStart.A * offsetPercentageInv + colorEnd.A * offsetPercentage);
        }
    }
}

 
SECRET
That gradient on my thread got generated using this class
#1 · 9y ago
KM
KMWTW
Nice release! I hope it will be rly useful <3
#2 · 9y ago
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

  • [Source]Simple menu classBy Void in C++/C Programming
    44Last post 15y ago
  • Simple random class with one time occurring random numbers!By Laslod in C# Programming
    4Last post 13y ago
  • Simple WeaponMgr ClassBy luizimloko in CrossFire Hack Coding / Programming / Source Code
    8Last post 13y ago
  • Simple MemoryMgr ClassBy CodeDemon in Combat Arms Hack Coding / Programming / Source Code
    21Last post 15y ago
  • A simple Hooking classBy 258456 in CrossFire Hack Coding / Programming / Source Code
    13Last post 14y ago

Tags for this Thread

#class#create#generator#gradient#source code#tutorial#zaczero