Re: [Flashcoders] scribbling an oval

2005-12-28 Thread Serge Jespers
This is what I'm trying to accomplish: http://webkitchen.be/downloads/ 
scribble.jpg


Thanks for your help,
Serge


Can you give us an example of the visual effect you're looking for?  
The simplest I can think of is a kind of 'ribbon' shape, like an  
oval but with two ends crossing over - this is a fairly classic way  
to show the kind of ring someone might draw around eg. a job ad.  
That wouldn't be too hard to describe mathematically.


Danny


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] scribbling an oval

2005-12-28 Thread Danny Kodicek



This is what I'm trying to accomplish: http://webkitchen.be/downloads/
scribble.jpg

Thanks for your help,
Serge


Okay. In that case I think you're best off drawing an ordinary ellipse (or 
possibly a rounded rectangle) but adding some error factor. If you're 
starting from an ellipse, here's what I'd do:


set a and b to the half-axes of the ellipse (I'm assuming the centre is 
(0,0))

set errorFactor to some small value
set wobbliness to some very small value
for q varying between 0 and some angle greater than 2*pi (yours seem to go 
round about three times, so q would go up to about 6*pi)

   set truePoint to (a*sin(q), b*cos(q))
   set normal to (-a*cos(q), b*sin(q))
   draw the point (truePoint + errorFactor * normal)
   set errorFactor to errorFactor + some number between -wobbliness and 
wobbliness


I'll test it out, but that sounds like the right kind of idea to me.

Danny 


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] scribbling an oval

2005-12-28 Thread Danny Kodicek



Right... That does make sense except for the draw the point...
Shouldn't that have an X and Y coordinate?


It does: it's the sum of two other points with an x and y coordinate. I'm 
mostly a Director person so these vector sums are done natively: Flash 
doesn't do anything so useful. But hopefully this should work.


I've just tested it in Lingo, and it works pretty well. If it's any help, 
I've attached the code here. Translating to actionScript shouldn't be too 
hard.


on drawWobble a, b, wobbliness

if voidp(b) then b=random(100)+10

if voidP(a) then a=random(100)+10

if voidP(wobbliness) then wobbliness=(a*a+b*b)/1000.0 -- seems to give 
pretty good results


pts=[]

errorFactor=0

mx=random(100)+50

repeat with i=0 to mx

q=i*8*pi/100 -- average of four loops

p=point(a*sin(q), b*cos(q))

norm=point(b*sin(q) , a*cos(q))

norm=norm/sqrt(norm[1]*norm[1]+norm[2]*norm[2]) -- make it unit length

pts.add(p+norm*errorFactor)

errorFactor=errorFactor+random(100)*wobbliness*0.01-wobbliness/2

if abs(errorFactor)10 then errorFactor=errorFactor*0.95 -- hold it in if 
deviating too far


end repeat

-- add drawing code here

end

HTH
Danny 


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] scribbling an oval

2005-12-28 Thread Sander
Are you trying to position an animated movieClip Serge, or use the  
drawing API to draw scribbles? Because it sound like the suggestions  
you're getting are the latter solution.


S

On 28 Dec 2005, at 12:55, Serge Jespers wrote:


Hey guys,

I'm kinda stuck here... so any help is appreciated.
I'm on this project that has a menu that when you mouse over the  
currently selected menu item gets scribbled around.


Since this is a variable menu, I thought I'd make that oval- 
scribbling dynamic and random. So now I'm trying to make a function  
that returns the next (random) coordinate for my oval shaped  
scribble but that's where I got stuck.


I'm throwing the max width and max height to this function and it  
should just return the next coordinate and end up at a specified  
amount of time as a scribbled oval.


Anyone have any suggestions? I really wish I paid more attention in  
math class now...


Thanks guys,
Serge

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] scribbling an oval

2005-12-28 Thread Danny Kodicek

One final thought and then I'll shut up.

If you want to make your scribble smoother, you can make the randomness 
'second-order'. That is, instead of randomising the change to the error 
factor, you could randomise the *rate* of change of the error factor. So you 
now keep track of two values, errorFactor and wobbliness. At each step, you 
add wobbliness to errorFactor, then change wobbliness by some random amount 
between -wobblewobbliness and wobblewobbliness :). Another advantage of this 
is that it gives you greater control of what happens at the extremes: if 
errorFactor gets greater than a certain amount you can clamp wobbliness in 
the right direction for a few steps until the factor gets within reasonable 
bounds again.


Danny 


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] scribbling an oval

2005-12-28 Thread Serge Jespers

It's supposed to be the drawing API ;-)
Positioning an animated MC would be the easy way and I always seem to  
go for the not so easy way ;-)


I got this far (ahum)  http://webkitchen.be/downloads/scribble.swf
And now I need a mathematician to fix the coordinates :p

Obviously, this is totally wrong ;-) but hey... at least I'm trying  
here ;-)
Oh man... I can totally see my math-teacher laughing his ass off  
right now...


