I have a Processing.js sketch that must be transparent. I figured out how to set the background to be transparent by default, however, when I draw on the sketch I seemed to have permanently marked the canvas.
Is it possible to clear the canvas and set it back to transparent using Processing.js?
If not, is context.clearRect(params) fast enough/ a suitable solution?
Here are the first two results for googling "Processing.js transparent background":
http://processingjs.org/reference/transparent/
http://processingjs.org/reference/background_/
(Even without google, the reference should be your first stop for questions like this.)
Anyway, yes you can use a transparent background. Just use the /* #pjs transparent="true"; */ directive at the top of your code to enable transparency, and then pass an alpha value into the background() function.
Related
Capturing an image of an off-screen window with CGWindowListCreateImage is a common way to create QuickLook style zoom-in animations, but this seems create an image with the wrong background colour, slightly lighter than the real window.
This causes a flash at the end of the animation which kind of ruins the effect.
Does anyone have any idea why this happens and what can be done about it?
EDIT: I created a demonstration app for this problem. It is a bit large and complex for a Stack Overflow question, but the relevant code is probably in the ZoomingWindow.m methods takeSnapshot and makeAndPrepareSnapshotWindow.
Setting the window appearance to textured in Interface Builder fixed this. Of course that also changes the color of the window, but that is acceptable in this particular case.
While there are lots of variations of the question, there doesn't seem to be a specific answer to a simple case of wanting to use built-in common controls on a transparent window using Win32. I don't want the controls to be transparent, I just want the border around it to be transparent. I can't believe MS didn't update the .dll's to handle transparency when they added it, but I guess they forgot? Is there a specific method that works. A button can get close with WS_EX_TRANSPARENT, but flaky where it works most of the time but at times part of the border shows up. Edit controls, change depending on when get focus or not.
So the question is simply:
Is there a way to make common controls on transparent window so there is no white border around them?
If not, is there a good replacement library that does it via owner draw?
If some, which ones and what is the method?
Seems silly to reinvent the wheel just because of the area around the control.
TIA!!
If I am not mistaken, you can take the following steps to achieve this effect.
1.Create a GDI+ Bitmap object with the PixelFormat32bppPARGB pixel format.
2.Create a Graphics object to draw in this Bitmap object.
3.Do all your drawing into this object using GDI+.
4.Destroy the Graphics object created in step 2.
5.Call the GetHBITMAP method on the Bitmap object to get a Windows HBITMAP.
6.Destroy the Bitmap object.
7.Create a memory DC using CreateCompatibleDC and select the HBITMAP from step 5 into it.
8.Call UpdateLayeredWindow using the memory DC as a source.
9.Select previous bitmap and delete the memory DC.
10.Destroy the HBITMAP created in step 5.
This method should allow you to control the alpha channel of everything that is drawn: transparent for the background, opaque for the button.
A similar discussion: Transparent window containing opaque text and buttons
I have a need. I need to make a window. The glass on the window is transparent. I have found some examples:
https://threejs.org/examples/#webgl_materials_shaders_fresnel
https://threejs.org/examples/#webgl_materials_cubemap_refraction
The background of these examples is static pictures.
My background is dynamic. How can I do it?
Maybe you can use THREE.Refractor like shown in this example. It allows you to create a refractive see-through surface. You might have to adjust the respective shader program in order to achieve your intended visual result (the default shader of THREE.Refractor does not perform any distortions).
I was on the way of making a picasa like photo viewer and later an image editor.i used JFrame and alpha channel to set background transparent.but while moving or zooming in/out ,as i had to draw it on different location and clear the previous image i used clearRect and faced the problem.
the oracle documentation says it clears the rect and restores the background color.
on some trials the clearRect clears the area to background color.But while continuous events like mouse-dragging its turning the color of cleared area to black and causing this:
`
thnx
.i used JFrame and alpha channel to set background transparent.
Don't use alpha for complete transparency. Instead just use:
panel.setOpaque( false );
If you are using semi transparency then check out Backgrounds With Transparency. It will explain the problems with transparent background and provide a couple of solutions.
The basic problem is that transparency breaks the painting contract with Swing components because the background is not cleared entirely before child components are painted.
I have a collection of HubTiles with user-selected images. If an image with transparency is selected, the HubTile's background color (PhoneAccentBrush) shows through. Is there a way to style just the photo background to Transparent without altering the animation backgrounds? (Although if the Title is displayed on a transparent background, that's acceptable, but I'd still like the flipside to use the accent color.)
I've done some searching on styling the HubTile, but haven't been successful.
Apparently the fastest way to find an answer on the interwebs is to post your question to SO. I found this not two minutes after posting.
Konstantinos Kyriakopoulos has a blog post with the template styling I was looking for. I couldn't set the image background to Transparent, but I was able to set it to PhoneBackgroundBrush, which works just as well.
Specifically, I set the Background of the Border in the TitlePanel Grid.