alpha

ggplot2: Thresholds for scale_alpha()

白昼怎懂夜的黑 提交于 2019-12-04 08:10:59
Is it possible to specify thresholds for color-scales? Look at this example: xy <- expand.grid(x=1:20,y=1:20) xyd <- data.frame(xy,z=runif(400),a=rowSums(xy)/40) g <- ggplot(xyd, aes(x=x, y=y, fill=z, alpha=a)) + geom_tile() + scale_alpha(range=c(0,1), limits=c(0.5,1)) g What I want is that Values of a below 0.5 get an alpha value of 0 so that the lower left half will be invisible. Obviously I could transform the original data but that would destroy the legend. The threshold is working and the values outside that threshold are set to NA ; the problem is that an alpha of NA is getting rendered

iOS UIButton with transparent title on white background

南楼画角 提交于 2019-12-04 07:17:14
I have a custom UIButton with transparent background and white title. I'm looking for a simple solution to invert it on highlight (white background and transparent title) as it is achieved on system UISegmentedControl . Is there simpler solution than inverting alpha on snapshot used as a CALayer mask? If not, could you tell how can I invert CALayer alpha? Odrakir You can draw the text on a CGContext using Destination Out as blend mode. This code seems to work: - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor greenColor]; UIFont* font = [UIFont fontWithName:@