Simply mask a UIView with a rectangle

Thanks to the link from MSK, this is the way I went with which works well: // Create a mask layer and the frame to determine what will be visible in the view. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; CGRect maskRect = CGRectMake(0, 0, 50, 100); // Create a path with the rectangle in it. … Read more

Converting CIDR address to subnet mask and network address

It is covered by apache utils. See this URL: http://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/util/SubnetUtils.html String subnet = “192.168.0.3/31”; SubnetUtils utils = new SubnetUtils(subnet); utils.getInfo().isInRange(address) Note: For use w/ /32 CIDR subnets, for exemple, one needs to add the following declaration : utils.setInclusiveHostCount(true);

Android Mask bitmap on canvas gen a black space

Here is a solution which helped me to implement masking: public void draw(Canvas canvas) { Bitmap original = BitmapFactory.decodeResource(getContext().getResources(),R.drawable.original_image); Bitmap mask = BitmapFactory.decodeResource(getContext().getResources(),R.drawable.mask_image); //You can change original image here and draw anything you want to be masked on it. Bitmap result = Bitmap.createBitmap(mask.getWidth(), mask.getHeight(), Config.ARGB_8888); Canvas tempCanvas = new Canvas(result); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); … Read more

Phone mask with jQuery and Masked Input Plugin

Try this – http://jsfiddle.net/dKRGE/3/ $(“#phone”).mask(“(99) 9999?9-9999”); $(“#phone”).on(“blur”, function() { var last = $(this).val().substr( $(this).val().indexOf(“-“) + 1 ); if( last.length == 3 ) { var move = $(this).val().substr( $(this).val().indexOf(“-“) – 1, 1 ); var lastfour = move + last; var first = $(this).val().substr( 0, 9 ); $(this).val( first + ‘-‘ + lastfour ); } });

Mask US phone number string with JavaScript

This answer assumes you want the following format: (000) 000-0000 (as the OP states). There are multiple different ways to implement this, but here are a couple different approaches: If you want to simply mask the number on the blur event (when the field loses focus), then you could use the following: document.getElementById(‘phone’).addEventListener(‘blur’, function (e) … Read more