RE: [pygame] loss of transparency in scaling surfaces

2008-08-19 Thread Sibtey Mehdi


Thanks Lenard, I used colorkey with per-pixel alpha that is working well. 


Thanks
Sibtey






> Hi
>
>  I am drawing a line on pygame screen and created one transparent 
> surface of size (800,700) and scaling down using smoothscale to the 
> pygame screen size .In this condition everything is working fine.
>
>  
>
> If have created the transparent surface of size like 4892X3614 and 
> then scaling down to the pygame screen size then transparency is lost. 
> Can any one help me understanding this? The script is shown below
>
>  
>
>  
>
>  
>
> import pygame
>
> BACKGROUNDCOLOR = (255,255,255)
>
[snip code]
>
> # for large surface like this transparecy is Lost
>
> surf = pygame.Surface((4892,3614))
>
> surf.fill(BACKGROUNDCOLOR)
>
> # set transparency
>
> surf.set_colorkey(BACKGROUNDCOLOR,pygame.RLEACCEL)
>
> #draw a line on transparent surface
>
> pygame.draw.line(surf,(200,155,155), (550,550),(750,550),2)
>
> #scale down
>
> surf3  = pygame.transform.smoothscale(surf, (800,700))
>
> screen.blit(surf3,(0,0))
>
>  
>
> pygame.display.flip()
>
[snip code]

The problem is that smoothscale doesn't guarantee colors will remain 
unchanged. I found the background color of surf3 was (253, 253, 253, 
255). The following modified version code does make surf3's background 
transparent.

import pygame
import sys
BACKGROUNDCOLOR = (255,255,255)
pygame.display.init()
screen = pygame.display.set_mode((800,700))
screen.fill(BACKGROUNDCOLOR)
# draw a line on pygame screen
pygame.draw.line(screen,(255,0,0), (50,50),(100,100),1)
# for small surface like this transparecy is fine
## *
##surf = pygame.Surface((800,700))
## **
# for large surface like this transparecy is Lost
surf = pygame.Surface((4892,3614), 0, 24)
surf.fill(BACKGROUNDCOLOR)
#draw a line on transparent surface
pygame.draw.line(surf,(200,155,155), (550,550),(750,550),2)
#scale down
surf3  = pygame.transform.smoothscale(surf, (800,700))
#set transparency
surf3.set_colorkey(surf3.get_at((0,0)),pygame.RLEACCEL)
screen.blit(surf3,(0,0))
 
pygame.display.flip()
while 1:
events = pygame.event.get()
for event in events:
if event.type==pygame.KEYDOWN and event.key ==pygame.K_ESCAPE:
pygame.display.quit()
sys.exit()


But it also shows that transparency and scaling don't go together well. 
Using colorkey with per-pixel alpha may be a better solution:


surf = pygame.Surface((4892,3614), pygame.SRCALPHA, 32)
bg = BACKGROUNDCOLOR
surf.fill((bg[0],bg[1],bg[2],0)) # Transparent background color.

surf3  = pygame.transform.smoothscale(surf, (800,700))
screen.blit(surf3,(0,0))


-- 
Lenard Lindstrom
<[EMAIL PROTECTED]>



[pygame] loss of transparency in scaling surfaces

2008-08-19 Thread Sibtey Mehdi
 

Hi 

 I am drawing a line on pygame screen and created one transparent surface of
size (800,700) and scaling down using smoothscale to the pygame screen size
.In this condition everything is working fine. 

 

If have created the transparent surface of size like 4892X3614 and then
scaling down to the pygame screen size then transparency is lost. Can any
one help me understanding this? The script is shown below

 

 

 

import pygame

BACKGROUNDCOLOR = (255,255,255)

pygame.display.init()

screen = pygame.display.set_mode((800,700))

screen.fill(BACKGROUNDCOLOR)

# draw a line on pygame screen

pygame.draw.line(screen,(255,0,0), (50,50),(100,100),1)

# for small surface like this transparecy is fine

## *

##surf = pygame.Surface((800,700))

## **

# for large surface like this transparecy is Lost

surf = pygame.Surface((4892,3614))

surf.fill(BACKGROUNDCOLOR)

# set transparency

surf.set_colorkey(BACKGROUNDCOLOR,pygame.RLEACCEL)

