List of usage examples for android.graphics Color rgb
@ColorInt public static int rgb(float red, float green, float blue)
From source file:Main.java
private static int applyMaskColor(int color, int mask, float alpha) { int[] rgb = { Color.red(color), Color.green(color), Color.blue(color) }; int[] maskRgb = { Color.red(mask), Color.green(mask), Color.blue(mask) }; for (int j = 0; j < 3; j++) { rgb[j] = Math.round(rgb[j] * alpha) + Math.round(maskRgb[j] * (1 - alpha)); if (rgb[j] > 255) { rgb[j] = 255;/* w ww . ja va2 s.c o m*/ } else if (rgb[j] < 0) { rgb[j] = 0; } } return Color.rgb(rgb[0], rgb[1], rgb[2]); }
From source file:com.knurld.dropboxdemo.KnurldActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.view_loading); ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressSpinner); progressBar.getIndeterminateDrawable().setColorFilter(Color.rgb(226, 132, 59), PorterDuff.Mode.MULTIPLY); context = this; knurldServiceThread = new Thread(new Runnable() { @Override/* w ww . ja v a2s .co m*/ public void run() { knurldService = new KnurldService(); runOnUiThread(new Runnable() { @Override public void run() { showSetup(); } }); } }); knurldServiceThread.start(); }
From source file:com.bytestemplar.tonedef.international.CountryListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getView().setBackgroundColor(Color.rgb(221, 221, 221)); }
From source file:com.google.adsensequickstart.DisplayInventoryFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ScrollView sv = new ScrollView(getActivity()); TableLayout tl = new TableLayout(getActivity()); tl.setBackgroundColor(Color.rgb(242, 239, 233)); sv.addView(tl);/*from w w w . jav a2 s .co m*/ if (displayInventoryController == null) { return sv; } Inventory inventory = displayInventoryController.getInventory(); TableLayout.LayoutParams tableRowParams = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); tableRowParams.setMargins(1, 1, 1, 1); TableRow.LayoutParams accountLayoutParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); accountLayoutParams.setMargins(2, 1, 2, 1); TableRow.LayoutParams adCLientLayoutParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); adCLientLayoutParams.setMargins(12, 1, 2, 1); TableRow.LayoutParams adUnitChannelLayoutParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); adUnitChannelLayoutParams.setMargins(24, 1, 2, 1); for (String accountId : inventory.getAccounts()) { TableRow trow = new TableRow(getActivity()); tl.addView(trow); TextView tv = new TextView(getActivity()); tv.setText(accountId); trow.addView(tv); tv.setLayoutParams(accountLayoutParams); for (String adClient : inventory.getAdClients(accountId)) { TableRow trow2 = new TableRow(getActivity()); trow2.setBackgroundColor(Color.rgb(214, 204, 181)); tl.addView(trow2); TextView tv2 = new TextView(getActivity()); tv2.setText(adClient); trow2.addView(tv2); tv2.setLayoutParams(adCLientLayoutParams); for (String adUnit : inventory.getAdUnits(adClient)) { TableRow trow3 = new TableRow(getActivity()); trow3.setBackgroundColor(Color.rgb(251, 145, 57)); tl.addView(trow3); TextView tv3 = new TextView(getActivity()); tv3.setText(adUnit); trow3.addView(tv3); tv3.setLayoutParams(adUnitChannelLayoutParams); } for (String customChannel : inventory.getCustomChannels(adClient)) { TableRow trow3 = new TableRow(getActivity()); trow3.setBackgroundColor(Color.rgb(255, 195, 69)); tl.addView(trow3); TextView tv3 = new TextView(getActivity()); tv3.setText(customChannel); trow3.addView(tv3); tv3.setLayoutParams(adUnitChannelLayoutParams); } } } return sv; }
From source file:Main.java
/** * Convert HSL values to a RGB Color.//from ww w .j ava 2 s. c om * * @param h Hue is specified as degrees in the range 0 - 360. * @param s Saturation is specified as a percentage in the range 1 - 100. * @param l Lumanance is specified as a percentage in the range 1 - 100. */ private static int hslToRGB(int hInt, int sInt, int lInt) { float h, s, l; h = (float) hInt; s = (float) sInt; l = (float) lInt; if (s < 0.0f || s > 100.0f) { String message = "Color parameter outside of expected range - Saturation"; throw new IllegalArgumentException(message); } if (l < 0.0f || l > 100.0f) { String message = "Color parameter outside of expected range - Luminance"; throw new IllegalArgumentException(message); } // Formula needs all values between 0 - 1. h = h % 360.0f; h /= 360f; s /= 100f; l /= 100f; float q = 0; if (l < 0.5) q = l * (1 + s); else q = (l + s) - (s * l); float p = 2 * l - q; int r = (int) (Math.max(0, HUEtoRGB(p, q, h + (1.0f / 3.0f))) * 255); int g = (int) (Math.max(0, HUEtoRGB(p, q, h)) * 255); int b = (int) (Math.max(0, HUEtoRGB(p, q, h - (1.0f / 3.0f))) * 255); return Color.rgb(r, g, b); }
From source file:Main.java
/** * Convert HSL (hue-saturation-lightness) components to a RGB color. * <ul>//from ww w.j a v a 2s . c o m * <li>hsl[0] is Hue [0 .. 360)</li> * <li>hsl[1] is Saturation [0...1]</li> * <li>hsl[2] is Lightness [0...1]</li> * </ul> * If hsv values are out of range, they are pinned. * * @param hsl 3-element array which holds the input HSL components * @return the resulting RGB color */ public static int HSLToColor(float[] hsl) { final float h = hsl[0]; final float s = hsl[1]; final float l = hsl[2]; final float c = (1f - Math.abs(2 * l - 1f)) * s; final float m = l - 0.5f * c; final float x = c * (1f - Math.abs((h / 60f % 2f) - 1f)); final int hueSegment = (int) h / 60; int r = 0, g = 0, b = 0; switch (hueSegment) { case 0: r = Math.round(255 * (c + m)); g = Math.round(255 * (x + m)); b = Math.round(255 * m); break; case 1: r = Math.round(255 * (x + m)); g = Math.round(255 * (c + m)); b = Math.round(255 * m); break; case 2: r = Math.round(255 * m); g = Math.round(255 * (c + m)); b = Math.round(255 * (x + m)); break; case 3: r = Math.round(255 * m); g = Math.round(255 * (x + m)); b = Math.round(255 * (c + m)); break; case 4: r = Math.round(255 * (x + m)); g = Math.round(255 * m); b = Math.round(255 * (c + m)); break; case 5: case 6: r = Math.round(255 * (c + m)); g = Math.round(255 * m); b = Math.round(255 * (x + m)); break; } r = constrain(r, 0, 255); g = constrain(g, 0, 255); b = constrain(b, 0, 255); return Color.rgb(r, g, b); }
From source file:Main.java
/** * Convert HSL (hue-saturation-lightness) components to a RGB color. * <ul>// w w w.j av a 2 s. com * <li>hsl[0] is Hue [0 .. 360)</li> * <li>hsl[1] is Saturation [0...1]</li> * <li>hsl[2] is Lightness [0...1]</li> * </ul> * If hsv values are out of range, they are pinned. * * @param hsl 3 element array which holds the input HSL components. * @return the resulting RGB color */ public static int HSLToColor(float[] hsl) { final float h = hsl[0]; final float s = hsl[1]; final float l = hsl[2]; final float c = (1f - Math.abs(2 * l - 1f)) * s; final float m = l - 0.5f * c; final float x = c * (1f - Math.abs((h / 60f % 2f) - 1f)); final int hueSegment = (int) h / 60; int r = 0, g = 0, b = 0; switch (hueSegment) { case 0: r = Math.round(255 * (c + m)); g = Math.round(255 * (x + m)); b = Math.round(255 * m); break; case 1: r = Math.round(255 * (x + m)); g = Math.round(255 * (c + m)); b = Math.round(255 * m); break; case 2: r = Math.round(255 * m); g = Math.round(255 * (c + m)); b = Math.round(255 * (x + m)); break; case 3: r = Math.round(255 * m); g = Math.round(255 * (x + m)); b = Math.round(255 * (c + m)); break; case 4: r = Math.round(255 * (x + m)); g = Math.round(255 * m); b = Math.round(255 * (c + m)); break; case 5: case 6: r = Math.round(255 * (c + m)); g = Math.round(255 * m); b = Math.round(255 * (x + m)); break; } r = Math.max(0, Math.min(255, r)); g = Math.max(0, Math.min(255, g)); b = Math.max(0, Math.min(255, b)); return Color.rgb(r, g, b); }
From source file:uk.bcu.MusicDetailsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.setTitle("Track Detail Info"); super.setTitleColor(Color.rgb(56, 172, 236)); setContentView(R.layout.details);/*w w w . ja v a 2s. c o m*/ ImageView AlbumArt = (ImageView) findViewById(R.id.AlbumArt); Animation fadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_in); // Now Set your animation AlbumArt.startAnimation(fadeInAnimation); txtTitle = (TextView) findViewById(R.id.AlbumTitle); txtartist = (TextView) findViewById(R.id.Artist); txtmbid = (TextView) findViewById(R.id.MbidDetails); txtDescriptionTitle = (TextView) findViewById(R.id.UrlDetails); txtAlbum = (TextView) findViewById(R.id.ReleaseDateDetails); txtlisteners = (TextView) findViewById(R.id.ListenersDetails); txtplaycount = (TextView) findViewById(R.id.PlaycountDetails); imgTrack = (ImageView) findViewById(R.id.AlbumArt); String strmusic = this.getIntent().getExtras().getString("music"); if (strmusic != null) { try { music = new JSONObject(strmusic); super.setTitle(music.getString("name")); txtTitle.setText(music.getString("name")); txtartist.setText(music.getString("artist")); txtmbid.setText(music.getString("mbid")); String id = music.getString("mbid"); MusicDetailsService service = new MusicDetailsService(id); service.addListener(this); thread = new Thread(service); thread.start(); // music image String imagePath = this.getDir("MymusicLib", Context.MODE_PRIVATE).getAbsolutePath() + "/MymusicLib/" + id + ".png"; File f = new File(imagePath); if (f.exists()) { imgTrack.setImageBitmap(BitmapFactory.decodeFile(imagePath)); } else { ImageDownloadService downloadService = new ImageDownloadService( music.getJSONArray("image").getJSONObject(2).getString("#text"), imagePath); downloadService.addListener(this); imageThread = new Thread(downloadService); imageThread.start(); } } catch (JSONException ex) { } } }
From source file:foam.jellyfish.StarwispCanvas.java
public Paint getPaint(Canvas canvas, JSONArray prim) { try {//from w ww . java 2s.com Paint myPaint = new Paint(); JSONArray c = prim.getJSONArray(1); myPaint.setColor(Color.rgb(c.getInt(0), c.getInt(1), c.getInt(2))); myPaint.setStrokeWidth(prim.getInt(2)); return myPaint; } catch (JSONException e) { Log.e("starwisp", "Error parsing data " + e.toString()); return null; } }
From source file:com.oguzbabaoglu.cardpager.example.ColorAdapter.java
private int generateRandomColor() { Random random = new Random(); int red = random.nextInt(256); int green = random.nextInt(256); int blue = random.nextInt(256); red = (red + Color.red(TINT)) >> 1; green = (green + Color.green(TINT)) >> 1; blue = (blue + Color.blue(TINT)) >> 1; return Color.rgb(red, green, blue); }