HOME | DD
Published: 2008-05-14 13:26:58 +0000 UTC; Views: 8885; Favourites: 40; Downloads: 348
Redirect to original
Description
You can change brush properties while the mouse button is down, by the way.This is an example of high-end brush programming for Flash. Unlike most applets, this one keeps the brush dots spaced evenly so they don't overlap awkwardly. The results are more similar to Photoshop's brushes than an oekaki applet.
How it's done:
Painting is done by putting a bunch of dots where the mouse moves.
The dot is a bitmap of a blurred circle. The bitmap size is (brushRadius+blurRadius)*2. To make the circle, the program tests each pixel in the bitmap and measures its distance from the middle pixel using the pythagorean theorem (X distance squared + Y distance squared = the square of the distance). If the pixel's distance is equal to or smaller than the brushRadius, it's colored black. A blur is then applied. Flash has a bitmap blurring method, but I do it manually by averaging pixels. (it's a little hard to explain)
The canvas is also a bitmap. As you brush, the dot bitmap is added to the canvas bitmap over and over. For transparency, there is an extra canvas bitmap that receives each stroke and places it on the bottom canvas with the desired opacity.
Dot spacing can be customized, but here it's set at .4 of the dot radius. When you click, it adds a dot, then when you drag, it measures the distance between the mouse and the last dot. (distance is measured with the pythagorean theorem - X squared + Y squared equals the square of the distance) If the distance is equal to or greater than the chosen dot spacing, a new dot is placed under the mouse.
Each pixel you move over is tested for distance instead of just given a new dot.
When you move the mouse quickly, it can cross multiple pixels in one frame, so the applet has to add multiple dots along the mouse path. It tests each pixel in the mouse path just like it tests the pixel under the mouse when you're moving slow. It always keeps the position of the last dot added in the stroke so no dots overlap incorrectly.
Related content
Comments: 19
darksky0001 [2012-06-06 20:04:58 +0000 UTC]
Really cool! But you should make it so that you don't press the left/riight arrows, coz they make me go back a page :/
👍: 0 ⏩: 0
creatom [2008-06-21 07:04:14 +0000 UTC]
hm, the link to the fla is broken... can you fix it?
👍: 0 ⏩: 1
Zareste In reply to creatom [2008-06-21 11:03:47 +0000 UTC]
Done. A lot of my files disappeared for some reason
👍: 0 ⏩: 0
ExcellentM [2008-05-16 21:57:23 +0000 UTC]
Yeah!
I like it!
It's very amazing and very fantastic!
Fav of course
👍: 0 ⏩: 0
CaptainCapitalism [2008-05-15 09:09:16 +0000 UTC]
This is pretty cool. Despite working with flash so much, I pretty much suck in the programming department outside of movie control.
👍: 0 ⏩: 0
Fruitful-Gima [2008-05-14 22:46:21 +0000 UTC]
I see that you are playing with programing. Do you plan to make your own photoshop?
👍: 0 ⏩: 1
Zareste In reply to Fruitful-Gima [2008-05-15 01:12:35 +0000 UTC]
Oh I've been doing this a while - did some DOS programming a long time ago. That sorta came to a close when GUI programming and class systems showed up, which I couldn't catch onto thanks to those god-awful programming books that spend 30 pages explaining something I could explain with a paragraph.
It's always been so hard just to alter some pixels on the frickin screen. If I could just control pixels, I could have done anything, but every language has 5,000 functions to draw squares and stars and the damn kitchen sink but you have to dig through the dark depths of the programming book if you want to make a red pixel. If I made a programming language, I would advertise it saying 'YOU CAN ACTUALLY CHANGE FUCKING PIXELS USING THIS LANGUAGE. HOLY SHIT. AFTER 40 YEARS OF COMPUTER SYSTEM ADVANCEMENT YOU NOW HAVE THE ABILITY TO MAKE A PIXEL' and everyone would use it
I'd like to make my own imaging system, sure. One to rule them all
👍: 0 ⏩: 0
BenHickling [2008-05-14 14:29:22 +0000 UTC]
This is looking much nicer than iScribble, I can't stand that program. It's a shame Flash can't access stuff like tablet pressure, otherwise you could have a full-fledged online painting program. It's awesome what AS3 can achieve!
👍: 0 ⏩: 1
Zareste In reply to BenHickling [2008-05-15 01:18:48 +0000 UTC]
Yep, all we needed was a little pixel-control, and now Java is practically obsolete.
I may put together a stand-alone program if my Grid project works out, then we'll have some pen pressure.
👍: 0 ⏩: 0
MaboCorescant [2008-05-14 14:00:30 +0000 UTC]
very very neat! Will you be taking this any farther? Cause other colors or a reset key would be nifty additions!
👍: 0 ⏩: 1
Zareste In reply to MaboCorescant [2008-05-14 22:43:07 +0000 UTC]
Oh, you can push 'delete' to reset. I'll certainly be doing more with this, like making a multi-user setup and adding it to The Grid I've been promising
Come to think of it, maybe I could hack it into a forum so people could post with sketches
👍: 0 ⏩: 0






















