package com.example.cloudmusic;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;
import androidx.palette.graphics.Palette;

public class TextColor extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.text_color);
        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.text2);
        Palette palette = Palette.from(bitmap).generate();
    //    int dominantColor = palette.getDominantColor(Color.TRANSPARENT);
        System.out.println("hello world");

        int vibrantColor = palette.getVibrantColor(0xFF000000);
        int vibrantDarkColor = palette.getDarkVibrantColor(0xFF000000);
        int vibrantLightColor = palette.getLightVibrantColor(0xFF000000);
        int mutedColor = palette.getMutedColor(0xFF000000);
        int mutedDarkColor = palette.getDarkMutedColor(0xFF000000);
        int mutedLightColor = palette.getLightMutedColor(0xFF000000);

        GradientDrawable gradientDrawable = new GradientDrawable(
                GradientDrawable.Orientation.TR_BL,
                new int[]{mutedColor ,vibrantDarkColor,vibrantColor}
        );
        findViewById(R.id.text_back).setBackground(gradientDrawable);

    }





    //   String colorInfo = " 鲜艳颜色： #" + Integer.toHexString(vibrantColor) +
//        " 深艳颜色： #" + Integer.toHexString(vibrantDarkColor) +
//
//        " 浅艳颜色： #" + Integer.toHexString(vibrantLightColor) +
//
//        " 柔和颜色： #" + Integer.toHexString(mutedColor) +
//
//        " 深柔颜色： #" + Integer.toHexString(mutedDarkColor) +
//
//        " 浅柔颜色： #" + Integer.toHexString(mutedLightColor);
//        System.out.println(colorInfo);
//        Log.d("TAG", "onCreate: "+colorInfo);
}
