Navigation

Recent site activity

Home‎ > ‎

Code projects



You're welcome to post me comments to my project pages at pygame.org or contact me via ranta.tero gmail

    Python


Python :   www.python.org
Pygame :    www.pygame.org
I am a real fan of Guido :-) -- He is a one of the most genious persons of the time

    The little snake fun as the sketch group


Hello world made easy

print "Hello world!"

Make it even cooler with pygame

# Import modules
import pygame
from pygame.locals import *


salutation = "Hello World !"

# Initialize
pygame.init ()
size = (256, 128)
window = pygame.display.set_mode ( size )

hellofont = pygame.font.SysFont ( 'courier', 16, True, True )
hellosurf = hellofont.render ( salutation, 1, Color("white") )
hellorect = window.blit ( hellosurf, (16, 16) )
pygame.display.update ( hellorect )

# Loop
loop = True
while loop is True:
   
    for evnt in pygame.event.get ():
       
        if evnt.type is QUIT:
            loop = False
           
        if evnt.type is KEYDOWN:
           
            if evnt.key == K_ESCAPE:
                loop = False

            if evnt.key == K_RETURN:
                window.fill ( Color("black"), hellorect )
                pygame.display.update ( hellorect )

    pygame.time.wait(250) # waiting 250 milliseconds makes it not too hasty


# Quit
pygame.quit ()



    Pyctor




Here an extract of an example session which produced the image above.

Example, version 1.5


name: math_art_1.bmp
size: 256, 256

valid parameters in functions are

    b      blue
    rfunc  red function
    g      green
    h      256
    gfunc  green function
    r      red
    bfunc  blue function
    w      256
    y      vertical position
    x      horizontal position
    size   (256, 256)

red function: x**2+y**2
green function: (x-w)**2+(y-h)**2
blue function: (x-w/2)**2-(y-h/2)**2

With the second version



Example, version 2

       ** Pyctor 2.0 **

Welcome!

Controls
To animate : SPACE bar
Zoom out   : -        
Zoom in    : +        
To scroll  : Arrow keys
To save    : ENTER key
To quit    : ESC key  
- What is your name?
  If you skipped, I would try to seek your username.
-
Tero
- What is the title of your work?
- Oceans
Oceans
Valid parameters for color component functions:

    rand : <random.Random object at 0x00CB5EA8>
    b : blue
    rfunc : red function
    g : green
    oy : 0
    h : height
    zoom : 0
    gfunc : green function
    r : red
    t : time
    w : width
    ox : 0
    y : vertical position
    x : horizontal position
    bfunc : blue function

Define your functions

Red
x**2-y**2

Green
128*sin(x/60)

Blue
64+?randint(-16,16)

Rendering begins
Rendering done
Your artwork has been saved in Oceans.bmp
Also your functions are saved in Oceans.txt
Thanks, goodbye :)


Version 2.3
http://docs.google.com/Doc?id=dcsh3bv7_1f7wk3gdj


    Platforms

  • Platform indenpendent
  • SDL

    Versions

released versions

  • 1.5
  • 2.0
  • 2.2
  • 2.3
  • 2.5
  • 2.7
  • 2.8
  • 2.9
  • 3.0 (26 Apr, 2009)

     

    Features

  • > 1.5
    • Draws bitmap images according to user defined mathematical functions supporting
      • logical operations, bitwise operations
      • polynomial
      • trigonometry
      • exponent
      • logarithm
      • hyperbolical
      • or any other built-in function supported by python, e.g. abs, min, max
    • Saves a bimap file
  • > 2.0
    • Can save a text file that contains the functions and general information of the work
    • Can load an image from a text file described above, command line arguments needed
    • Zoom
    • Scroll
    • Possible animation
    • Resizable window (animation must be on)
  • > 2.3
    • Bug fix : math functions now really usable
    • Use math functions via "math." or simply with a dollar tag "$"
    • Use random methods via "rand." or with a question tag "?"
  • > 2.5
    • Instant response to user's actions
    • Object oriented design
    • Far better than earlier versions
  • > 3.0
    • Better scrolling and zooming
    • Optimizations

Feature test results (the latest release)
  • Making a new work - Yes
  • Saving - Yes
  • Loading - Yes
  • Smooth behavior - Yes
  • Animation - N/A
  • Scrolling - Yes
  • Zooming - Yes

    Library dependencies

  • pygame <=1.8.1 release
  • math (built-in)
  • sys (built-in)
  • os (built-in)
  • random (built-in)

    Screenshots





Pyctor :     www.pygame.org
                   http://code.google.com/p/pyctor/



    WebKLF


WebKLF 2
It is a python application powered by pygame to retrieve a specific information from an Internet source.
In this case it is specifically got from the html source of www.klf.fi
Myself, I like much the interface in the application.

The projects has been configured on Windows XP with Python 2.6.
It would be nice if some of you tried this out on another platform. Some of the features might not work on every one.


    Platforms


  • Windows XP or higher, Vista
  • Linux


    Features


  • Withdraw and display of information from www.klf.fi
  • Colored text on console window (Win)
  • Optional username search from OS environment variables (Win)


    Library dependencies


  • pygame <=1.8.1 release
  • os
  • sys
  • urllib2


    Screenshots





    Webget


It is a python pygame powered application to retrieve a specific information from an Internet source.
It is flexible so that users can define their keyword and url.
It is based on WebKLF, which is an earlier project of mine.


The projects has been configured on Windows XP with Python 2.6.
It would be nice if some of you tried this out on another platform. Some of the features might not work on every one.


    Platforms


  • Windows XP or higher, Vista
  • Linux


    Features


  •  Retrieval and display of information from url
  •  Colored text on console window (Win)
  •  Optional username search from OS environment variables (Win)


    Version

  •    1.0 (?)
  •    It is a parallel version of WebKLF 2
  •    According to that the version number could be else.


    Library dependencies


  •  pygame <=1.8.1 release
  •  os, sys, urllib2


    Screenshots


    Known problem issues


  •  It does not work with all web sources.
  •  Possible omission of the first letter of the title
  •  Status: waiting for ideas to improve it

Comments

tero ranta - May 10, 2009 3:41 AM

Just testing out the comment feature here.