#draw a line on transparent surface

pygame.draw.line(surf,(200,155,155), (550,550),(750,550),2)

#scale down

surf3  = pygame.transform.smoothscale(surf, (800,700))

screen.blit(surf3,(0,0))

 

pygame.display.flip()

while 1:

events = pygame.event.get()

for event in events:

if event.type==pygame.KEYDOWN and event.key ==pygame.K_ESCAPE:

pygame.display.quit()

 

thanks,

Sibtey

 



[pygame] help PGU Utilities

2008-08-06 Thread Sibtey Mehdi
Hi,

How to write the resizable Notes on pygame surface similar to paste it note
in Microsoft visio. I have just gone through the pgu utilities but couldn't
get it properly. Any help on how to use pgu or any better way to write the
note is appreciated.

 

 

Thanks,

Sibtey

 



RE: [pygame] Surfaces must not be locked during blit

2008-06-27 Thread Sibtey Mehdi
Hugo,

logicalSurface is an object that contain pygame surface I am drawing
everything on it and blitting this surface to the pygame screen.

I haven't locked the surface anywhere else, all the others drawing function
working fine only blit function gives the problem if and only if I draw the
pages quickly by pressing pageUp and pand pageDown.

 

I have temporary fixed this problem like this, but I want a better solution

def blit(self,screen, logicalSurface, (offsetX,offsetY)):

"""

blit the surface on to the pygamewindow, logicalSurface -> pygame
surface

"""   

try:

screen.blit (logicalSurface.surface, (-offsetX, -offsetY))

except:

time.sleep(0.1)

self.blit(screen, pygameSurface,(offsetX, offsetY)) 

 

Thanks,

Sibtey

 

  _  

On Behalf Of Hugo Arts



 

What exactly is the difference between logicalSurface and
logicalsurface.surface? in draw(), you draw directly on logicalSurface. But
after that you blit logicalSurface.surface to the screen.

pygame draw functions will lock/unlock surface automagically IIRC, so the
problem is likely with the blit call. Try to find out if either of the
surfaces is locked, and if so, try to unlock them. The surface may be locked
multiple times, and you must unlock it the same number of times to regain
access, so you might need more than one unlock call.

Are you locking these surfaces elsewhere in your code? There may be a bug in
that code that causes some surfaces to stay locked when they shouldn't.
Remember to call unlock the same amount of times you called lock.

If you don't use lock in your code, there may be a bug in 1.8.0 locking.

On Fri, Jun 27, 2008 at 11:16 AM, Sibtey Mehdi <[EMAIL PROTECTED]>
wrote:

 

I am using 1.8.0 packages (march 29 2008).  On page Up and Page Down I am
calling the drawPage() function. 

 

def drawPage(self, page, logicalSurface):

self.draw(page, logicalSurface)

self.screen.blit (logicalSurface.surface, (-offsetX, -offsetY))

 

def draw(self,  page, logicalSurf):

 #draw rect

 for rec in page.rects:

 
self.Pygame.draw.rect(logicalSurf,rec.color,(rec.x1,rec.y1,rec.x2,rec.y2),
1)

 #text

 for text in page.texts:

#draw text

 #lines

 for line in  page.lines:

 self.Pygame.draw.line(logicalSurf,
[line.colline.x1,line.y1],[line.x2,line.y2],1)



thanks,

Sibtey

 

 

 

 

Are you using svn pygame? There have been some changes since 1.8.0  to 

the locking code.

 

Hugo Arts wrote:

> well, if pygame says this is a locking issue, then it is most likely a

> locking issue. If you say unlocking the surface did not fix the problem as

> you said, I don't have another solution with the current supplied

> information.

> 

> We'll likely need to see some code before we can figure out the actual

> error.

> 

> Hugo

> 

> On Fri, Jun 27, 2008 at 8:54 AM, Sibtey Mehdi <[EMAIL PROTECTED]>

> wrote:

> 

>   

>>  Hi

>> 

>> I am drawing some graphics page (Text, rect, lines, polygon) on pygame

>> surface, but when I quickly pressing page up and page down my application

>> give the Pygame error "Surfaces must not be locked during blit".

>> 

>> I have also unlocked the surface by suface.unlock before blitting but it

