Re: [pygame] scaling the entire screen
Pardon my ignorance, but isn't it simpler to just scale every separate image only once when you're loading them? Then you'd keep scale information in a variable so you can tell what's the apropriate spacing between images. What's flawed in my idea? -Thiago On Wed, Mar 19, 2008 at 6:53 AM, Sibtey Mehdi [EMAIL PROTECTED] wrote: I am creating a offscreen surface, size (5000, 3200) and drawing Rect then I am scaling down that offscreen surface to fit in to the real surface but I will get the scattered lines on the screen or half rect. Is there any way to solve this problem?
[pygame] pygame for 2d graphics
Hi, I am working on a requirement - developing 2d graphics like lines/rectangles using pygame. The original dimension of one screen and coordinates of components to be drawn on that screen are in pixels . My code is below - s = pygame.Surface((4892,3164)) #original dimension of a screen in pixels got from some other application s.fill((255,255,255)) pygame.draw.aalines(s,(0,0,0),True,[(3000,2500),(3192,2500),(3192,2648),(300 0,2648)],0) #original dimensions of a rect pygame.display.init() w = pygame.display.set_mode((1000,750)) s1 = pygame.transform.scale(s,(1000,750)) w.blit(s1,(0,0)) pygame.display.flip() done = False while not done: for e in pygame.event.get(): if e.type == pygame.KEYDOWN: done = True --- When i am trying to scale down the original surface to pygame window , the rectangle is not visible. This is original scalling. I have to provide different scalling levels to provide zooming effect . What more need to be done to get rectangle visible ? Thanks, Madhubala
Re: [pygame] pygame for 2d graphics
Madhubala wrote: My code is below - s = pygame.Surface((4892,3164)) #original dimension of a screen in pixels got from some other application s.fill((255,255,255)) pygame.draw.aalines(s,(0,0,0),True,[(3000,2500),(3192,2500),(3192,2648),(3000,2648)],0) #original dimensions of a rect pygame.display.init() w = pygame.display.set_mode((1000,750)) s1 = pygame.transform.scale(s,(1000,750)) w.blit(s1,(0,0)) pygame.display.flip() When i am trying to scale down the original surface to pygame window , the rectangle is not visible. This is original scalling. I have to provide different scalling levels to provide zooming effect . You are experiencing the destructive effects of aliasing. The scale function probably does point or at best bilinear sampling. When scaling down by such a large factor you must first filter the image to remove frequencies above 1/2 the sampling rate, then sample. This can be done with a convolution but is likely to be slow. You'll likely also be unhappy with the resulting dimness of the lines. The filtering will blend them with their environment causing them to be light gray instead of black. You can read more about aliasing at http://en.wikipedia.org/wiki/Aliasing gb
Re: [pygame] pygame for 2d graphics
On 3/19/08, Madhubala [EMAIL PROTECTED] wrote: Hi, I am working on a requirement - developing 2d graphics like lines/rectangles using pygame. The original dimension of one screen and coordinates of components to be drawn on that screen are in pixels . My code is below - s = pygame.Surface((4892,3164)) #original dimension of a screen in pixels got from some other application s.fill((255,255,255)) pygame.draw.aalines(s,(0,0,0),True,[(3000,2500),(3192,2500),(3192,2648),(3000,2648)],0) #original dimensions of a rect pygame.display.init() w = pygame.display.set_mode((1000,750)) s1 = pygame.transform.scale(s,(1000,750)) w.blit(s1,(0,0)) pygame.display.flip() done = False while not done: for e in pygame.event.get(): if e.type == pygame.KEYDOWN: done = True --- When i am trying to scale down the original surface to pygame window , the rectangle is not visible. This is original scalling. I have to provide different scalling levels to provide zooming effect . What more need to be done to get rectangle visible ? pygame.draw.aalines() only draws lines, not filled rectangles. If the rectangle dimensions are greater than the screen, all of the drawn parts will be outside the viewing area, and so will not be seen. As far as I know, There is no way to make an antialiased rectangle with out using BOTH aalines() and rect(). For an arbitrary polygon, (like if the rectangle is to be rotated), use pygame.draw.polygon(). Now, It looks like what is happening here, is that you are drawing said lines on a surface, which is then blitted to the screen. The rectangle you chose fits on the surface, but, as you can see, when that surface is put on-screen, the area containing the lines is OUTSIDE the viewing area. Try blitting it instead at like (-3050,-2550) or so, and you should see something. Thanks, Madhubala Hope this helps, Ian
Re: [pygame] pygame for 2d graphics
try rotozoom instead of scale... scale is like a nearest neighbor scale, so it throws out a lot of pixels. rotozoom is a resampler. On Wed, Mar 19, 2008 at 5:39 AM, Madhubala [EMAIL PROTECTED] wrote: s1 = pygame.transform.scale(s,(1000,750)) When i am trying to scale down the original surface to pygame window , the rectangle is not visible. This is original scalling. I have to provide different scalling levels to provide zooming effect . What more need to be done to get rectangle visible ?
Re: [pygame] scaling the entire screen
On Tue, Mar 18, 2008 at 11:45 PM, Thiago Chaves [EMAIL PROTECTED] wrote: Pardon my ignorance, but isn't it simpler to just scale every separate image only once when you're loading them? Then you'd keep scale information in a variable so you can tell what's the apropriate spacing between images. What's flawed in my idea? Nothing. You just have to chose how you'll do it. It is all a matter of how you want to do it. There is no right way, but there are very wrong ways and more right ways than others. --For example, if you're going to scale everything, it will be faster to do it beforehand, instead of repeatedly. This will help simplicity. --Of course, if your graphics get rotated when you play the game, then you should use rotozoom() as that will be the equivalent to rotating the max. resolution image, then scaling the rotated image, (as opposed to rotating the small image, which leads to unnecessary visual distortions). --You don't, want to scale a small surface (like 100x100) to a large resolution (like 200x2000) EVERY frame. That will be slow. --What is more correct is to scale things first, before the game starts. --But, if the graphics are always going to be at a set resolution, then it is more correct to keep your images in a lower (or higher) resolution to begin with. --This also applies if you are going to scale the images up, but the images are scaleable. (For instance, a single pixel in the center of a blank 3x3 image can be blown up to like 100x100 without any visual mess-ings up). --Remember, scaling things up takes longer than scaling things down. Ian
Re: [pygame] scaling the entire screen
On Wed, Mar 19, 2008 at 10:01 AM, Ian Mallett [EMAIL PROTECTED] wrote: --But, if the graphics are always going to be at a set resolution, then it is more correct to keep your images in a lower (or higher) resolution to begin with. The OP was asking for the option to let users choose the resolution, so this isn't an option. I would say to target the smallest resolution, and at that level have no scaling. The point of the low resolution is for the fastest framerate. For higher resolutions either scale your images up beforehand, or scale them right after pygame.image.load(). In drawing code, make sure you abstract the resolution out of it. You could scale all x,y values by same amount, where the lowest resolution would have a scale of 1.0. There are probably other options as well. Or switch to opengl, where the problem vanishes :)
Re: [pygame] pygame for 2d graphics
On Wed, Mar 19, 2008 at 9:50 AM, Brian Fisher [EMAIL PROTECTED] wrote: try rotozoom instead of scale... scale is like a nearest neighbor scale, so it throws out a lot of pixels. rotozoom is a resampler. Cool! I didn't know that! Ian
Re: [pygame] pygame for 2d graphics
Also, pygame 1.8 will have a transform.smoothscale function that is a filtered scale. It should run faster than rotozoom because it doesn't need to consider rotation. Anybody who is doing scaling and wants it to look good should probably install pygame 1.8 rc5 and try the smoothscale function. On Wed, Mar 19, 2008 at 1:44 PM, Ian Mallett [EMAIL PROTECTED] wrote: On Wed, Mar 19, 2008 at 9:50 AM, Brian Fisher [EMAIL PROTECTED] wrote: try rotozoom instead of scale... scale is like a nearest neighbor scale, so it throws out a lot of pixels. rotozoom is a resampler. Cool! I didn't know that! Ian
RE: [pygame] pygame for 2d graphics
Thank you. 'rotozoom' solved the problem. Madhubala _ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ian Mallett Sent: Thursday, March 20, 2008 2:15 AM To: pygame-users@seul.org Subject: Re: [pygame] pygame for 2d graphics On Wed, Mar 19, 2008 at 9:50 AM, Brian Fisher [EMAIL PROTECTED] wrote: try rotozoom instead of scale... scale is like a nearest neighbor scale, so it throws out a lot of pixels. rotozoom is a resampler. Cool! I didn't know that! Ian
RE: [pygame] pygame for 2d graphics
Thank you. I tried with rotozoom and smoothscale too. Both are working fine and solved the scalling problem. Madhubala -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Brian Fisher Sent: Thursday, March 20, 2008 3:08 AM To: pygame-users@seul.org Subject: Re: [pygame] pygame for 2d graphics Also, pygame 1.8 will have a transform.smoothscale function that is a filtered scale. It should run faster than rotozoom because it doesn't need to consider rotation. Anybody who is doing scaling and wants it to look good should probably install pygame 1.8 rc5 and try the smoothscale function. On Wed, Mar 19, 2008 at 1:44 PM, Ian Mallett [EMAIL PROTECTED] wrote: On Wed, Mar 19, 2008 at 9:50 AM, Brian Fisher [EMAIL PROTECTED] wrote: try rotozoom instead of scale... scale is like a nearest neighbor scale, so it throws out a lot of pixels. rotozoom is a resampler. Cool! I didn't know that! Ian