1
$\begingroup$

Using Python I'm trying to generate a texture with a few lines and text.

I've got a proof of concept using Pillow and a function to convert from PIL Image to Blender Image, but I would like to avoid having the extra dependency.

Is there a built-in 2D Graphics API I could use to draw shapes and rasterise/sample pixels for a texture ?

I had a look at the Grease Pencil API which looks great for drawing. Would it be possible to get an Image/pixels from Grease Pencil ? If so, how ?

$\endgroup$
0
$\begingroup$

Unfortunately I haven't found a way to easily render text using the GreasePencil API nor a way to capture GreasePencil text/lines into a texture (Blender Image).

I ended up using PIL and copying the pixels over to a Blender Image (method described here). Other than the conversion using [:] to access pixels slightly faster the other speed up was using a bitmap font (as opposed to a true type font which was slow to rasterize):

font = ImageFont.load(os.path.join(os.path.dirname(os.path.abspath(__file__)),"fonts","haxor.pil"))
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.