About the translucent effect of three.js - three.js

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).

Related

How to make CGWindowListCreateImage render correct background color?

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.

Three.js-- having text overlays appear on screen

I'd like to create some mechanism that provides a text overlay on top of my 3D scene at certain times (such as when clicking a mouse button for instance.)
I'm going over the tutorials on github and notice things like the THREE.TextGeometry class. Using it I can put 3D text in the scene, but it may be a bit more than I need-- what I'm really after is a way to put some text on, say, a black background, overlay it on the scene, then move it out of the way when done. Does anyone know of good ways to do this in three.js? (If the THREE.TextGeometry class is a good way to do this that's fine, I'm just not sure how to do the overlay bit.)
Use HTML. It's super easy and powerful especially if you just need an overlay. With CSS, you can also achieve things like semi-transparent background. If you want to have it "blend" to scene, i.e. have perspective etc. you can use THREE.CSS3DRenderer which will transform divs based on camera you supply.

Drawing an image with a color tint in MonoTouch

What do I need to read up on to tint the image I draw with a predefined color. Alternatively just adjust the alpha value? I've played around with BlendMode but I basically don't know what I'm doing. :)
Simplyfied code below
_backgroundImage = UIImage.FromFile ("whiteblock.png");
var ctx = UIGraphics.GetCurrentContext ();
// What do I do here to tint or adjust alpha of the image
ctx.DrawImage (rect, _backgroundImage.CGImage);
Thanks
AnkMannen
I recommend starting with the Core Image Filter reference docs (see also CIFilter).
(Note that depending on the version of the OS, not all filters may be available.)
You probably want to focus on the filters in the CICategoryColorAdjustment category.
In particular, the CITemperatureAndTint filter can adjust the tint of the image, as you ask. But, it is not straightforward to use.* There are other questions on StackOverflow describing it, like this one: Input parameters of CITemperatureAndTint (CIFilter)
Finally check out the MonoTouch docs for a code example with CITemperatureAndTint. (I believe the image attached to the examples given there are wrong, as they show a scaled image, not a tinted image.)
*It takes two parameters, each a 2D CIVector. I believe the first component of the vector is temperature and should be in the ballpark of (1k ... 30k). I believe the second component is wavelength, so in the ballpark of (380 ... 700). If someone knows better, correct me.

How to prevent LATEX-labels in MATLAB GUI to become blurry?

Within my current MATLAB GUI project, i have two axes objects. The first is used by the workaround "uibutton" (I don't use GUIDE) in order to display a LaTeX-formula (as far as I know, only axes labels are capable to use LaTeX whereas normal static text fields aren't...). The other axes object is used to actually plot a 3D-function.
The program has the following steps:
the first axes creats the LATEX-formula (e.g. f(x)=).
User enters a function in the edit field after the LaTeX-formula (e.g. f(x)=a+b).
User presses a "plot"-button.
3D-function is plotted in the second axes object.
Problem:
As soon as the 3D-function is plotted, the nicely rendered LaTeX-formular becomes crisp. Is there any way to prevent this from happening?
http://i42.tinypic.com/348pq2u.png (See picture for problem demonstration)
Check your figure properties before and after you draw the 3D plot
get(gcf, 'renderer')
My guess is that plotting the 3D function changes the renderer from the default ("painters") to another (likely OpenGL). Matlab's Latex rendering does not seem to play well with zbuffer or OpenGL (these produce bitmaps rather than line art).
You may be stuck if painters can't render your 3D graphics properly, but you can try to force it by setting the renderer manually back to painters
set(gcf, 'renderer', 'painters')

Qt - Drawing a Rect/Frame out of a bigger Pixmap image

I've been banging my head about this seemingly easy task and I could really use some help.
I have a wide Image loaded in the gui (using the designer..) and I want to be able to draw only a portion of it, a rectangle.
I need to be able to change this rectangle position over the large image, in order to draw a different part of the larger image at will. In this process the rect must maintain its size.
Using the Ui::MainWindow object I'm able to access the label holding the image and a solution that involves using this option is preferred (in order to keep up with the rest of the code I've already written )
Any solution will be much appreciated :)
Thanks,
Itamar
I would definitely (for ease of use) just place an empty label as placeholder in Designer.
Then implement the paintEvent for this label (delegate it to your own method). You'll have also have to look into QPainter, QPixMap, etc... Should be doable based on these hints and the documentation.
If you want more, I suggest you provide a small code snippet to work upon.
If you want to do this more or less purely through designer, you could put a QScrollArea where you want the portion of the image to appear. If you set the scroll area's scrollbar policy to be never shown, you can then manually change what part is visible via the scroll area widget. However, this would probably be more complex that creating a derived widget and reimplementing the paint function.

Resources