# Default alpha to 1 for Color4.FromHexString

**URL:** <https://forum.babylonjs.com/t/default-alpha-to-1-for-color4-fromhexstring/25226>\
**Category:** Feature requests\
**Created:** [November 12, 2021, 6:27pm UTC](https://forum.babylonjs.com/t/default-alpha-to-1-for-color4-fromhexstring/25226 "2021-11-12T18:27:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [November 12, 2021, 6:27pm UTC](https://forum.babylonjs.com/t/default-alpha-to-1-for-color4-fromhexstring/25226/1 "2021-11-12T18:27:51Z")

</div>

Heya, I was wondering if Color4.FromHexString could default alpha to 1 instead of 0?

The issue is that most of the hex codes from color tables on the web, etc. don’t have an extra two characters for the alpha…

So it can be tedious to copy and paste the hex code and then have to remember to add the extra ff at the end and again each time after copying and pasting a new hex string over the existing one to try out different colors, for example…

Let me know if it would be good to do and I’ll make a little PR for it. 🙂

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [November 12, 2021, 6:48pm UTC](https://forum.babylonjs.com/t/default-alpha-to-1-for-color4-fromhexstring/25226/2 "2021-11-12T18:48:18Z")

</div>

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/1/018d8bd2fb07780da5cb4ed361e5300f2ad1620d.jpeg)

It is, however, a breaking change. And needs to be documented in the breaking changes section of what’s new.

Having said that - what’s wrong with using the Color3.FromHexString in that case? Would make more sense in terms of color conversion

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [November 12, 2021, 7:03pm UTC](https://forum.babylonjs.com/t/default-alpha-to-1-for-color4-fromhexstring/25226/3 "2021-11-12T19:03:04Z")

</div>

For instance when setting the face colors using MeshBuilder.Create functions, a Color4 is needed, same with the scene’s clear color, so converting with Color4.FromHexString() without having to add ff to the end of it would be more convenient here I think, especially when copying and pasting the hex strings from color tables and other tools on the web.

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [November 12, 2021, 9:43pm UTC](https://forum.babylonjs.com/t/default-alpha-to-1-for-color4-fromhexstring/25226/4 "2021-11-12T21:43:34Z")

</div>

Here’s a little PR for it, with a note in the breaking changes section. 🙂

> <https://github.com/BabylonJS/Babylon.js/pull/11456>
>
> Patch to default alpha to 1 when a 7 char hex string is passed to Color4.FromHex…String, to allow standard hex strings to be copied and pasted from color table websites, etc., more conveniently without having to add "ff" to the string each time.
> When an empty or invalid string is passed, all 4 components still default to 0, in keeping with the original behavior.
> Forum posts with more info on the use case for this are here: https://forum.babylonjs.com/t/default-alpha-to-1-for-color4-fromhexstring/25226/3
