Re: [pygame] MMX Transform for Win32
On Sat, Mar 8, 2008 at 8:03 PM, Richard Goedeken < [EMAIL PROTECTED]> wrote: > Regarding your previous message, I presume you are referring to > transforming a > rectangular pixel map into an arbitrary quadrilateral? Yes.
Re: [pygame] MMX Transform for Win32
The pygame.transform.smoothscale.__doc__ gives the usage information. It scales an image smoothly (and quickly, with the MMX code) using a bilinear filter for upsampling and a novel area-based filter for downscaling which minimizes moire patterns on highly downscaled images. Each axis can be scaled independently (ie, there's no requirement to keep the same aspect ratio). My goals in writing this routine were to achieve high image quality and high speed. Regarding your previous message, I presume you are referring to transforming a rectangular pixel map into an arbitrary quadrilateral? It would be easy enough to write a C function to do this but it would be slow. Writing accelerated (MMX) code for this type of routine would be time-consuming, and it wouldn't achieve the same level of speedup that I got with the smoothscale function. Richard Ian Mallett wrote: Thanks. How can one use this with Python?
Re: [pygame] MMX Transform for Win32
Richard Goedeken wrote: I think I posted it on this email list when it was done; maybe noone merged it into the SVN tree? I don't think I have write access to SVN, otherwise I would have merged it. I have attached a zip file with the code. Richard Jason Ward wrote: I just looked in transform.c and I haven't seen any asm code at all. maybe point me to a function name or a code line number The assembler code is in SVN. The code is in routines: filter_shrink_X_MMX, filter_expand_X_MMX, filter_shrink_Y_MMX and filter_expand_Y_MMX. -- Lenard Lindstrom <[EMAIL PROTECTED]>
Re: [pygame] MMX Transform for Win32
Thanks. How can one use this with Python?
Re: [pygame] MMX Transform for Win32
Can we add a transform feature to stretch a rectangle to a new size--but not necessarily rectangular?
Re: [pygame] MMX Transform for Win32
Marcus von Appen wrote: The code first needs to be brought into shape (there are some minor issues, if I remember correctly) and be sync'ed with the latest changes in SDL_gfx. At least the parts taken from it. Regards Marcus I added a new function to the transform module called 'smoothscale'; it's all computed in software and doesn't use anything from SDL_gfx. Do you have a list of the problems encountered with this function? Richard
Re: [pygame] Google summer of code, and pygame. Where Google pays students to work on pygame.
Cool, that'd be good. Start thinking of ideas for projects you'd want to work on, and I'll let you know the outcome of our application. Of course if they don't let 'pygame' in you should still be able to do stuff under the python organisation, or maybe even OLPC. Here's the list of ideas so far: http://www.pygame.org/wiki/gsoc2008ideas cu, On Fri, Mar 7, 2008 at 8:10 AM, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > René Dudfield wrote: > > Hello, > > > > We've almost got pygame 1.8 released! ya! Once that's done, we'll > > have to figure out what we want to do for the next release... but on > > another note, there's this google summer of code thing coming up GSoC( > > http://code.google.com/soc/2008/ ). It's where google pays students > > $4500 to work on open source projects for three months. > This is pretty exciting, Rene! > I'm a student currently, and I'm planning on doing a Summer of Code > project. I'll apply for a Pygame one if you guys get accepted. > Thanks for letting us know, > -Luke >
Re: [pygame] MMX Transform for Win32
I just looked in transform.c and I haven't seen any asm code at all. maybe point me to a function name or a code line number
Re: [pygame] MMX Transform for Win32
On, Sun Mar 09, 2008, Richard Goedeken wrote: > The code is in src/transform.c in the pygame tree. The task at hand is to > translate the 32-bit MMX code (I think there's 4 sections of code, each > about 40-60 lines) from the AT&T syntax used by GCC to the Intel style used > by VC. The Intel format is compatible with masm, nasm, yasm, etc. It's > pretty easy to read. The AT&T style is quite powerful but very strange > looking, and if you don't have an inclination to learn a bit about it then > the translation would be very hard. Take a look at it and let me know if > you want to take a crack at it. I could always proof-read it. The code first needs to be brought into shape (there are some minor issues, if I remember correctly) and be sync'ed with the latest changes in SDL_gfx. At least the parts taken from it. Regards Marcus pgpgWEETAm5gt.pgp Description: PGP signature
Re: [pygame] MMX Transform for Win32
The code is in src/transform.c in the pygame tree. The task at hand is to translate the 32-bit MMX code (I think there's 4 sections of code, each about 40-60 lines) from the AT&T syntax used by GCC to the Intel style used by VC. The Intel format is compatible with masm, nasm, yasm, etc. It's pretty easy to read. The AT&T style is quite powerful but very strange looking, and if you don't have an inclination to learn a bit about it then the translation would be very hard. Take a look at it and let me know if you want to take a crack at it. I could always proof-read it. Richard Jason Ward wrote: what is this MMX discussion about and the transform function? If this is to do with pygame source I may be interested. but not to solely do it, just to give a rather small helping hand. I know intel asm but I haven't really gotten into MMX so this would be a great opportunity for me to get into it. So I might be able to help you do it Richard. Just direct me in exactly what it is :)
Re: [pygame] MMX Transform for Win32
what is this MMX discussion about and the transform function? If this is to do with pygame source I may be interested. but not to solely do it, just to give a rather small helping hand. I know intel asm but I haven't really gotten into MMX so this would be a great opportunity for me to get into it. So I might be able to help you do it Richard. Just direct me in exactly what it is :)
Re: [pygame] Event Stack Weirdness
Kris Schnee wrote: Lenard Lindstrom wrote: pygame.quit() must be explicitly called since atexit functions are not executed until IDLE's nteractive interpreter is either closed or restarted. What are the atexit functions, though, that interfere in this very specific case? The atexit module allows one to register exit handlers that are called when Python exits. pygame.quit is one of those. But the IDLE interactive interpreter process does not quit when the pygame program finishes, so pygame.quit is not called. This may be the problem, especially since everything works fine when IDLE is terminated and restarted. Note on Window IDLE only runs one process if a file is opened for "Edit with IDLE". -- Lenard Lindstrom <[EMAIL PROTECTED]>
[pygame] MMX Transform for Win32
VC is not clever enough to vectorize the C code and emit MMX instructions. :) If no-one else volunteers, I can translate the code to intel-style inline ASM. It might take a week or two to get it done, though. Richard On Mon, Mar 3, 2008 at 1:16 PM, Lenard Lindstrom <[EMAIL PROTECTED] Slightly off topic, but one thing I remembered is that the MMX scaling code Richard Goedeken so generously donated in not used in Visual C builds. The MMX code is in AT&T form, not used by masm. So the options are to add an masm translation of the code to transform.c or just use the MinGW compiled transform.pyd. Of course VC may be clever enough to do its own MMX optimization.
Re: [pygame] TTS and Pitch Parameter
"Gary BIshop" <[EMAIL PROTECTED]> Wrote: I repeat, pyTTS, at least the version 3.0 that I have, does not have a method or property named Pitch. You are, I think simply assigned those values to an instance variable that you are adding to the tts object. Do you hear the pitch change when you assign to the pitch variable? Gary, I do not know why I thought there was a pitch command. I did a test just in python and could not get it to work. Do not know what or where I was when I thought there was a pitch command. so, could not duplicate it. Below is the modifications to the maze game you could test and run. I left the pitch in there but it is just an instance, and does not affect anything. I changed, modified the game for volume and rate. I also give it voices to change and also a good bye message. Bruce # Pyramid Puzzles # A Maze Exploration Game # By Shane Dittmar And Gary Bishop # Version 1.0 # use the arrow keys to play. Up arrow moves you forward. Left arrow turns 90 degrees left. # Right arrow turns 90 degrees right. Down arrow turns around 180 degrees. Escape quits. # # Listen for the hint in the sound of the wind. # Load Modules import pygame from pygame.locals import * import random, sys import time import math import pyTTS tts = pyTTS.Create() tts.Volume = 70 tts.Pitch = 1 # go to the program directory import os mydir = os.path.dirname(sys.argv[0]) if mydir: os.chdir(mydir) # Constants -- cell marks BOTTOMWALL = 0 RIGHTWALL = 1 VISITED= 2 PATH = 3 # Directions. I have numbered them so adding 1 rotates right and subtracting one rotates left NORTH = 0 SOUTH = 2 WEST = 3 EAST = 1 class Maze: def __init__( self, n_rows, n_cols ): """Create a maze with given number of rows and cols. member variable longest_path is the sequence of cells you pass through to get to the end. """ self.n_rows = n_rows self.n_cols = n_cols self.maze = [ [ [True,True,False,tuple()] for c in range(n_cols) ] for r in range(n_rows) ] self.longest_path = tuple() # will be the longest path through the maze def randomize( self ): # Choose a random end point currCol = random.randrange(self.n_cols) currRow = random.randrange(self.n_rows) # The search can be quite deep if self.n_rows*self.n_cols > sys.getrecursionlimit(): sys.setrecursionlimit( self.n_rows*self.n_cols+5 ) # Recursively Remove Walls - Depth First Algorithm self._make_path( currRow, currCol, tuple() ) #* def _make_path( self, R, C, path, D=None ): '''Used internally to generate the maze.''' maze = self.maze # speed up a bit maze[R][C][PATH] = path # track the longest path path = ((R,C),) + path if len(path) > len(self.longest_path): self.longest_path = path # Knock out wall between this and previous cell maze[R][C][VISITED] = True; if D==NORTH: maze[R] [C] [BOTTOMWALL] = False elif D==SOUTH: maze[R-1][C] [BOTTOMWALL] = False elif D==WEST: maze[R] [C] [RIGHTWALL] = False elif D==EAST: maze[R] [C-1][RIGHTWALL] = False # Build legal directions array directions = [] if R>0: directions.append(NORTH) if R0: directions.append(WEST) if C len(self.longest_path): self.longest_path = path # note that we've been here maze[R][C][VISITED] = True; # Build directions array directions = [] if R>0 and not maze[R-1][C][BOTTOMWALL]: directions.append(NORTH) if R0 and not maze[R][C-1][RIGHTWALL]: directions.append(WEST) if C 0: return SOUTH, distance if dc > 0: return EAST, distance if dc < 0: return WEST, distance def openings(self, row, col): '''For each direction indicate if there is an opening''' result = [False]*4 result[NORTH] = row>0 and not self.maze[row-1][col][BOTTOMWALL] result[SOUTH] = not self.maze[row][col][BOTTOMWALL] result[EAST] = not self.maze[row][col][RIGHTWALL] result[WEST] = col>0 and not self.maze[row][col-1][RIGHTWALL] return result def __str__(self): """Return a simple visual representation of the maze in ASCII""" if self.longest_path: result = str((self.longest_path[0],self.longest_path[-1]))+'\n' else: result = '((-1,-1),(-1,-1))\n' result += '.' + self.n_cols*'_.' result += '\n' for i in range(self.n_rows): result += '|' for j in range(self.n_cols): if i==self.n_rows-1 or self.maze[i][j][BOTTOMWALL]: result += '_' else: result += ' ' if j==self.n_cols-1 or self.maze[i][j][RIGHTWALL]: result += '|
Re: [pygame] Perspective Test
Julia wrote: Awesome code Kamilche. I really like it. I'm going to put it in my favorites folder :) Thanks, glad you enjoyed it! I should probably mention I was inspired to create this code after reading an explanation of one point perspective at this site: http://www.olejarz.com/arted/perspective
Re: [pygame] TTS and Pitch Parameter
I repeat, pyTTS, at least the version 3.0 that I have, does not have a method or property named Pitch. You are, I think simply assigned those values to an instance variable that you are adding to the tts object. Do you hear the pitch change when you assign to the pitch variable? I include a session in ipython below. You can see that while tts.Rate is identified as a property, tts.Pitch is not found. gb In [2]: tts=pyTTS.Create() In [3]: tts.Rate? Type: property Base Class: String Form: Namespace: Interactive Docstring: @return: Rate of speech, typically in the range of [-10, 10] @rtype: integer Class Docstring: property(fget=None, fset=None, fdel=None, doc=None) -> property attribute fget is a function to be used for getting an attribute value, and likewise fset is a function for setting, and fdel a function for del'ing, an attribute. Typical use is to define a managed attribute x: class C(object): def getx(self): return self.__x def setx(self, value): self.__x = value def delx(self): del self.__x x = property(getx, setx, delx, "I'm the 'x' property.") In [4]: tts.Pitch? Object `tts.Pitch` not found. In [5]: FT wrote: Hi! Below is the speech.py file which will load in python25 from my windows OS. It uses the same command as in the pygame example, no different. So, the same import should be in affect, except if pygame uses these same commands, the pitch does not work.
Re: [pygame] Perspective Test
Awesome code Kamilche. I really like it. I'm going to put it in my favorites folder :) /J On Sat, Mar 8, 2008 at 5:51 AM, Kamilche <[EMAIL PROTECTED]> wrote: > Here's a perspective test I wrote, that I thought others might find > enjoyable. It illustrates a single-point perspective (a 'vanishing > point'), and shows how a room with a floor, ceiling, door, and avatar > changes as the vanishing point changes. > > > import pygame, os, sys, urllib > > SCREENSIZE = (1024, 768) > BACKCOLOR = (150, 150, 150) > INVISIBLE = ( 0, 0, 0, 0) > PERSPECTIVECOLOR= ( 0, 0, 0, 128) > PERSPECTIVEWIDTH= 2 > WALLCOLOR = (255, 128, 0, 220) > WINDOWCOLOR = ( 0, 64, 200, 100) > DOORCOLOR = (100, 64, 50, 200) > CEILINGCOLOR= (255, 255, 255, 255) > FLOORCOLOR = (121, 74, 81, 255) > HORIZONCOLOR= ( 0, 128, 0, 200) > VPCOLOR = (255, 0, 0, 255) > WALLDEPTH = .35 > > VANISHINGPOINT = (SCREENSIZE[0]/2, SCREENSIZE[1]/2) > > bg = None > temp = None > girl = None > > def CalculatePoint(depth, point): > xa, ya = VANISHINGPOINT > xb, yb = point > xbb = xa + depth * (xb-xa) > ybb = ya + depth * (yb-ya) > return int(xbb), int(ybb) > > def Intersection(a,b,c,d): > Ax,Ay = a; Bx,By = b; Cx,Cy = c; Dx,Dy = d > u = float((Dx-Cx)*(Ay-Cy)-(Dy-Cy)*(Ax-Cx)) / > float((Dy-Cy)*(Bx-Ax)-(Dx-Cx)*(By-Ay)) > x = Ax + u*(Bx-Ax) > y = Ay + u*(By-Ay) > return int(x),int(y) > > def DrawWall(): > w, h = SCREENSIZE > topleft = CalculatePoint(WALLDEPTH, (0, 0)) > topright = CalculatePoint(WALLDEPTH, (w, 0)) > bottomleft = CalculatePoint(WALLDEPTH, (0, h)) > bottomright = CalculatePoint(WALLDEPTH, (w, h)) > pos = topleft > wallwidth = int(topright[0]-topleft[0]) > wallheight = int(bottomleft[1]-topleft[1]) > temp.fill(WALLCOLOR) > bg.blit(temp, topleft, [0, 0, wallwidth, wallheight]) > pygame.draw.lines(bg, PERSPECTIVECOLOR, 1, [topleft, topright, > bottomright, bottomleft], PERSPECTIVEWIDTH) > > def DrawOrthogonals(): > pygame.draw.line(bg, PERSPECTIVECOLOR, (0, 0), VANISHINGPOINT, > PERSPECTIVEWIDTH) > pygame.draw.line(bg, PERSPECTIVECOLOR, (SCREENSIZE[0], 0), > VANISHINGPOINT, PERSPECTIVEWIDTH) > pygame.draw.line(bg, PERSPECTIVECOLOR, (0, SCREENSIZE[1]), > VANISHINGPOINT, PERSPECTIVEWIDTH) > pygame.draw.line(bg, PERSPECTIVECOLOR, SCREENSIZE, VANISHINGPOINT, > PERSPECTIVEWIDTH) > pygame.draw.line(bg, HORIZONCOLOR, (0, VANISHINGPOINT[1]), > (SCREENSIZE[0], VANISHINGPOINT[1]), PERSPECTIVEWIDTH) > > def DrawDoor(): > w, h = SCREENSIZE > topleft = CalculatePoint(.9, (0, .25*h)) > topright = CalculatePoint(.7, (0, .25*h)) > bottomleft = CalculatePoint(.9, (0, h)) > bottomright = CalculatePoint(.7, (0, h)) > pos = topleft > windowwidth = int(topright[0]-topleft[0]) > windowheight = int(bottomleft[1]-topleft[1]) > lst = [topleft, topright, bottomright, bottomleft, topleft] > temp.fill(INVISIBLE) > pygame.draw.polygon(temp, DOORCOLOR, lst) > bg.blit(temp, [0, 0]) > pygame.draw.circle(bg, DOORCOLOR, topleft, 5) > pygame.draw.circle(bg, DOORCOLOR, topright, 5) > pygame.draw.circle(bg, DOORCOLOR, bottomright, 5) > pygame.draw.circle(bg, DOORCOLOR, bottomleft, 5) > > def DrawCeiling(): > w, h = SCREENSIZE > vx, vy = VANISHINGPOINT > numtiles = 8 > for i in range(0, SCREENSIZE[0]+1, SCREENSIZE[0]/numtiles): > pygame.draw.line(bg, CEILINGCOLOR, (i, 0), VANISHINGPOINT, 1) > > # Calculate horizontal lines > topright = CalculatePoint(WALLDEPTH, (w, 0)) > for i in range(0, SCREENSIZE[0]+1, SCREENSIZE[0]/numtiles): > try: > x, y = Intersection((0, 0), topright, (i, 0), VANISHINGPOINT) > left = Intersection([0, y], [w, y], (0, 0), VANISHINGPOINT) > right = Intersection([0, y], [w, y], (w, 0), VANISHINGPOINT) > pygame.draw.line(bg, CEILINGCOLOR, left, right, 1) > except: > pass > #pygame.draw.line(bg, CEILINGCOLOR, (0, 0), topright, 1) > > def DrawFloor(): > w, h = SCREENSIZE > factor = 4 > for i in range(-w*factor, w*2*factor, 100): > pygame.draw.line(bg, FLOORCOLOR, (i, h), VANISHINGPOINT, 1) > > def DrawGirl(): > w, h = SCREENSIZE > data = [(.8, (75, h)), (.9, (w/2+50, h)), (WALLDEPTH+.05, (150, h))] > data.sort() > for depth, dest in data: > pt = CalculatePoint(depth, dest) > resizedgirl = pygame.transform.rotozoom(girl, 0, depth) > bg.blit(resizedgirl, [pt[0]-resizedgirl.get_width()/2, > pt[1]-resizedgirl.get_height()]) > pygame.draw.circle(bg, (0, 0, 255), pt, 5) > > def Text(s, _font = []): > if len(_font) == 0: > font = pygame.font.Font(None, 24) > _font.append(font) > font = _font[0] > shadow = font.render(s, 1, (0, 0, 0)) > color = font.render(s, 1, (255