Computer Science Canada

Lua and Python Question

Author:  clydex [ Wed May 26, 2010 11:40 pm ]
Post subject:  Lua and Python Question

Hi, i'm fairly new to python, and am trying to port something from lua into python.


    --[[
    bell = Image.createEmpty(20,20)
    bell:clear(Color.new(255,255,255))]]
    bell = bell or Image.load("bell.png")
    bell_width = bell:width()
    bell_height = bell:height()


I'm wondering what the first and last 2 lines do to the image, and how I would code that in python. Thank you.

Author:  BBil [ Thu Nov 11, 2010 5:07 pm ]
Post subject:  Re: Lua and Python Question

bell_width = bell:width()
bell_height = bell:height()

This looks eerily similar to a couple lines of code from something i made. keep in mind that I am using pygame

self.width=self.pirate.get_width()
self.height=self.pirate.get_height()

So this pretty much just sets up 2 variables to be the exact same width and height of a picture (surface in pygame lingo)
Canada Canada Canada Canada Canada

Author:  jcollins1991 [ Thu Nov 11, 2010 10:07 pm ]
Post subject:  Re: Lua and Python Question

The first two lines create an image, then if it's able to load the "bell.png" image it overwrites it. The last two lines don't do anything to the image, they just access the width and height values of the image. I don't think there's anything in the python standard libraries to do image processing, but there are libraries available that might be able to imitate this functionality http://www.pythonware.com/products/pil/


: