Git Product home page Git Product logo

colorpicker's Introduction

通过RGB获取色值

之前写的10进制转换16进制:

private String tenToSixteen(EditText et) {
		if ("".equals(et.getText().toString().trim())) {
			et.startAnimation(mAnimation);
			return "error";
		}
		int value = Integer.parseInt(et.getText().toString().trim());
		String result = "";
		if (value < 0 || value > 255) {
			et.startAnimation(mAnimation);
			return "error";
		} else {
			if (value == 0) {
				return "00";
			} else {
				int first = value / 16;
				int last = 0;
				if (first == 0) {// value<16
					if (value > 0 && value < 10) {
						result = "0" + value;
					} else if (value > 9) {
						result = "0" + numToLetter(value);
					}
				} else {// value>=16
					last = value - first * 16;
					if (last == 0) {// value=16n
						if (first > 0 && first < 10) {
							result = first + "0";
						} else if (first > 9) {
							result = numToLetter(first) + "0";
						}
						return result;
					} else {
						if (first > 0 && first < 10) {
							if (last > 0 && last < 10) {
								result = first + "" + last;
							} else if (last > 9) {
								result = first + numToLetter(last);
							}
						} else if (first > 9) {
							if (last > 0 && last < 10) {
								result = numToLetter(first) + "" + last;
							} else if (last > 9) {
								result = numToLetter(first) + numToLetter(last);
							}
						}
					}
				}
			}
		}
		return result;
	}

	private String numToLetter(int num) {
		return String.valueOf((char) ('a' + (num - 10)));
	}

后来看了别人的代码,才发现:

	String resultStr = String.format("#%02x%02x%02x", mList.get(0).getProgress(), mList.get(1).getProgress(), mList.get(2).getProgress());

原来还可以这样!!!

然后顺便扒一下人家的图...

2015-02-27 5 38 00

多谢:

https://github.com/4k3R/material-color-picker

😊

colorpicker's People

Contributors

lvliheng avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.