Language:
C     Change language:
Pastebin: 92232
Author: Anonymous
Subject: Untitled
Created: 2008-07-22 16:56:31
Download and save
Toggle line numbers
1-- global table of methods and Image-related functions 
2Image = {} 
3-- constructor 
4function Image.new(x,y) ... end 
5-- a member function 
6function Image:color_allocate(r,g,b) ... end 
7-- the rest go here 
8 
9 
10-- metatable for images 
11local image_mt = {} 
12-- refer lookups to the global table of methods 
13image_mt.__index = Image 
14-- don't let people play with the metatable 
15image_mt.__metatable = Image 
16-- garbage collection 
17function image_mt:__gc() ... end 
18-- stringification 
19function image_mt:__tostring() return ("image: "..self.width.."x"..self.height) end 
20 
21-- now, if we want an Image, we just create the userdata 
22-- and then use setmetatable() to associate image_mt with it 
Thread:
[92232] Untitled by Anonymous at 2008-07-22 16:56:31
Tip: Click the line numbers to toggle highliting on that line.

Paste followup:

Language:
Author:
Subject:


    Tabstop:     bigger biggest
Note: You can prefix a line with "@@@" to highlight it.