render_text() and image_quad()
The code :
digit 9 in black - drawn with image()
Digit 9 in red - drawn using image_quad()
I'd like to clip the digit using image_quad() , but it seems to me that the image inserted via image_quad() is larger than its image() equivalent (by factor of ca. 1.5).
What am I doing wrong?
The URL does not work for me. Is it a private gist or a public one?
I am sorry, it got truncated, should be https://gist.github.com/anonymous/dfc5685a2b2a49762660
Btw if some automatic scaling is involved, this is on a non-retina iPad mini. Running Pythonista 1.5 on iOS 7.1.2.
With font size 45 the digits start to overlap more, here is with 400:
Do you have a retina device? i wonder if this is a bug in how retina is handled with double resolution. I solved this by doubling the from_x etc params:
image_quad(img, pos, pos, pos+siz.w, pos, pos, pos+siz.h, pos+siz.w, pos+siz.h, 0.,0.,siz.w*2,0,0,siz.h*2,siz.w*2,siz.h*2 )
No, I don't.
I wonder if
scene.render_text()really builds the image or just creates a kind of text layer that gets generated later.
I have achieved what I wanted to do with PIL
ImageFontand it works fine, probably because PIL is actually rendering the text here before moving on.
i think this is an image_quad bug, the optional from parameters are incorrectly scaled, i think by a factor of 2.
image_quad('iob:alert_256',0,0, 256,0,0,256, 256,256,0,0,256,0,0,256,256,256)
produces a clipped image. note, you could also use image with the from parameters if you are just trying to crop. image_quad is for drawing warped quadrilaterals, regular image works fine for rectangles.
(img, siz) = render_text('9','Helvetica',100) rect(pos,pos,siz-6,siz-40) tint(0,0,0) image(img, pos, pos,siz-6,siz-40,3,20,siz-6,siz-40)