Hi, Chris,
On 11-mei-2006, at 15:09, <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
wrote:
Hi list inhabitants,
Here's what I've got so far (it's kinda fun, but not really good)
(really dirty behaviour, needs serious refactoring, and you need an
8-bit member named "bol", just a black dot fading out at the edges)
Part of the behaviour is a rip of from a behaviour by Dave Mennenoh
(I'm pretty lazy :) ) I ripped the angle-calculation from the
follow mouse thing in the director library.
Here goes:
Frankly, I don't really understand what all the fiddling with quads
is good for.
Below is a behavior that produces a reasonable smear brush effect,
using a circular matte (created from the member "bol" as in your
script).
The effect becomes less convincing if you move the mouse very
quickly, causing the individual copypixels commands to be widely
spaced, but that could be fixed by recording the mouse locations in a
list during a stroke, and asynchronously handling the associated
paint actions (too much work to whip up quickly right now).
You could let the effect taper out by reducing the size of the matte
and the scrRect and trgRect variables dynamically.
You might consider creating an array of different sized mattes in the
beginsprite handler for this purpose.
BTW: it's assumed that the sprite with the image you draw into is
aligned with the top left of the stage. If it isn't you'll need to
adjust for the offset.
Have fun!
property p_dragging
property p_lastLoc
property p_maskImage
property p_halfWidth
property p_OS_buffer
property p_member
property p_maskOffset
property p_maskWidth
on beginSprite me
p_member = sprite(me.spriteNum).member
p_OS_buffer = p_member.image.duplicate()
maskWidth = member("bol").width -- assuming it's not oval
p_maskWidth = maskWidth + 16 -- some extra space around the matte
to avoid edge effects
p_maskOffset = point(p_maskWidth / 2, p_maskWidth / 2)
p_maskImage = image(maskWidth, maskWidth, 8, #grayscale)
p_maskImage.copyPixels(member("bol").image, p_maskImage.rect,
member("bol").rect)
end beginSprite
on mouseDown me
p_dragging = true
p_lastLoc = _mouse.mouseLoc
end mouseDown
on mouseUp me
p_dragging = false
end mouseUp
on mouseUpOutside me
p_dragging = false
end mouseUpOutside
on exitFrame me
if p_dragging then
newLoc = _mouse.mouseLoc
srcRect = (rect(p_lastLoc,p_lastLoc)).inflate
(p_maskWidth,p_maskWidth)
trgRect = (rect(newLoc,newLoc)).inflate(p_maskWidth,p_maskWidth)
p_OS_buffer.copyPixels(p_OS_buffer, trgRect, srcRect,
[#maskImage:p_maskImage, #maskOffset:newLoc - p_maskOffset])
cp_rect = srcRect.union(trgRect)
p_member.image.copyPixels(p_OS_buffer,cp_rect, cp_rect)
p_lastLoc = newLoc
end if
end exitFrame
Mark Hagers
[EMAIL PROTECTED]
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[email protected] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]