[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] pygame for 2d graphics



On 3/19/08, Madhubala <madhubalav@xxxxxxxxxxxxxx> 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