Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
So I am attempting to make a little audio player using Pygame. I wanted to add a little audio visualizer similar to in Windows Media Player. I was thinking of starting with an audio wave that scrolls across the screen. But I'm not sure where to start.
Right now I'm just using pygame.mixer to start, stop, and pause the music. I think I would have to use pygame.sndarray and get some samples but I don't know what to do from there. What can I do to turn those samples into a visual audio wave?
Check out the pygame.draw methods.
You can probably take the audio values and map them to one of the draw options - like draw.arc or draw.line. You will have to map the signal output to values that remain within the X and Y max and min of the viewport.
Processing can do the same thing, but is a bit easier to implement if you are interested in learning the scripting language. It has methods specifically for doing the mapping for you and you can do some pretty extreme visuals without a lot of code.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm confused on how the PyOpenGL camera works or how to implement it. Am I meant to rotate and move the whole world around the camera or is there a different way?
I couldn't find anything that can help me and I don't know how to translate C to python.
I just need a way to transform the camera that can help me understand how it works.
To say it bluntly: There is no such thing as a "camera" in OpenGL (neither there is in DirectX, or Vulkan, or in any of the legacy 3D graphics APIs). The effects of a camera is understood as some parameter that contributes to the ultimate placement of geometry inside the viewport volume.
The sooner you understand that all that current GPUs do is offering massively accelerated computational resources to set the values of pixels in a 2D grid, where the region of the pixels changed are mere points, lines or triangles on a 2D plane onto which they are projected from an arbitrarily dimensioned, abstract space, the better.
You're not even moving around the world around the camera. Setting up transformations is actually errecting the stage in which "the world" will appear in the first place. Any notion of a "camera" is an abstraction created by a higher level framework, like a third party 3D engine or your own creation.
So instead of thinking in terms of a camera, which constrains your thinking, you should think about it this way:
What kind of transformations do I have to chain up, to give a tuple of numbers that are called "position" an actual meaning, by letting this position turn up at a certain place on the visible screen?
You really ought to think that way, because that is what's actually happening.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have a set of images. I have to use them for training a network. I want to simulate a lens flare effect and chromatic aberration on the images. I have tried to find some function in OpenCV, scikit and other python image library but no help from there. How can i simulate these effect on my image? Rough idea or code will be useful. Images are in jpg format.
Depends on what kind of lens flare you are trying to achieve. Create e.g. hexagon mask and overlay multiple instances of it partially transparently between start and end point of the flare axis? Hexagons should be at least slightly bigger "in sun's direction" and spaced more or less in equal distance compared to each others. User should be able to click start and end points of said axis from the pic and use e.g. mouse to rotate, zoom in/out the axis and define number of flare elements to be added.
For chromatic aberration, I would split the RGB components, apply slightly different scaling factors, and merge back. Depending on whether you want to simulate a flint or crown effect, the factors will be increasing or decreasing.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm trying to display an array of image thumbnails using Python and Qt4. My problem is that I don't want to calculate the amount of columns for the grid, so that when the application is resized or my thumbnails get bigger, the number of columns automatically change.
Actually I want to use Qlabel, because images are going to have file names and possibly buttons. Is there an easy way to do it?
Something like that:
Brendan Abel's answer is the right and elegant way to use the power of Qt. However, if you find model-view architecture too heavy, I'd suggest you to use FlowLayout demonstrated in here.
Its rather quite easy to implement and may suit your needs.
You should look into using a QGraphicsView. It's a good building block for truly custom widgets that don't really resemble any of the built-in widgets. It uses a model/view architecture and allows you pretty much unlimited flexibility how and where each item is drawn, as opposed to relying on the more limited QLayout system of placement.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need a way to get a list of all sprites in a certain area of the screen, and I cannot find one anywhere on the internet.
Can someone please give me an example code of how to do this?
If it helps, all the sprites are in an "active" list.
Depends on whether you have obstacles or not, i.e. what the definition of "In the Area" means and also home many sprites you are dealing with.
If there's not many sprites and the distance calc is fast then brute force is probably ok.
for sprite in sprites:
if something.distance(sprite) < THRESHOLD:
do_something_with_near_sprite(sprite)
If you have a lot of sprites have a look at quadtrees and things like that. If calculating the distance is complicated then you're probably going to want to look at A* algorithm. There are libraries for these things so you shouldn't have to implement them yourself unless you want to.
This is a pretty general question (prepare to have it voted down by others :)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need to make a simple board game for school in python it has to have a grid sort of like a chess board individual spaces where the character can stand. But I have no idea how, we are not allowed to download anything since it's school computers. Also I need to make the character move. I just need this is the most simple form. The example the book gave us looked like this:
..........
..P.......
..........
..T.......
....T.....
..........
..T.......
..........
.........X
P is the player, T is a trap and X is the treasure. I don't need it exactly like that I just need a board like that and how to make the player move on it.
As this question is not very precise the answer can't be as well; but maybe there are some general hints:
-think about how to store the positions of the elements on the boards (lists (-> lines of the game) might be a good start)
-think about what it means to move the figure (taking the list approach this means you can increment or decrement the position in the list or switch to another one)
-think about how you could see that the player has fallen in to a trap/won (check if a position is already acquired before moving the figure)