Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1>
  Black Ops4 Color Mixer Fix
</h1>
<h2>
  <a href="https://twitter.com/SexualRhino_/status/1050686310262788096" target="blank">What's the problem with in game color mixer?</a>
</h2>

<div id="app">
  <p> The color you want:</p>
  R:<input v-model.number='r' type="number" class="num r" max=255 min=0 v-on:change="cal"> G:
  <input v-model.number='g' type="number" class="num g" max=255 min=0 v-on:change="cal"> B:
  <input v-model.number='b' type="number" class="num b" max=255 min=0 v-on:change="cal">
  <div class="preview" v-bind:style="{background: `rgba(${r},${g},${b})` }">

  </div>

  <div class="result">RGB value you should input in BO4:<span class="rgb">R: {{rr}}  G:{{rg}} B:{{rb}}</span> </div>

</div>
              
            
!

CSS

              
                body {
  background: #20262e;
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
}

.result {
  margin-top: 20px;
}

.num {
  margin-left: 10px;
  margin-right: 10px;
}

.rgb {
  padding-left: 20px;
  font-weight: bold;
  font-size: 30px;
}

h1 {
  color: white;
  margin-bottom: 20px;
  font-size: 20px;
  font-size: 40px;
}
h2,
a {
  color: white;
  margin-bottom: 30px;
}

.preview {
  border: 1px solid black;
  width: 100px;
  height: 30px;
  display: inline-block;
  vertical-align: middle;
}

              
            
!

JS

              
                const table = [0, 55, 79, 96, 110, 122, 132, 143, 152, 160, 168, 175, 182, 188, 195, 201, 207, 213, 219, 224, 228, 234, 238, 243, 247, 252];

const convert = function(input) {
	if(input>255) input = 255;
  if(input<0) input = 0;
  var closest = table.reduce(function(prev, curr) {
    return (Math.abs(curr - input) < Math.abs(prev - input) ? curr : prev);
  });
  var index = table.indexOf(closest);
  var ingame = index * 10;
  var next = index + 1  > 25 ? 255: table[index+1];
  var prev = index - 1 < 0 ? 0 : table[index-1];
  if (input>= closest){
 	  var diff = next - closest;
    var diff2 = input - closest;
    var adj = Math.round(diff2/diff*(next===255? 5: 10));
    ingame = ingame + adj;
  } else {
   	var diff = closest - prev;
    var diff2 = closest - input;
    var adj = Math.round(diff2/diff*10)
    ingame = ingame - adj;
  }
  return ingame;
};

new Vue({
  el: "#app",
  data: function(){ return {
    r:0,
    g:0,
    b:0,
    rr:0,
    rg:0,
    rb:0,
  }},
  methods: {
  	cal: function(){
    	this.rr = convert(this.r);
          	this.rg = convert(this.g);
                	this.rb = convert(this.b);
    }
  }
})
              
            
!
999px

Console