hello,
since 1.1.3 the following code doesnt work :-(
http://www.bigbold.com/snippets/posts/show/377
perhabs someone can correct this.
thanks patrick
hello,
since 1.1.3 the following code doesnt work :-(
http://www.bigbold.com/snippets/posts/show/377
perhabs someone can correct this.
thanks patrick
OK, OK.... I will correct it.
See a new version here.
http://www.bigbold.com/snippets/posts/show/407
Last edited by korakotc; 2005-06-21 at 13:09.
I try to 'look' into the new canvas API.
Here is what I found.
Most drawing functions are moved from canvas to
the new graphics module. It has the following
drawing command
point, line, rectangle, ellipse, arc, pieslice, polygon
You can also write text (with font,color) with 'text'.
You can insert an image with 'blit'
The parameters for most methods are similar:
draw.rectangle(coords, outline, fill, width, pattern)
coords = sequence of x,y ; either [x,y,x,y] or [(x,y),(x,y)]
outline = line color ; either [r,g,b] or 0xrrggbb
fill = fill color ; same
width = line width (default is 1)
pattern = Image object to be background
Here are what you typically call:
draw.point((x,y),0xff0000,width=2)
drwa.line([10,10, 50,50], 0xff0000, width=2)
draw.rectangle([10,10,50,50] ,outline=0x00ff00, fill=0xff0000, pattern=im)
draw.ellipse(....) # same as rectangle
draw.arc(coords, start, end, outline, fill, width, pattern) # start & end is in radian
# draw.pieslice same as draw.arc
draw.polygon( [10,10,10,40,40,10], 0] # black triangle
draw.text((x,y), text, fill, font)
draw.blit(image, source=sourcerect, target=targetrect, scale=0, mask=bit_image) # rect is (0,0,20,20)
# if source != target and scale ==1, it will scale
# you create a 1-bit mask with Image.New(size, mode='1')
You can open & save image
from graphics import *
im = Image.open(filename)
im.save(filename)
An easy way to create image is
im = screenshot() # capture screen shot
You can resize image and rotate (transpose) image
as well
(see graphics.py)
Before drawing into image or screen, please wrap it with Draw(), like this
c = Canvas()
draw = Draw(c)
im = Image.open(filename)
draw = Draw(im)
(Without this, it still works sometimes though)
What is missing is how to 'read' data from
each pixel in the image.
I expect an image._bitmapapi() to provide something
like .GetPixel (of the underlining BitMap). But no, it provide nothing but a bitmap object to pass to Image.from_cfbsbitmap(..)
Please provide getpixel! Please!!!
An example of creating 'circle' function.
http://www.bigbold.com/snippets/posts/show/410
Note that using the separate Draw object is no longer necessary from 1.1.2 onwards, since a Draw object is now automatically created by Image and Canvas and the Draw methods can be invoked on Canvas and Image directly.Originally posted by korakotc
I try to 'look' into the new canvas API.
Here is what I found.
Before drawing into image or screen, please wrap it with Draw(), like this
c = Canvas()
draw = Draw(c)
im = Image.open(filename)
draw = Draw(im)
(Without this, it still works sometimes though)
It just seemed so ugly to have to create a separate Draw object for each Canvas and Image. So, although the graphics module includes the method for creating explicit Draw objects and that works, users probably won't have any need to create Draw objects explicitly.
Last edited by jplauril; 2005-06-23 at 15:24.
Please update the examples (snake, ball, tetris, etc.) accordingly.Originally posted by jplauril
It just seemed so ugly to have to create a separate Draw object for each Canvas and Image. So, although the graphics module includes the method for creating explicit Draw objects and that works, users probably won't have any need to create Draw objects explicitly. [/B]
Many people (like me) will typically choose an example and
modify it to get a different (but similar) app.
I look forwards to the documentation ... or the new version....
Whatever comes first.![]()
I'll be the new version ;-) The 1.1.4 build was submitted this week. Hopefully that means it will be available for download next week. Unfortunately, the updated documentation wasn't in the mix. I'm pretty sure the editing schedule has the docs being finished next week though...Originally posted by korakotc
I look forwards to the documentation ... or the new version....
Whatever comes first.![]()
Here are more examples:
- Creating sparkline
http://www.bigbold.com/snippets/posts/show/413
- 15-Square game
http://www.bigbold.com/snippets/posts/show/414
Developing scripts in emulator is very convenient.
I wouldn't have finished them if I had used my old 'sending by bluetooth' method.
Does it typically take a week or more beforeOriginally posted by eriksmartt
The 1.1.4 build was submitted this week. Hopefully that means it will be available for download next week.
what you submitted is available?
Could you give a short glimpse of what's new in 1.1.4?
Yeah, a week is probably right, but I suppose it can vary. The 1.1.4 seems to have been delayed though. There were some changes to one of the publishing systems... long story. Anyway, at this rate, the 1.1.5 release will probably be the next out. (And yes, the documentation will be included with this one :-)Originally posted by korakotc
Does it typically take a week or more before
what you submitted is available?
1.1.5 was sent to FN this morning, so it should be there in a few days. This release includes the completely updated documentation.
If you interrupt playing the 15 square game from
http://www.bigbold.com/snippets/posts/show/414
for more than a certain period of time
the screen saver (or whatever) removes the numbers
from the screen but you can get them back out of nowhere
using the mouse stick. Is this a bug or a surprising feature of the code?
PS: I am using the latest (1.1.6) fast build.
Screensaver will typically clear the screen.
I didn't write a 'redraw' function to give to canvas.
So, it will update only the movement of each square.
Adding a redraw function that draw all the 15 squares
according to the current state will solve this.