alpha

colorWithAlphaComponent example in Swift

守給你的承諾、 提交于 2019-12-03 01:02:28
What is the correct syntax for this function in Swift? The following works fine, and colors the background purple: self.view.backgroundColor = UIColor.purpleColor() When I chain the colorWithAlphaComponent function, the view shows the correct alpha for a moment, and then changes to an opaque purple that is relatively dark: self.view.backgroundColor = UIColor.purpleColor().colorWithAlphaComponent(0.5) Is this the recommended function for adding an alpha value to a UIColor? Furthermore, why does the intellisense popup say that this function expects a UIColor as a parameter? E.g., self.view

How to load Transparent PNG to Bitmap and ignore alpha channel

回眸只為那壹抹淺笑 提交于 2019-12-02 21:51:30
问题 I see many questions about how to load a PNG with an alpha channel and display it, but none about how to load a PNG that has an alpha channel but ignore the alpha channel, revealing the underlying RGB data. I've tried simply removing all the data from the alpha channel, but I just get black pixels instead of the color data I want. It seems that from the moment I create the Bitmap object, it does not contain any color information in pixels where alpha is 0, though I assure you that information

How to convert grayscale bitmap into alpha mask?

蹲街弑〆低调 提交于 2019-12-02 21:31:21
I have a grayscale JPG picture, and I'd like to load it into Bitmap of format Bitmap.Config.ALPHA_8 . Is that possible, how can I do that? It's straightforward to load alpha channel from a PNG (which can have empty R,G,B channels), but I'd like to use JPG for compression. This is a followup question to How to combine two opaque bitmaps into one with alpha channel? ColorMatrix to rescue! Quoting Android docs, ColorMatrix: 5x4 matrix for transforming the color+alpha components of a Bitmap. The matrix is stored in a single array, and its treated as follows: [ a, b, c, d, e, f, g, h, i, j, k, l, m

Matplotlib: plotting transparent histogram with non transparent edge

天大地大妈咪最大 提交于 2019-12-02 19:08:28
I am plotting a histogram, and I have three datasets which I want to plot together, each one with different colours and linetype (dashed, dotted, etc). I am also giving some transparency, in order to see the overlapping bars. The point is that I would like the edge of each bar not to become transparent as the inner part does. Here is an example: import matplotlib.pyplot as plt import numpy as np x = np.random.random(20) y =np.random.random(20) z= np.random.random(20) fig = plt.figure() ax = fig.add_subplot(111) ax.hist(x, bins=np.arange(0, 1, 0.1), ls='dashed', alpha = 0.5, lw=3, color= 'b')

Adjust Transparency (alpha) of stat_smooth lines, not just transparency of Confidence Interval

人盡茶涼 提交于 2019-12-02 18:49:20
Using ggplot2's stat_smooth(), I'm curious how one might adjust the transparency of the generated regression line. Using geom_points() or geom_line(), one normally sets a value for 'alpha', indicating the percent transparency. However, with stat_smooth(), alpha sets the transparency of the confidence interval (in my sample below, turned off - se=FALSE). I cannot seem to find a way to make the regression line(s) a lower transparency than 1. Your advice would be wonderful. Sample Code library(reshape2) df <- data.frame(x = 1:300) df$y1 <- 0.5*(1/df$x + 0.1*(df$x-1)/df$x + rnorm(300,0,0.015)) df

alpha blending in webgl works not correctly

最后都变了- 提交于 2019-12-02 16:53:34
问题 code: gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LESS); gl.enable(gl.BLEND); gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); Problem in that on a figure "superfluous" is drawn: how to correct it? P.S. alpha=0.9 回答1: What is your perspective zNear and zFar set to? Is it possible you're setting it too close and the back of your cube is being clipped? See sample below where it's set too close. That doesn't look like your issue but it's hard to tell. Also are you sorting your polygons? When

Modify alpha opacity of LESS variable

本小妞迷上赌 提交于 2019-12-02 14:59:06
Using LESS, I know that I can change the saturation or tint of a color variable. That looks like this: background: lighten(@blue, 20%); I want to change the alpha opacity of my color, though. Preferably like this: background: alpha(@blue, 20%); Is there a simple way to do this in LESS? The site documentation gives the answer: background: fade(@blue, 20%); The function name is fade not alpha according to that document. For completeness fade Set the absolute transparency of a color. Can be applied to colors whether they already have an opacity value or not. background: fade(@blue, 20%); fadein

How to load Transparent PNG to Bitmap and ignore alpha channel

孤人 提交于 2019-12-02 11:26:08
I see many questions about how to load a PNG with an alpha channel and display it, but none about how to load a PNG that has an alpha channel but ignore the alpha channel, revealing the underlying RGB data. I've tried simply removing all the data from the alpha channel, but I just get black pixels instead of the color data I want. It seems that from the moment I create the Bitmap object, it does not contain any color information in pixels where alpha is 0, though I assure you that information is physically there in the PNG. To be clear, if my image contains a pixel with these values: (R:255 G

alpha blending in webgl works not correctly

僤鯓⒐⒋嵵緔 提交于 2019-12-02 10:25:38
code: gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LESS); gl.enable(gl.BLEND); gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); Problem in that on a figure "superfluous" is drawn: how to correct it? P.S. alpha=0.9 gman What is your perspective zNear and zFar set to? Is it possible you're setting it too close and the back of your cube is being clipped? See sample below where it's set too close. That doesn't look like your issue but it's hard to tell. Also are you sorting your polygons? When rendering transparent things you generally have to draw front to back. For a convex object like a sphere,

Problem reconstituting UIImage from RGBA pixel byte data

杀马特。学长 韩版系。学妹 提交于 2019-12-02 09:10:44
I need to create 12 coloured images from a single greyscale image ( red orange yellow etc ) Source image is actually a PNG, RGBA: I'm using a library I found ( https://github.com/PaulSolt/UIImage-Conversion/ ) to break the UIImage into a RGBA byte array which I then process pixel by pixel, and use the same library to reconstitute a new UIImage. This is my code: - (UIImage*) cloneWithTint3: (CGColorRef) cgTint { enum { R, G, B, A }; // - - - assert( CGColorGetNumberOfComponents( cgTint ) == 4 ); const float* tint = CGColorGetComponents( cgTint ); // - - - int w = self.size.width; int h = self