npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

csgo-fade-percentage-calculator

v1.1.6

Published

Calculate the Fade percentage of a CS2 skin using its paint seed.

Downloads

2,102

Readme

CS2 Fade Percentage Calculator

NPM Version NPM Bundle Size NPM Downloads GitHub License GitHub Test Workflow Status GitHub Build Workflow Status

Calculate the Fade percentage value of a CS2 skin based on a given seed value. Supporting all Fade skins (except for gloves), Amber Fade skins, and Acid Fade skins. Easily convert every paint seed (also called pattern index) into a fade percentage value, or get a full list of all paint seeds and the corresponding fade percentages.

🚀 Installation

In order to install the latest package version from NPM, simply run:

npm install csgo-fade-percentage-calculator

🛠 Usage

There are three modules which all share the same four methods as shown in the examples below:

const {
  FadeCalculator,
  AmberFadeCalculator,
  AcidFadeCalculator,
} = require('csgo-fade-percentage-calculator');

// Get a list of all Fade percentages for all available weapons.
const allFadePercentages = FadeCalculator.getAllFadePercentages();

// Get a list of Amber Fade percentages for the P2000.
const p2000AmberFadePercentages = AmberFadeCalculator.getFadePercentages('P2000');

// Get the Acid Fade percentage for the SSG 08 and the seed 123.
const ssgAcidFadePercentage = AcidFadeCalculator.getFadePercentage('SSG 08', 123);

// Get all supported Fade weapons.
const supportedWeapons = FadeCalculator.getSupportedWeapons();

📜 How It Works

Each CS2 weapon skin has a random paint seed value between 0 and 1000. This paint seed value, sometimes also called pattern index, determines the positioning of the pattern on the gun. Specifically, the paint seed determines the X offset, Y offset, and rotation value for the pattern position. Those three values can be calculated using an algorithm that has been open-sourced by Valve.

Luckily, most Fade skins have the same X and Y offsets, and only the rotation value changes with each paint seed. This package simply converts paint seeds to rotation values and then assigns each rotation value a fade percentage between 80% and 100%, where the best rotation value is a 100% Fade, and the worst rotation value is an 80% Fade.

The whole process just involves simple math, and it is superior to alternative methods such as image pixel color analysis for various reasons:

  • The resulting Fade percentage values are much more accurate
  • The methodology can be easily verified and reproduced
  • The algorithm is simple and fast

🌎 Platform Support

Most platforms that support fade percentages use the open-source algorithm implemented by this package to generate their fade values. The sites below all share the same fade percentage values, which can also be generated by this package:

Other sites are currently known to use their own algorithms, probably based on image analysis. These sites come to different conclusions about which paint seed corresponds to which fade value, as pixel color analysis is not very accurate for determining a fade value:

💻 Other Programming Languages

Are you not using Node, JavaScript, or TypeScript for your project? We have a pre-generated JSON file for you that contains the fade percentages of all supported weapons. You can download it with any programming language into your project to store and process the values there.

Alternatively, feel free to check out the source code of this library and port it into your preferred language.

❓ Frequently Asked Questions

How accurate are the generated fade percentages?

The generated fade percentage values are basically as accurate as they can get. Fade percentages don't really exist in CS2 itself, it's a community-driven value that has been historically computed through image analysis of screenshots. However, this method is not very accurate as it depends on many presumptions of the used algorithm. This library just reverses the algorithm that Valve uses internally to apply the pattern on the weapon, and our only presumption is a fade percentage range between 80% and 100%, with 80% being the worst and 100% being the best value.

Why do some websites display different fade percentages?

Some websites may use different algorithms to calculate fade percentages, often based on pixel color analysis of screenshot images. Those algorithms can come to very different conclusions about what seed value corresponds to which fade percentage. Hopefully, the community will shift from image analysis to the open-source algorithm used by this library, creating a stronger consensus.

Why are gloves not supported?

Glove skins are handled differently in CS2. The method used by this library to compute fade values does not work for glove skins, because their patterns shift more unpredictably, similar to Case Hardened skins.

⭐ Credits

A big thanks goes to Step7750, the work on this library was inspired by his research about CS2 paint seeds. He also implemented Valve's uniform random number generator in Go, which was ported to TypeScript for this project.