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.example.mapdemo.PolygonDemoActivity.java
private void setUpMap() { // Create a rectangle with two rectangular holes. mMap.addPolygon(new PolygonOptions().addAll(createRectangle(new LatLng(-20, 130), 5, 5)) .addHole(createRectangle(new LatLng(-22, 128), 1, 1)) .addHole(createRectangle(new LatLng(-18, 133), 0.5, 1.5)).fillColor(Color.CYAN) .strokeColor(Color.BLUE).strokeWidth(5)); // Create a rectangle centered at Sydney. PolygonOptions options = new PolygonOptions().addAll(createRectangle(SYDNEY, 5, 8)); int fillColor = Color.HSVToColor(mAlphaBar.getProgress(), new float[] { mColorBar.getProgress(), 1, 1 }); mMutablePolygon = mMap.addPolygon(/* w w w.j a v a2 s . c o m*/ options.strokeWidth(mWidthBar.getProgress()).strokeColor(Color.BLACK).fillColor(fillColor)); mColorBar.setOnSeekBarChangeListener(this); mAlphaBar.setOnSeekBarChangeListener(this); mWidthBar.setOnSeekBarChangeListener(this); // Move the map so that it is centered on the mutable polygon. mMap.moveCamera(CameraUpdateFactory.newLatLng(SYDNEY)); }
From source file:curso.and17.PolygonDemoActivity.java
private void setUpMap() { // Create a rectangle with two rectangular holes. mMap.addPolygon(new PolygonOptions().addAll(createCWRectangle(new LatLng(-20, 130), 5, 5)) .addHole(createCWRectangle(new LatLng(-20, 130), 3, 3)).fillColor(Color.CYAN) .strokeColor(Color.BLUE).strokeWidth(5)); // Create an ellipse centered at Sydney. PolygonOptions options = new PolygonOptions(); int numPoints = 400; float semiHorizontalAxis = 10f; float semiVerticalAxis = 5f; double phase = 2 * Math.PI / numPoints; for (int i = 0; i <= numPoints; i++) { options.add(new LatLng(SYDNEY.latitude + semiVerticalAxis * Math.sin(i * phase), SYDNEY.longitude + semiHorizontalAxis * Math.cos(i * phase))); }//w w w. j a v a2 s .c o m int fillColor = Color.HSVToColor(mAlphaBar.getProgress(), new float[] { mColorBar.getProgress(), 1, 1 }); mMutablePolygon = mMap.addPolygon( options.strokeWidth(mWidthBar.getProgress()).strokeColor(Color.BLACK).fillColor(fillColor)); mColorBar.setOnSeekBarChangeListener(this); mAlphaBar.setOnSeekBarChangeListener(this); mWidthBar.setOnSeekBarChangeListener(this); // Move the map so that it is centered on the mutable polygon. mMap.moveCamera(CameraUpdateFactory.newLatLng(SYDNEY)); }
From source file:com.google.mcommerce.sample.android.chapter09.googleMap.PolygonDemoActivity.java
private void setUpMap() { // Create a rectangle with two rectangular holes. mMap.addPolygon(new PolygonOptions().addAll(createRectangle(new LatLng(-20, 130), 5, 5)) .addHole(createRectangle(new LatLng(-22, 128), 1, 1)) .addHole(createRectangle(new LatLng(-18, 133), 0.5, 1.5)).fillColor(Color.CYAN) .strokeColor(Color.BLUE).strokeWidth(5)); // Create an ellipse centered at Sydney. PolygonOptions options = new PolygonOptions(); int numPoints = 400; float semiHorizontalAxis = 10f; float semiVerticalAxis = 5f; double phase = 2 * Math.PI / numPoints; for (int i = 0; i <= numPoints; i++) { options.add(new LatLng(SYDNEY.latitude + semiVerticalAxis * Math.sin(i * phase), SYDNEY.longitude + semiHorizontalAxis * Math.cos(i * phase))); }/* w ww .ja va2 s. c om*/ int fillColor = Color.HSVToColor(mAlphaBar.getProgress(), new float[] { mColorBar.getProgress(), 1, 1 }); mMutablePolygon = mMap.addPolygon( options.strokeWidth(mWidthBar.getProgress()).strokeColor(Color.BLACK).fillColor(fillColor)); mColorBar.setOnSeekBarChangeListener(this); mAlphaBar.setOnSeekBarChangeListener(this); mWidthBar.setOnSeekBarChangeListener(this); // Move the map so that it is centered on the mutable polygon. mMap.moveCamera(CameraUpdateFactory.newLatLng(SYDNEY)); }
From source file:com.cyrilmottier.android.polaris2demo.PolygonDemoActivity.java
private void setUpMap() { // Create a rectangle with two rectangular holes. mMap.addPolygon(new PolygonOptions().addAll(createCWRectangle(new LatLng(-20, 130), 5, 5)) .addHole(createCWRectangle(new LatLng(-22, 128), 1, 1)) .addHole(createCWRectangle(new LatLng(-18, 133), 0.5, 1.5)).fillColor(Color.CYAN) .strokeColor(Color.BLUE).strokeWidth(5)); // Create an ellipse centered at Sydney. PolygonOptions options = new PolygonOptions(); int numPoints = 400; float semiHorizontalAxis = 10f; float semiVerticalAxis = 5f; double phase = 2 * Math.PI / numPoints; for (int i = 0; i <= numPoints; i++) { options.add(new LatLng(SYDNEY.latitude + semiVerticalAxis * Math.sin(i * phase), SYDNEY.longitude + semiHorizontalAxis * Math.cos(i * phase))); }//from w ww . jav a 2s.c o m int fillColor = Color.HSVToColor(mAlphaBar.getProgress(), new float[] { mColorBar.getProgress(), 1, 1 }); mMutablePolygon = mMap.addPolygon( options.strokeWidth(mWidthBar.getProgress()).strokeColor(Color.BLACK).fillColor(fillColor)); mColorBar.setOnSeekBarChangeListener(this); mAlphaBar.setOnSeekBarChangeListener(this); mWidthBar.setOnSeekBarChangeListener(this); // Move the map so that it is centered on the mutable polygon. mMap.moveCamera(CameraUpdateFactory.newLatLng(SYDNEY)); }
From source file:com.cyrilmottier.android.polaris2demo.PolylineDemoActivity.java
private void setUpMap() { // A simple polyline with the default options wrap Melbourne-Adelaide-Perth. mMap.addPolyline((new PolylineOptions()).add(MELBOURNE, ADELAIDE, PERTH)); // A geodesic polyline that goes around the world. mMap.addPolyline(/* w ww.j a v a 2 s . c o m*/ (new PolylineOptions()).add(LHR, AKL, LAX, JFK, LHR).width(5).color(Color.BLUE).geodesic(true)); // Circle centered at Sydney. This polyline will be mutable. PolylineOptions options = new PolylineOptions(); int radius = 5; int numPoints = 100; double phase = 2 * Math.PI / numPoints; for (int i = 0; i <= numPoints; i++) { options.add(new LatLng(SYDNEY.latitude + radius * Math.sin(i * phase), SYDNEY.longitude + radius * Math.cos(i * phase))); } int color = Color.HSVToColor(mAlphaBar.getProgress(), new float[] { mColorBar.getProgress(), 1, 1 }); mMutablePolyline = mMap.addPolyline(options.color(color).width(mWidthBar.getProgress())); mColorBar.setOnSeekBarChangeListener(this); mAlphaBar.setOnSeekBarChangeListener(this); mWidthBar.setOnSeekBarChangeListener(this); // Move the map so that it is centered on the mutable polyline. mMap.moveCamera(CameraUpdateFactory.newLatLng(SYDNEY)); }
From source file:com.google.mcommerce.sample.android.chapter09.googleMap.PolylineDemoActivity.java
private void setUpMap() { // A simple polyline with the default options from Melbourne-Adelaide-Perth. mMap.addPolyline((new PolylineOptions()).add(MELBOURNE, ADELAIDE, PERTH)); // A geodesic polyline that goes around the world. mMap.addPolyline(/* www.j a va2 s .c o m*/ (new PolylineOptions()).add(LHR, AKL, LAX, JFK, LHR).width(5).color(Color.BLUE).geodesic(true)); // Circle centered at Sydney. This polyline will be mutable. PolylineOptions options = new PolylineOptions(); int radius = 5; int numPoints = 100; double phase = 2 * Math.PI / numPoints; for (int i = 0; i <= numPoints; i++) { options.add(new LatLng(SYDNEY.latitude + radius * Math.sin(i * phase), SYDNEY.longitude + radius * Math.cos(i * phase))); } int color = Color.HSVToColor(mAlphaBar.getProgress(), new float[] { mColorBar.getProgress(), 1, 1 }); mMutablePolyline = mMap.addPolyline(options.color(color).width(mWidthBar.getProgress())); mColorBar.setOnSeekBarChangeListener(this); mAlphaBar.setOnSeekBarChangeListener(this); mWidthBar.setOnSeekBarChangeListener(this); // Move the map so that it is centered on the mutable polyline. mMap.moveCamera(CameraUpdateFactory.newLatLng(SYDNEY)); }
From source file:com.example.mapdemo.PolylineDemoActivity.java
private void setUpMap() { // A simple polyline with the default options from Melbourne-Adelaide-Perth. mMap.addPolyline((new PolylineOptions()).add(MELBOURNE, ADELAIDE, PERTH)); // A geodesic polyline that goes around the world. mMap.addPolyline(/* w ww. j a va 2s . c o m*/ (new PolylineOptions()).add(LHR, AKL, LAX, JFK, LHR).width(5).color(Color.BLUE).geodesic(true)); // Rectangle centered at Sydney. This polyline will be mutable. int radius = 5; PolylineOptions options = new PolylineOptions() .add(new LatLng(SYDNEY.latitude + radius, SYDNEY.longitude + radius)) .add(new LatLng(SYDNEY.latitude + radius, SYDNEY.longitude - radius)) .add(new LatLng(SYDNEY.latitude - radius, SYDNEY.longitude - radius)) .add(new LatLng(SYDNEY.latitude - radius, SYDNEY.longitude + radius)) .add(new LatLng(SYDNEY.latitude + radius, SYDNEY.longitude + radius)); int color = Color.HSVToColor(mAlphaBar.getProgress(), new float[] { mColorBar.getProgress(), 1, 1 }); mMutablePolyline = mMap.addPolyline(options.color(color).width(mWidthBar.getProgress())); mColorBar.setOnSeekBarChangeListener(this); mAlphaBar.setOnSeekBarChangeListener(this); mWidthBar.setOnSeekBarChangeListener(this); // Move the map so that it is centered on the mutable polyline. mMap.moveCamera(CameraUpdateFactory.newLatLng(SYDNEY)); }
From source file:de.quist.app.maps.example.PolylineDemoActivity.java
@Override public void onMapReady(Map map) { // Override the default content description on the view, for accessibility mode. // Ideally this string would be localised. map.setContentDescription("Google Map with polylines."); // A simple polyline with the default options from Melbourne-Adelaide-Perth. map.addPolyline((BuildConfig.MAP_BINDING.newPolylineOptions()).add(MELBOURNE, ADELAIDE, PERTH)); // A geodesic polyline that goes around the world. map.addPolyline((BuildConfig.MAP_BINDING.newPolylineOptions()).add(LHR, AKL, LAX, JFK, LHR).width(5) .color(Color.BLUE).geodesic(true)); // Rectangle centered at Sydney. This polyline will be mutable. int radius = 5; PolylineOptions options = BuildConfig.MAP_BINDING.newPolylineOptions() .add(BuildConfig.MAP_BINDING.newLatLng(SYDNEY.latitude() + radius, SYDNEY.longitude() + radius)) .add(BuildConfig.MAP_BINDING.newLatLng(SYDNEY.latitude() + radius, SYDNEY.longitude() - radius)) .add(BuildConfig.MAP_BINDING.newLatLng(SYDNEY.latitude() - radius, SYDNEY.longitude() - radius)) .add(BuildConfig.MAP_BINDING.newLatLng(SYDNEY.latitude() - radius, SYDNEY.longitude() + radius)) .add(BuildConfig.MAP_BINDING.newLatLng(SYDNEY.latitude() + radius, SYDNEY.longitude() + radius)); int color = Color.HSVToColor(mAlphaBar.getProgress(), new float[] { mColorBar.getProgress(), 1, 1 }); mMutablePolyline = map.addPolyline(options.color(color).width(mWidthBar.getProgress())); mColorBar.setOnSeekBarChangeListener(this); mAlphaBar.setOnSeekBarChangeListener(this); mWidthBar.setOnSeekBarChangeListener(this); // Move the map so that it is centered on the mutable polyline. map.moveCamera(BuildConfig.MAP_BINDING.cameraUpdateFactory().newLatLng(SYDNEY)); }
From source file:com.cyrilmottier.android.polaris2demo.PolylineDemoActivity.java
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (mMutablePolyline == null) { return;/*from ww w . ja v a 2 s .co m*/ } if (seekBar == mColorBar) { mMutablePolyline.setColor( Color.HSVToColor(Color.alpha(mMutablePolyline.getColor()), new float[] { progress, 1, 1 })); } else if (seekBar == mAlphaBar) { float[] prevHSV = new float[3]; Color.colorToHSV(mMutablePolyline.getColor(), prevHSV); mMutablePolyline.setColor(Color.HSVToColor(progress, prevHSV)); } else if (seekBar == mWidthBar) { mMutablePolyline.setWidth(progress); } }
From source file:de.vanita5.twittnuker.view.ColorPickerView.java
/** * Get the current color this view is showing. * /*from w w w .j a v a 2s .c o m*/ * @return the current color. */ public int getColor() { if (mShowAlphaPanel) return Color.HSVToColor(mAlpha, new float[] { mHue, mSat, mVal }); return Color.HSVToColor(new float[] { mHue, mSat, mVal }); }