如何打造炫酷的“镜子”?对图形 GUI 中显示的项目有何影响?
我有一个 QGraphicsScene,并向场景添加了几个 QGraphicsItem。添加到场景中的所有项目都是 QGraphicsPixmapItem。
我希望输出显示的场景对于添加到场景中的每个项目都具有“镜像”视觉效果。我希望“镜像”视觉效果在显示专辑时看起来对 iTunes 镜像有一点影响:
(注:上面看到的图片来自"CoverFlow 公司网站”。我认为 CoverFlow 是实现 iTunes 专辑显示“镜子”视觉效果的人。)
请注意此场景中的每个项目下面都有一个镜子。
如何为每个项目创建这种“镜像”视觉效果(如屏幕截图所示)?
I have a QGraphicsScene and I add a couple of QGraphicsItem(s) to the scene. All the items being added to the scene are QGraphicsPixmapItem.
I want the output displayed scene to have a "mirror" visual effect for each item that is added to the scene. I would like the "mirror" visual effect to look a little something to the iTunes mirror affect when you display albums:
(NOTE: Image seen above is from "CoverFlow company website". CoverFlow are the people that I think implemented the iTunes album display "mirror" visual effect.)
Notice how each item in this scene has a mirror below it.
How do you create this "mirror" visual effect (seen in the screenshot) for each item?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想这就是我会做的。根据评论,我想这对你也有好处。
我将简单地使用 QPainter 从原始图像创建反射的镜像图像并将两者合并(再次使用 QPainter)。生成的图像是使用 QGraphicsPixmapItem 显示的图像。在下面的代码中,我创建了图像的反射镜像版本。然后您需要做的就是调整参数并合并。
您可以将生成的图像(两者合并的结果)加载到 QGraphicsPixmapItem 中,然后可以继续应用所需的所有转换。
编辑:我忘记您可能还想设置额外的不透明度,正如提供的图像似乎所做的那样。我没有尝试,但使用 QPixmaps 可能可以做到同样的事情。这应该可以提高性能,甚至可以加速绘画(具体取决于您使用的平台和绘画引擎)。
EDIT2:根据要求,这是我的测试代码的输出:

(我希望这张图片不受某些版权或类似的保护,我试图检查,但什么也没写)
I suppose this is how I would do it. I guess this is good for you as well according to the comment.
I would simply create the reflected mirrored image from the original using the QPainter and merge the two (using the QPainter again). This resulting image is the one shown using the QGraphicsPixmapItem. In the code below I created the reflected mirrored version of the image. All you need to do then is to tune the parameters and merge.
You can load the resulting image (the result of the merge of the two) in a QGraphicsPixmapItem and then you can go on applying all the transformations you need.
EDIT: I forgot that you may also want to set an additional opacity, as the image provided seems to do. I didn't try, but it might be possible to do the same using QPixmaps. This should improve performance or even allow, depending on the platform and on the paint engine you're using, accelerated painting.
EDIT2: As requested this is the output of my test code:

(I hope this image is not under some copyright or similar, I tried to check but nothing was written)