>> doesn't solve the problem.

>> 

>> So please help me out of this problem

>> 

>> 

>> 

>> Thanks,

>> 

>> Sibtey

>> 

>> 

>> 

>> 

> 

>   

 



RE: [pygame] Surfaces must not be locked during blit

2008-06-27 Thread Sibtey Mehdi
 

I am using 1.8.0 packages (march 29 2008).  On page Up and Page Down I am
calling the drawPage() function. 

 

def drawPage(self, page, logicalSurface):

self.draw(page, logicalSurface)

self.screen.blit (logicalSurface.surface, (-offsetX, -offsetY))

 

def draw(self,  page, logicalSurf):

 #draw rect

 for rec in page.rects:

 
self.Pygame.draw.rect(logicalSurf,rec.color,(rec.x1,rec.y1,rec.x2,rec.y2),
1)

 #text

 for text in page.texts:

#draw text

 #lines

 for line in  page.lines:

 self.Pygame.draw.line(logicalSurf,
[line.colline.x1,line.y1],[line.x2,line.y2],1)



thanks,

Sibtey

 

 

 

 

Are you using svn pygame? There have been some changes since 1.8.0  to 

the locking code.

 

Hugo Arts wrote:

> well, if pygame says this is a locking issue, then it is most likely a

> locking issue. If you say unlocking the surface did not fix the problem as

> you said, I don't have another solution with the current supplied

> information.

> 

> We'll likely need to see some code before we can figure out the actual

> error.

> 

> Hugo

> 

> On Fri, Jun 27, 2008 at 8:54 AM, Sibtey Mehdi <[EMAIL PROTECTED]>

> wrote:

> 

>   

>>  Hi

>> 

>> I am drawing some graphics page (Text, rect, lines, polygon) on pygame

>> surface, but when I quickly pressing page up and page down my application

>> give the Pygame error "Surfaces must not be locked during blit".

>> 

>> I have also unlocked the surface by suface.unlock before blitting but it

>> doesn't solve the problem.

>> 

>> So please help me out of this problem

>> 

>> 

>> 

>> Thanks,

>> 

>> Sibtey

>> 

>> 

>> 

>> 

> 

>   



[pygame] Surfaces must not be locked during blit

2008-06-27 Thread Sibtey Mehdi
Hi

I am drawing some graphics page (Text, rect, lines, polygon) on pygame
surface, but when I quickly pressing page up and page down my application
give the Pygame error "Surfaces must not be locked during blit".

I have also unlocked the surface by suface.unlock before blitting but it
doesn't solve the problem.

So please help me out of this problem

 

Thanks,

Sibtey

 



RE: [pygame] hoe to create the RoundRect ?

2008-03-27 Thread Sibtey Mehdi
Yeah, I need such types of rectangles. 

 



 

  _  

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Ian Mallett
Sent: Thursday, March 27, 2008 2:15 PM
To: pygame-users@seul.org
Subject: Re: [pygame] hoe to create the RoundRect ?

 

Do you mean like a rectangle with rounded edges?  As far as I know, PyGame
doesn't go that.  You can, however, make several rectangles of different
sizes, and draw them over each other.  Because they overlap, they will
appear to form a rounded rectangle.
Ian

<>

[pygame] hoe to create the RoundRect ?

2008-03-27 Thread Sibtey Mehdi
How I can draw the RoundRect Using pygame, is there any direct way or I have
to draw this by draw.line and draw.arc

 



[pygame] scaling the entire screen

2008-03-18 Thread Sibtey Mehdi

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?



RE: [pygame] mapping logical coordinate ????

2008-03-12 Thread Sibtey Mehdi
 

 Thanks,for your kind help

But, I am getting the coordinate (3000, 2000, 3400, 2400) from some others
tools and want to create the pygame.draw.rect (3000, 2000, 3400, 2400) to
show some information. I have create a Surface pygame.Surface ((4000, 3000))
and then tried to scale down it but the rectangle has not displayed in the
pygame window. Can anyone help me out? 

 

I have tried something like this

  screen = pygame.display.set_mode ((800,700))

  worksurf = pygame.Surface((4000,3000))

  pygame.draw.rect (worksurf, (255, 0, 0), (3000, 2000, 3400, 2400), 1)

  screen.blit (worksurf, (0, 0)))

  newSurf = pygame.transform.scale (worksurf, (800,700)) #scale down

  screen.blit (newSurf, (0, 0)))

 

 

