26 Şubat 2018 Pazartesi

Color Sınıfı

Giriş
Şu satırı dahil ederiz.
import android.graphics.Color;
argb metodu
Şöyle yaparız. alpha rengin ne kadar mat (opak) olduğunu belirtir.
Color.argb(255, 255, 255, 255)
FF yüzde yüz mat demektir.
100%  FF
95%  F2
90%  E6
85%  D9
80%  CC
75%  BF
70%  B3
65%  A6
60%  99
55%  8C
50%  80
45%  73
40%  66
35%  59
30%  4D
25%  40
20%  33
15%  26
10%  1A
5%  0D
0%  00
BLACK alanı
Şöyle yaparız.
Color.BLACK ; Color.WHITE;
blue metodu
Şöyle yaparız.
int color = ...;
int b = Color.blue(color)
colorToHSV metodu
Şöyle yaparız. RGB'den HSV renk uzayına geçisi sağlar.
/**
 * @param bitmap which bitmap to convert
 * @param hue any value from 0 to 360.
 * @return bitmap with new hue values
 */
public Bitmap setHue(Bitmap bitmap, float hue){
    Bitmap newBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
    int width = newBitmap.getWidth();
    int height = newBitmap.getHeight();
    float [] hvs = new float[3];

    for(int y = 0; y < height; y++){
        for(int x = 0; x < width; x++){
            int pixel = newBitmap.getPixel(x,y);
            Color.colorToHSV(pixel,hvs);
            hvs[0] = hue;
            newBitmap.setPixel(x,y,Color.HSVToColor(Color.alpha(pixel),hvs));
        }
    }
    return newBitmap;
}
green metodu
Şöyle yaparız.
int color = ...;
int g = Color.green(color)
parseColor metodu
Açıklaması şöyle
Supported formats are: #RRGGBB #AARRGGBB or one of the following names: 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray', 'grey', 'lightgrey', 'darkgrey', 'aqua', 'fuchsia', 'lime', 'maroon', 'navy', 'olive', 'purple', 'silver', 'teal'.
Şöyle yaparız.
Color.parseColor("#1AFFFFFF")
Şöyle yaparız.
String name = "yellow";
Color.parseColor(name);
red metodu
Şöyle yaparız.
int color = ...;
int r = Color.red(color)
rgb metodu
Şöyle yaparız.
int d = 0;
int color = Color.rgb(d, d, d);
setAlpha metodu
Şöyle yaparız.
textView.getBackground().setAlpha(51);
TRANSPARENT Alanı
Şöyle yaparız.


int color = Color.TRANSPARENT;

Hiç yorum yok:

Yorum Gönder