This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GIMP Palette | |
Name: RGB 15 | |
Columns: 0 | |
# URL: https://community.aseprite.org/t/how-or-where-can-i-get-a-gba-color/22207 | |
# Colors: 32768 | |
0 0 0 000000 | |
8 0 0 080000 | |
16 0 0 100000 | |
25 0 0 190000 | |
33 0 0 210000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static Vector4 LinearToXyz (in Color c) | |
{ | |
// This could also be written as matrix-vector multiplication. | |
// Perceptual luminance is the y component. | |
return new Vector4 ( | |
0.41241086f * c.r + 0.35758457f * c.g + 0.1804538f * c.b, | |
0.21264935f * c.r + 0.71516913f * c.g + 0.07218152f * c.b, | |
0.019331759f * c.r + 0.11919486f * c.g + 0.95039004f * c.b, | |
c.a); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
byte[ ] stlLut = new byte[256]; | |
byte[ ] ltsLut = new byte[256]; | |
for (int i = 0; i < 256; ++i) | |
{ | |
float x = i / 255.0f; | |
float y = StandardToLinearChannel (x); | |
stlLut[i] = (byte) (0.5f + 255.0f * y); | |
float z = LinearToStandardChannel (x); | |
ltsLut[i] = (byte) (0.5f + 255.0f * z); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
[RequireComponent (typeof (SpriteRenderer))] | |
public class Grayscale : MonoBehaviour | |
{ | |
void Start ( ) | |
{ | |
SpriteRenderer renderer = GetComponent<SpriteRenderer> ( ); | |
Sprite sprite = renderer.sprite; | |
Texture2D srcTexture = sprite.texture; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static float StandardToLinearChannel (in float x) | |
{ | |
return x > 0.04045f ? | |
Mathf.Pow ((x + 0.055f) / 1.055f, 2.4f) : | |
x / 12.92f; | |
} | |
static float LinearToStandardChannel (in float x) | |
{ | |
return x > 0.0031308f ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static float GrayLumIncorrect (in Color srgb) | |
{ | |
return 0.21264935f * srgb.r + 0.71516913f * srgb.g + 0.07218152f * srgb.b; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static float GrayHsl (in Color c) | |
{ | |
return 0.5f * (Mathf.Max (c.r, c.g, c.b) + | |
Mathf.Min (c.r, c.g, c.b)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static float GrayHsv (in Color c) | |
{ | |
return Mathf.Max (c.r, c.g, c.b); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static float GrayAverage (in Color c) | |
{ | |
return (c.r + c.g + c.b) / 3.0f; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dofile("./sRgbToAdobeRgb.lua") | |
local dlg = Dialog { title = "SRGB - Adobe Convert" } | |
dlg:button { | |
id = "palAdobeToSrgb", | |
text = "Pal &Adobe to sRGB", | |
onclick = function() | |
local sprite = app.activeSprite | |
if sprite then |
NewerOlder