mask

Can a single CALayer be used as the mask for multiple other layers?

*爱你&永不变心* 提交于 2019-12-01 05:51:33
I can't find anything in the docs that indicates whether a single CALayer (or subclass) can be used as the mask property for multiple other layers. Is it possible? Or undefined? My experimentation says that it cannot. It will end up as the mask for the last layer it is attached to, and any previous layers it was assigned as a mask to, will revert to the default value of mask. It is possible. I combined mask of CAGradationLayer and CAShapeLayer. I made UIImage from two layers, and I use it to mask. You can generate image from CALayer like below. extension CALayer { func makeImage() -> UIImage {

Masking a UIView

丶灬走出姿态 提交于 2019-12-01 05:29:36
I use the following code all the time in my view controller: UIView *view = [[CustomView alloc] init]; UIView *mask = [[CustomMask alloc] init]; [view layer].mask =[mask layer]; and it masks the view as I want. However, when it is not in a view controller I get the error: 'Request for member 'mask' in something not a structure or a union' E.g. I want to apply the mask in the CustomView class itself. So I would have: UIView *mask = [[CustomMask alloc] init]; [self layer].mask =[mask layer]; This produces the error. If I do it in my AppDelegate class with two images I get the same error again.

Bit Mask usage in the program below from Programming Pearls

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 04:08:17
I started reading "Programming Pearls" today and while doing it's exercise I came across this question "How would you implement your own bit vector?". When I looked at the solution it was like this: #define BITSPERWORD 32 #define SHIFT 5 #define MASK 0x1F #define N 10000000 int a[1 + N/BITSPERWORD]; void set(int i) { a[i >> SHIFT] |= (1 << (i & MASK)); Where I am getting confused at is this statement 1 << (i & MASK) Could someone please explain me what's going on here? Note that MASK is set such that it has the lowest SHIFT bits set, where SHIFT is exactly the base-2 logarithm of BITSPERWORD .

Can a single CALayer be used as the mask for multiple other layers?

拥有回忆 提交于 2019-12-01 04:05:10
问题 I can't find anything in the docs that indicates whether a single CALayer (or subclass) can be used as the mask property for multiple other layers. Is it possible? Or undefined? 回答1: My experimentation says that it cannot. It will end up as the mask for the last layer it is attached to, and any previous layers it was assigned as a mask to, will revert to the default value of mask. 回答2: It is possible. I combined mask of CAGradationLayer and CAShapeLayer. I made UIImage from two layers, and I

Take N first values from every row in NumPy matrix that fulfill condition

℡╲_俬逩灬. 提交于 2019-12-01 03:59:55
问题 I have a numpy vector , and a numpy array . I need to take from every row in the matrix the first N (lets say 3) values that are smaller than (or equal to) the corresponding line in the vector. so if this is my vector: 7, 9, 22, 38, 6, 15 and this is my matrix: [[ 20., 9., 7., 5., None, None], [ 33., 21., 18., 9., 8., 7.], [ 31., 21., 13., 12., 4., 0.], [ 36., 18., 11., 7., 7., 2.], [ 20., 14., 10., 6., 6., 3.], [ 14., 14., 13., 11., 5., 5.]] the output should be: [[7,5,None], [9,8,7], [21,13

Bit Mask usage in the program below from Programming Pearls

核能气质少年 提交于 2019-12-01 01:33:57
问题 I started reading "Programming Pearls" today and while doing it's exercise I came across this question "How would you implement your own bit vector?". When I looked at the solution it was like this: #define BITSPERWORD 32 #define SHIFT 5 #define MASK 0x1F #define N 10000000 int a[1 + N/BITSPERWORD]; void set(int i) { a[i >> SHIFT] |= (1 << (i & MASK)); Where I am getting confused at is this statement 1 << (i & MASK) Could someone please explain me what's going on here? 回答1: Note that MASK is

Converting subnet mask “/” notation to Cisco 0.0.0.0 standard

女生的网名这么多〃 提交于 2019-12-01 01:08:33
I've searched SO for help but could'nt find a answer to my question. Situation: I need to convert a "/NN" subnet mask notation (think IPTABLES) to a 0.0.0.0 cisco notation. NN are the number of "1" in the submask, from the lowest octet to the higher. Each octet are 8 bit integers. Possible solution: Make a array of 32 "0" and filling the last NN digits with "1", then group in 4 octets and converting to int... a /23 mask should be like 0.0.1.255. My question is how to do it in .NET... i never used binary manipulation and conversion. Can you guys help me with this solution? UPDATE - Stephen has

Create an image-overlay mask in javafx

一个人想着一个人 提交于 2019-12-01 00:52:28
I'm trying to do a simple thing. I have a binary image and all I want is to overlay the binary image on a color image, but the white pixels in the binary image should be red, and the black transparent. I'm quite used to JavaFx but I'm stuck with this one. I know I could achieve it by iterating through all pixels with a PixelReader, but I'm sure there is an easier way. I tried to use some sort of Blend-effect but no luck so far. I think it should be similar to this: How to Blend two Image in javaFX I came up with this: Image image = new Image("/circle.jpg", false); ImageView iv = new ImageView

Actionscript3 alpha masking?

落爺英雄遲暮 提交于 2019-12-01 00:47:31
I was trying to apply a spotlight effect on a google map application. Specifically, I draw a circle that follows the mouse and set it as a mask over the map. The problem is only the map area within the circle shows up, I know it's what mask is supposed to look like, but is there a way to make the area outside the circle some kind of semi-transparent so that the map under it can also see through? That way people can still see the rest of the map when they navigate just the area within the circle is highlighted. Thanks! Another option is to use blendModes (it could be a bit more cpu expensive in

UIImage by selecting part of another UIImage

元气小坏坏 提交于 2019-12-01 00:23:58
I have an UIImage and a CGPoint which tells me in what direction I should move it to create another image. The background can be anything. Give the initial UIImage how I can create the new one? What is the most efficient way of doing it? Here is what I'm doing: int originalWidth = image.size.width; int originalHeight = image.size.height; float xDifference = [[coords objectAtIndex:0] floatValue]; float yDifference = [[coords objectAtIndex:1] floatValue]; UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 240, originalWidth, originalHeight)]; UIImageView *imageView = [[UIImageView