makeOvalCoordinates = function (w, h, p) {
if (p=1) {
nx = w/2;
ny = h/2;
} else {
if (nx= -w/2){
nx -= 10;
} else {
nx+=10;
}
if (ny=-h/2){
ny -= 10;
} else {
ny+=10;
}
}
return {x:nx, y:ny};
};



Are you trying to position an animated movieClip Serge, or use the  
drawing API to draw scribbles? Because it sound like the  
suggestions you're getting are the latter solution.


S


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] scribbling an oval

2005-12-28 Thread Andreas Weber
The sample you originally posted is not accessible anymore, so my take on
this might be off-base:

http://www.motiondraw.com/md/as_samples/t/CatmullRomSpline/scribbledOval.htm
l

This approach is more about 'scribbling' than Math -

First several ovals are manually drawn with this tool
http://www.motiondraw.com/md/as_samples/t/LineGeneralization/demo.html

Now each time the mouse is clicked one of the pre-recorded paths is
selected, some random is applied to its coordinates, it is smoothed again
and finally it is rendered as Catmull Rom spline:
http://www.motiondraw.com/md/as_samples/t/CatmullRomSpline/tween.html

Post again if you need more details/code!

HTH
--
Andreas Weber
motiondraw.com



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Serge
Jespers
Sent: Wednesday, December 28, 2005 2:44 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] scribbling an oval


It's supposed to be the drawing API ;-)
Positioning an animated MC would be the easy way and I always seem to
go for the not so easy way ;-)

I got this far (ahum)  http://webkitchen.be/downloads/scribble.swf
And now I need a mathematician to fix the coordinates :p

Obviously, this is totally wrong ;-) but hey... at least I'm trying
here ;-)
Oh man... I can totally see my math-teacher laughing his ass off
right now...

makeOvalCoordinates = function (w, h, p) {
if (p=1) {
nx = w/2;
ny = h/2;
} else {
if (nx= -w/2){
nx -= 10;
} else {
nx+=10;
}
if (ny=-h/2){
ny -= 10;
} else {
ny+=10;
}
}
return {x:nx, y:ny};
};



 Are you trying to position an animated movieClip Serge, or use the
 drawing API to draw scribbles? Because it sound like the
 suggestions you're getting are the latter solution.

 S

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] scribbling an oval

2005-12-28 Thread Serge Jespers
Yeah I also thought about doing pre-recorded paths but I though it  
was gonna look cooler if it were totally random :-)


What sample are you referring to? 'cause my stuff is still online ;-)


S

The sample you originally posted is not accessible anymore, so my  
take on

this might be off-base:

http://www.motiondraw.com/md/as_samples/t/CatmullRomSpline/ 
scribbledOval.htm

l

This approach is more about 'scribbling' than Math -

First several ovals are manually drawn with this tool
http://www.motiondraw.com/md/as_samples/t/LineGeneralization/demo.html

Now each time the mouse is clicked one of the pre-recorded paths is
selected, some random is applied to its coordinates, it is smoothed  
again

and finally it is rendered as Catmull Rom spline:
http://www.motiondraw.com/md/as_samples/t/CatmullRomSpline/tween.html

Post again if you need more details/code!

HTH
--
Andreas Weber
motiondraw.com



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] scribbling an oval

2005-12-28 Thread Andreas Weber
 What sample are you referring to? 'cause my stuff is still online ;-)

Sorry, hadn't reallized that the link had just an unwanted line-break. All
fine now!

 Yeah I also thought about doing pre-recorded paths but I though
 it was gonna look cooler if it were totally random :-)

Note that the pre-recorded path is just used as a 'matrix' which is then
altered by random factors.
I don't think that 'totally random' will work for anything but a chaotic
scribble - you'll need some original 'matrix' for the shape, either
constructed mathematically or drawn manually.

HTH
--
Andreas Weber
motiondraw.com



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Serge
Jespers
Sent: Wednesday, December 28, 2005 3:59 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] scribbling an oval


Yeah I also thought about doing pre-recorded paths but I though it
was gonna look cooler if it were totally random :-)

What sample are you referring to? 'cause my stuff is still online ;-)


S

 The sample you originally posted is not accessible anymore, so my
 take on
 this might be off-base:

 http://www.motiondraw.com/md/as_samples/t/CatmullRomSpline/
 scribbledOval.htm
 l

 This approach is more about 'scribbling' than Math -

 First several ovals are manually drawn with this tool
 http://www.motiondraw.com/md/as_samples/t/LineGeneralization/demo.html

 Now each time the mouse is clicked one of the pre-recorded paths is
 selected, some random is applied to its coordinates, it is smoothed
 again
 and finally it is rendered as Catmull Rom spline:
 http://www.motiondraw.com/md/as_samples/t/CatmullRomSpline/tween.html

 Post again if you need more details/code!

 HTH
 --
 Andreas Weber
 motiondraw.com


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders