List of usage examples for android.graphics Color HSVToColor
@ColorInt public static int HSVToColor(@IntRange(from = 0, to = 255) int alpha, @Size(3) float hsv[])
From source file:com.google.appinventor.components.runtime.GoogleMap.java
/** * * @param lat Latitude of the center of the circle * @param lng Longitude of the center of the circle * @param radius Radius of the circle//from www.ja v a2s . c o m * @param alpha Alpha value of the color of the circle overlay * @param hue Hue value of the color of the circle overaly * @param strokeWidth Width of the perimeter * @param strokeColor Color of the perimeter */ @SimpleFunction(description = "Create a circle overlay on the map UI with specified latitude and longitude for center. " + "\"hue\" (min 0, max 360) and \"alpha\" (min 0, max 255) are used to set color and transparency level of the circle, " + "\"strokeWidth\" and \"strokeColor\" are for the perimeter of the circle. " + "Returning a unique id of the circle for future reference to events raised by moving this circle. If the circle is" + "set to be draggable, two default markers will appear on the map: one in the center of the circle, another on the perimeter.") public int AddCircle(double lat, double lng, double radius, int alpha, float hue, float strokeWidth, int strokeColor, boolean draggable) { int uid = generateCircleId(); int fillColor = Color.HSVToColor(alpha, new float[] { hue, 1, 1 }); if (draggable) { //create a draggableCircle DraggableCircle circle = new DraggableCircle(new LatLng(lat, lng), radius, strokeWidth, strokeColor, fillColor); mCircles.add(circle); circles.put(circle, uid); } else { Circle plainCircle = mMap.addCircle(new CircleOptions().center(new LatLng(lat, lng)).radius(radius) .strokeWidth(strokeWidth).strokeColor(strokeColor).fillColor(fillColor)); circles.put(plainCircle, uid); } return uid; }
From source file:io.jawg.osmcontributor.ui.utils.BitmapHandler.java
public static Bitmap hue(Bitmap bitmap, float hue) { Bitmap newBitmap = bitmap.copy(bitmap.getConfig(), true); final int width = newBitmap.getWidth(); final int height = newBitmap.getHeight(); float[] hsv = 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, hsv); hsv[0] = hue;//from ww w. j av a 2 s .co m newBitmap.setPixel(x, y, Color.HSVToColor(Color.alpha(pixel), hsv)); } } return newBitmap; }
From source file:info.tellmetime.TellmetimeActivity.java
/** * Handles changing highlight color via #mSeekBarHighlight. * * @param value indicates exact offset in gradient (SeekBar's max value is equal to #mRainbow width). *//*from w w w. j a v a2s.co m*/ @Override public void onProgressChanged(SeekBar seekBar, int value, boolean fromUser) { switch (seekBar.getId()) { case R.id.highlightValue: mHighlightColor = mRainbow.getPixel(value, 0); if (((RadioButton) findViewById(R.id.radio_backlight_highlight)).isChecked()) { float[] highlightHSV = new float[3]; Color.colorToHSV(mHighlightColor, highlightHSV); mBacklightColor = Color.HSVToColor(33, highlightHSV); } if (fromUser) mHighlightPosition = (float) value / seekBar.getMax(); mClockAlgorithm.tickTock(); break; case R.id.minutesSize: mMinutesSize = value; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { FrameLayout minutesIndicators = (FrameLayout) findViewById(R.id.minutes_indicators); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) minutesIndicators .getLayoutParams(); params.topMargin = (int) -TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize / 3, getResources().getDisplayMetrics()); minutesIndicators.setLayoutParams(params); } ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots); for (int i = 0; i < minutesDots.getChildCount(); i++) { TextView m = (TextView) minutesDots.getChildAt(i); m.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize); } break; } mHider.delayedHide(4000); }
From source file:com.google.appinventor.components.runtime.GoogleMap.java
@SimpleFunction(description = "Set the property of an existing circle. Properties include: " + "\"alpha\"(number, value ranging from 0~255), \"color\" (nimber, hue value ranging 0~360), " + "\"radius\"(number in meters)") public void UpdateCircle(int circleId, String propertyName, Object value) { Log.i(TAG, "inputs: " + circleId + "," + propertyName + ", " + value); float[] hsv = new float[3]; Object circle = getCircleIfExisted(circleId); // if it's null, getCircleIfExisted will show error msg Circle updateCircle = null; // the real circle content that gets updated if (circle != null) { if (circle instanceof DraggableCircle) { updateCircle = ((DraggableCircle) circle).getCircle(); }/*from w w w. j a v a2s.c o m*/ if (circle instanceof Circle) { updateCircle = (Circle) circle; } try { Float val = Float.parseFloat(value.toString()); if (propertyName.equals("alpha")) { int color = updateCircle.getFillColor(); Color.colorToHSV(color, hsv); Integer alphaVal = val.intValue(); //Color.HSVToColor(mAlpha, new float[] {mColorHue, 1, 1});//default to red, medium level hue color int newColor = Color.HSVToColor(alphaVal, hsv); updateCircle.setFillColor(newColor); } if (propertyName.equals("color")) { int alpha = Color.alpha(updateCircle.getFillColor()); int newColor = Color.HSVToColor(alpha, new float[] { val, 1, 1 }); updateCircle.setFillColor(newColor); } if (propertyName.equals("radius")) { // need to cast value to float Float radius = val; updateCircle.setRadius(radius); // if it's a draggableCircle, then we need to remove the previous marker and get new radius marker if (circle instanceof DraggableCircle) { // remove previous radius marker Marker centerMarker = ((DraggableCircle) circle).getCenterMarker(); Marker oldMarker = ((DraggableCircle) circle).getRadiusMarker(); oldMarker.remove(); Marker newMarker = mMap.addMarker(new MarkerOptions() .position(toRadiusLatLng(centerMarker.getPosition(), radius)).draggable(true) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))); ((DraggableCircle) circle).setRadiusMarker(newMarker); // create a new draggabble circle } } } catch (NumberFormatException e) { //can't parse the string form.dispatchErrorOccurredEvent(this, "UpdateCircle", ErrorMessages.ERROR_GOOGLE_MAP_INVALID_INPUT, value.toString()); } } else { // the circle doesn't exist form.dispatchErrorOccurredEvent(this, "UpdateCircle", ErrorMessages.ERROR_GOOGLE_MAP_CIRCLE_NOT_EXIST, circleId); } }
From source file:info.tellmetime.TellmetimeActivity.java
public void onBacklightRadioClick(View view) { boolean isChecked = ((RadioButton) view).isChecked(); switch (view.getId()) { case R.id.radio_backlight_light: if (isChecked) mBacklightColor = mBacklightLight; break;/*from w w w .j a v a 2s .c o m*/ case R.id.radio_backlight_dark: if (isChecked) mBacklightColor = mBacklightDark; break; case R.id.radio_backlight_highlight: if (isChecked) { float[] highlightHSV = new float[3]; Color.colorToHSV(mHighlightColor, highlightHSV); mBacklightColor = Color.HSVToColor(33, highlightHSV); } break; } mClockAlgorithm.tickTock(); mHider.delayedHide(4000); }
From source file:org.mariotaku.twidere.activity.ComposeActivity.java
@Override public boolean onPrepareOptionsMenu(final Menu menu) { if (menu == null || mEditText == null || mTextCount == null) return false; final String text_orig = parseString(mEditText.getText()); final String text = mIsPhotoAttached || mIsImageAttached ? mUploadUseExtension ? getImageUploadStatus(this, FAKE_IMAGE_LINK, text_orig) : text_orig + " " + FAKE_IMAGE_LINK : text_orig;/*from www.ja va 2 s. com*/ final int count = mValidator.getTweetLength(text); final float hue = count < Validator.MAX_TWEET_LENGTH ? count >= Validator.MAX_TWEET_LENGTH - 10 ? 5 * (Validator.MAX_TWEET_LENGTH - count) : 50 : 0; final float[] hsv = new float[] { hue, 1.0f, 1.0f }; mTextCount .setTextColor(count >= Validator.MAX_TWEET_LENGTH - 10 ? Color.HSVToColor(0x80, hsv) : 0x80808080); mTextCount.setText(parseString(Validator.MAX_TWEET_LENGTH - count)); final MenuItem sendItem = menu.findItem(MENU_SEND); if (sendItem != null) { sendItem.setEnabled(text_orig.length() > 0); } return super.onPrepareOptionsMenu(menu); }
From source file:com.mjhram.ttaxi.GpsMainActivity.java
@EventBusHook public void onEventMainThread(ServiceEvents.updateDrivers updateDriversEvent) { tracer.debug("updating nearby driver"); double[] drvLat = updateDriversEvent.drvLat; double[] drvLong = updateDriversEvent.drvLong; double lat_dw = updateDriversEvent.lat_d; double lng_dw = updateDriversEvent.lng_d; Location loc = updateDriversEvent.location; LatLng center = new LatLng(loc.getLatitude(), loc.getLongitude()); //double radiusInMeters = Utilities.toRadiusMeters(new LatLng(0.0, 0.0), new LatLng(radius, radius)); //1. remove previous markers clearDriversMarkers();//from w w w .jav a 2 s.c o m //2.a add scan circle int circleStrokeWidth = 3; int mStrokeColor = Color.BLACK; int mFillColor1 = 20; int mAlpha = 20; int mFillColor = Color.HSVToColor(mAlpha, new float[] { mFillColor1, 1, 1 }); /*CircleOptions opt = new CircleOptions() .center(center) .radius(radiusInMeters) .strokeWidth(circleStrokeWidth) .strokeColor(mStrokeColor) .fillColor(mFillColor); mapsSearchCircle = googleMap.addCircle(opt);*/ //Polygon [or rectangle] PolygonOptions options = new PolygonOptions().addAll(Utilities.createRectangle(center, lat_dw, lng_dw)); searchPolygon = googleMap .addPolygon(options.strokeWidth(circleStrokeWidth).strokeColor(Color.BLACK).fillColor(mFillColor)); //2.b add new markers countOfDrivers = updateDriversEvent.drvCount; nearbyDrivers = new Marker[countOfDrivers]; for (int i = 0; i < updateDriversEvent.drvCount; i++) { LatLng driverPosition = new LatLng(drvLat[i], drvLong[i]); MarkerOptions markerOptions = new MarkerOptions().position(driverPosition) .icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi)).anchor(0.5f, 0.5f).draggable(true); ; nearbyDrivers[i] = googleMap.addMarker(markerOptions); } }
From source file:com.t2.compassionMeditation.Graphs1Activity.java
/** * Returns a unique key color based on the current index and total count of parameters * @param currentIndex Index of current parameter * @param totalCount Total number of parameters * @return Unique color based in inputs *///from ww w .j a v a2 s. c om protected int getKeyColor(int currentIndex, int totalCount) { float hue = currentIndex / (1.00f * totalCount) * 360.00f; return Color.HSVToColor(255, new float[] { hue, 1.0f, 1.0f }); }
From source file:com.dwdesign.tweetings.activity.ComposeActivity.java
@Override public boolean onPrepareOptionsMenu(final Menu menu) { if (menu == null || mEditText == null || mTextCount == null) return false; final String text_orig = parseString(mEditText.getText()); final String text = mIsPhotoAttached || mIsImageAttached ? mUploadUseExtension ? getImageUploadStatus(this, FAKE_IMAGE_LINK, text_orig) : text_orig + " " + FAKE_IMAGE_LINK : text_orig;//from www . j av a2 s .c o m final int count = mValidator.getTweetLength(text); final float hue = count < 140 ? count >= 130 ? 5 * (140 - count) : 50 : 0; final float[] hsv = new float[] { hue, 1.0f, 1.0f }; mTextCount.setTextColor(count >= 130 ? Color.HSVToColor(0x80, hsv) : 0x80808080); mTextCount.setText(parseString(140 - count)); final MenuItem sendItem = menu.findItem(MENU_SEND); if (sendItem != null) { sendItem.setEnabled(text_orig.length() > 0); } return super.onPrepareOptionsMenu(menu); }