Nick Moffitt:

> The tactical.py has the classes that do the transformations

 

My bad.  http://zork.net/~nick/tkhasi/space.py is the file that actually

does the coordinate transformations (but remember that positive Y is

down on the screen)

 

-- 

"Ill-informed qmail-bashing is better than no   Nick Moffitt

qmail-bashing at all." [EMAIL PROTECTED]

--Don Marti



[pygame] mapping logical coordinate ????

2008-03-12 Thread Sibtey Mehdi
Hi All

How to map the logical coordinates in to window coordinates using
pygame.

 

Thanks.. 



RE: [pygame] how to display pygame graphics within a wxpython window

2008-03-05 Thread Sibtey Mehdi
 

 

Ok, but is there any way to tell PyGame to paint any window, I mean by
passing the window handle to pygame.

 

hi,

 

Using pygame with wxpython is not supported.  See this page for details:

http://www.pygame.org/wiki/Gui

 

 

cheers,

 

 

On Wed, Mar 5, 2008 at 4:01 PM, Sibtey Mehdi <[EMAIL PROTECTED]> wrote:

> 

> 

> 

> 

> Hi

> 

> How to display pygame graphics within a wxpython window. I have

> tried the last example on http://wiki.wxpython.org/IntegratingPyGame but
it

> opens the two separate window one for pygame one for frame. I want to
create

> one frame that can use the pygame  drawing functionality.

> 

> 

> 

> 

> 

> Thanks.

> 

> Sibtey



[pygame] how to display pygame graphics within a wxpython window

2008-03-04 Thread Sibtey Mehdi
Hi

How to display pygame graphics within a wxpython window. I have
tried the last example on http://wiki.wxpython.org/IntegratingPyGame but it
opens the two separate window one for pygame one for frame. I want to create
one frame that can use the pygame  drawing functionality.

 

 

Thanks.

Sibtey 



RE: [pygame] How to add Zoom functionality?

2008-03-03 Thread Sibtey Mehdi
To add zoom in, I want to transform the size of the shape when we select
that shape and press "crl+I" key. If the size is increased the scroll bar
should be added that's why I am using 'wx'. 

 

 

 

 

Ok, so you drew some shapes on the screen. You also want to put in zoom
in/out functionality.

 

How do you want them to be able to zoom in? What do you want to happen when
they zoom in? What is zooming in?

Hi All

I am using Mirra to draw some shapes on the screen and set the environment
"wx" to add the scrollbar. Does any one know how to add ZOOM in and zoom out
functionality?

 

Thanks.

gopal 

 

 



RE: [pygame] how to add the scroll bar?

2008-02-26 Thread Sibtey Mehdi

Thanks, I have tried the wxPython and got it.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Ian Mallett
Sent: Tuesday, February 26, 2008 8:31 PM
To: pygame-users@seul.org
Subject: Re: [pygame] how to add the scroll bar?

You can't do it with PyGame, unless you want to hardcode it yourself.
If you want to have one without making yourself, you can use wxPython.
 Might be easier to make it yourself, though, given the overcomplexity
of wx...



[pygame] how to add the scroll bar?

2008-02-26 Thread Sibtey Mehdi
Hi

 Does any one know how to add the scrollbar using pygame?. I am using
pygame for some other type of applications and this functionality is needed
to zoom the drawing on the screen.

 

Thanks..

SibteyMehdi



[pygame] how to display a string ?

2008-02-15 Thread Sibtey Mehdi
Hi All

I am drawing the rectangles using pyOpenGl and pygame and want to
display some string over the rectangles with different color.

I have gone through the pyOpenGl references but couldn't get the way.
Any one knows about the tutorial then help me out.

 

 

Thanks.

Sibtey

 

 

 

 

 





[pygame] Help

2008-02-14 Thread Sibtey Mehdi
Hi All

 

I am new to PyOpenGl and want to use 2D graphics, to create
rectangle to represent some information. Is there any 2D graphics library
that is supported by pygame and will be a better option instead of using
PyOpenGl?

 

 

Thanks,

 

Sibtey Mehdi