Java Color Encode encode(Color c)

Here you can find the source of encode(Color c)

Description

encode

License

Open Source License

Declaration

public static String encode(Color c) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Color;

public class Main {
    public static String encode(Color c) {
        return "#" + hex(c.getAlpha(), 2) + hex(c.getRed(), 2) + hex(c.getGreen(), 2) + hex(c.getBlue(), 2);
    }//w ww .j a  v  a  2  s.co  m

    public static String hex(int i, int places) {
        String s = Integer.toHexString(i);
        while (s.length() < places)
            s = "0" + s;
        return s;
    }
}

Related

  1. encode(Color color)
  2. encode(Color color)
  3. encode(Color color)
  4. encode(Color color)