Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get window with semi-transparent blurred background

I'd like to get a window that has a semi-transparent blurred background, just like what the Terminal can do. See this video, about 30 sec in, to see what I mean: http://www.youtube.com/watch?v=zo8KPRY6-Mk

See an image here: http://osxdaily.com/wp-content/uploads/2011/04/mac-os-x-lion-terminal.jpg

I've been googling for an hour, and can't get anything to work. I believe I need to somehow create a core animation layer and add a background filter, but I've been unsuccessful so far... I just see the gray background of my window. Here's the code I've got so far:

Code:

//  Get the content view -- everything but the titlebar.
NSView *theView = [[self window] contentView];
[theView setAlphaValue:0.5];

// Create core animation layer, with filter
CALayer *backgroundLayer = [CALayer layer];
[theView setWantsLayer:YES];
[theView setLayer:backgroundLayer]; 
CIFilter *blurFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
[blurFilter setDefaults];
[theView layer].backgroundFilters = [NSArray arrayWithObject:blurFilter];  
[[theView layer] setBackgroundFilters:[NSArray arrayWithObject:blurFilter]];

Any tips or examples to do what I'm trying to do? Thanks!

like image 639
Scott C Avatar asked Jun 24 '12 04:06

Scott C


People also ask

What is the filter that blurs the background?

FaceTune can help you blur the backgrounds of your photos. Along with one-touch background replacement tools, you can try artistic styles and filters on your photos. You get to choose the subject and blur just the background and set the intensity of the blurring effect for a professional-style picture in seconds.

How do I make the background blurry on my desktop?

Choose the Move tool from the Toolbox and click outside of the foreground. Then, click on the Background Layer and choose Filters. From here, you can choose Simple Blur, Motion Blur, or Gaussian Blur for your background.

How do you blur the background on a computer screen without it zooming in?

How to enable blur background during a meeting. Join a Zoom Meeting or a Webinar as a panelist. In the bottom-left corner of the video window, click the up arrow button next to the Start Video / Stop Video button. Click Blur My Background.


1 Answers

no need for layers and filters, NSWindow can do it itself

[mywindow setOpaque:NO];
[mywindow setBackgroundColor: [NSColor colorWithCalibratedHue:0.0 saturation:0.0 brightness:0.2 alpha:0.5]];

please do not use this, as it will alpha your title bar also (post it here just in case others need)

[mywindow setOpaque:NO];
[mywindow setBackgroundColor: [NSColor blackColor]];
[mywindow setAlphaValue:0.5];

enter image description here

like image 146
Jiulong Zhao Avatar answered Oct 02 '22 18:10

Jiulong Zhao