Comments (3)
I don't think I have time to debug this, but if I did/do I would need a minimal example that reproduces it for me and doesn't require any input data files (ex. numpy.random instead). If you can simplify this down as much as possible it would really help me track down what's going on in the internals.
from vispy.
Sure, here is a simple example:
from vispy import app, scene
import numpy as np
from vispy.scene.cameras import TurntableCamera
from vispy.io import load_data_file, read_png
class Blending_image(scene.visuals.Image):
def __init__(self):
scene.visuals.Image.__init__(self, parent=None)
self.unfreeze()
self.overlaid_images = [self]
# NOTE: Here, I set img2's parent as img1.
# So when apply some transform on img1,
# img2 can be add the same effect.
img2 = scene.visuals.Image(parent=self)
self.overlaid_images.append(img2)
# Set GL state. Must check depth test, otherwise weird in 3D.
self.set_gl_state(depth_test=True,
depth_func='lequal',
blend_func=('src_alpha', 'one_minus_src_alpha'))
self.freeze()
def set_data2(self, img1, img2):
self.set_data(img1)
self.overlaid_images[1].set_data(img2)
canvas = scene.SceneCanvas(keys='interactive', bgcolor='white')
vb1 = scene.widgets.ViewBox(parent=canvas.scene)
vb2 = scene.widgets.ViewBox(parent=canvas.scene)
grid = canvas.central_widget.add_grid()
grid.padding = 20
grid.add_widget(vb1, 0, 0)
grid.add_widget(vb2, 0, 1)
vb1.camera = TurntableCamera(fov=45, azimuth=0, elevation=-90)
vb2.camera = TurntableCamera(fov=45, azimuth=0, elevation=-90)
# Create the image
root = 'mona_lisa/mona_lisa_sm.png'
img_data1 = read_png(load_data_file(root))[:500, :500, :]
img_data2 = read_png(load_data_file(root))[-500:, :500, :]
img_ov1data = np.ones((500, 500, 4)).astype(np.float32)
img_ov1data[:, :, 3] = 0.5
img_ov2data = np.random.rand(500, 500, 4).astype(np.float32)
img_ov2data[:, :, 3] = 0.5
image1 = Blending_image()
image1.set_data2(img_data1, img_ov1data)
image2 = Blending_image()
image2.set_data2(img_data2, img_ov2data)
vb1.add(image1)
vb2.add(image2)
vb1.camera.set_range()
vb2.camera.set_range()
vb1.camera.link(vb2.camera)
canvas.show()
app.run()
from vispy.
I have solved this problem. There are two way to solve it
- Just add
Blending_image
's children into viewbox
vb1.add(image1)
vb1.add(image1.overlaid_images[-1])
vb2.add(image2)
vb2.add(image2.overlaid_images[-1])
- modify
_set_clipper
ofBlending_image
class Blending_image(scene.visuals.Image):
......
......
def _set_clipper(self, node, clipper):
"""
To clipper its children
Assign a clipper that is inherited from a parent node.
If *clipper* is None, then remove any clippers for *node*.
"""
super()._set_clipper(node, clipper)
for im in self.children:
if isinstance(im, scene.visuals.Image):
if node in im._clippers:
im.detach(self._clippers.pop(node))
if clipper is not None:
im.attach(clipper)
im._clippers[node] = clipper
from vispy.
Related Issues (20)
- Cannot find Quartz library on MacOS Sonoma HOT 18
- how can i disable the canvas border HOT 2
- No setter for some properties of Arrow or Line after instantiation HOT 3
- Question regarding datoviz, backends, gtk HOT 5
- destructive behaviour when lines overlap HOT 1
- Errorous behavior in Vispy.Visuals.Markers.set_data HOT 2
- grid solver constraint not working HOT 4
- Running vispy inside docker and not being able to access OpenGL drivers HOT 1
- SurfacePlotVisual.set_data cause vertex shader to perform unnecessary build HOT 3
- Looking for additional maintainers HOT 12
- vispy flickering on Windows with real time data HOT 12
- How to use a canvas decorator inside a custom class HOT 2
- How to change shortcut for camera Interaction in vispy HOT 2
- VisPy does not work properly if QtWebEngineWidgets is imported HOT 4
- Outdated Vispy version with Debian 12 package HOT 2
- Having problems with TextVisuals and InstancedMesh HOT 9
- Memory usage keep increasing HOT 13
- Add several light to a surface plot
- What's the status of GLFW? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vispy.