Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] - anti-aliased drawing functions to memblocks

Author
Message
Phaelax
DBPro Master
15
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Sep 2013 18:16 Edited at: 26th Sep 2013 18:24
I wrote a set of anti-aliased drawing routines that write directly to an image memblock. This is useful for creating custom graphics while preserving background transparency.

The box and circle commands can draw either an outline or filled-in. I'm still in the process of adding other commands for gradient filles, but the circle has a radial gradient function.

makeMemblockImage(memblock_num, width, height, fill_color)
mem_circle(memblock_num, centerX, centerY, radius, color, fill, preseveBackground)
mem_circle_gradient_radial(memblock_num, centerX, centerY, radius, innerColor, outerColor, gradient_centerX, gradient_centerY, gradient_radius, preseveBackground)
mem_rounded_box(memblock_num, x1, y1, x2, y2, radius, color, fill, preseveBackground)
mem_line(memblock_num, x1, y1, x2, y2, color, preseveBackground)
mem_box(memblock_num, x1, y1, x2, y2, color, fill, preseveBackground)



The preserveBackground option does just what it says. If turned off, the drawing routine will overwrite any pixel data currently in its pixels' positions. If turned on, it will use a form of alpha compositing to blend the drawing operation on top of any current data. It has a few quirks here and there, but works well in most situations.


Demo



Library



The shapes in the screenshot were all drawn to a single image.


Attachments

Login to view attachments

Login to post a reply

Server time is: 2019-02-17 08:23:20
Your offset time is: 2019-02-17 08:23:20