How do I add a gradient fill to a movie clip in as3 flash - movieclip

trying to make code to first addchild movie clip, then apply a gradient to it. Some posts have talked about making a gradient box the same as the bounding area of the movie clip and add a mask which would be great but I'm getting no where. Code I'm using is more confusing then anything if I posted every thing I tried. Wouldn't have to be a movieclip, could have it be a button or graphic.

Use MovieClip.graphics.beginGradientFill(fillType, colors);
For example,
yourMovieClip.beginGradientFill(GradientType.LINEAR, [0XFF0000, 0XC0C0C0])
will make your MovieClip a linear gradient of red and a grayish color, and you can change the SpreadMethod to, for example, REPEAT, REFLECT, or PAD (SpreadMethod.type).
See the Adobe LiveDocs Reference of it.
Also, before you ask, you need to import Classes from flash.display.

Related

How to paint using brush with particular area...

I want to fill each and every part with different colours like circle with other colour and each leave with different colour and stick with different colours. I have bunch of colours. You can fidn similar apps like Toonia Color book on apple app store...
I am unable to get bounds of particular part in image.
I searched a whole day before writing this question. Every one is saying just look for flood fill and Quick Fill algorithms but i am not able to solve this problem.
In Toonia Colorbook this is done using vector graphics and masks. Every shape is described as a bezier curve that masks a drawing layer.
check out CAShapeLayer and CALayer for further details

How to do Water color painting in iOS using CoreGraphics? [duplicate]

I have been working with OpenGL in iOS, and setting the colors with glColor4f(r,g,b,a) and then drawing my own color on a white UIImageView. I basically have a brush, which is then moved around my user's touch, and then it paints the color onto the canvas. But this color needs to be water paint (like smudged color)
Does anyone understand/knows how to get a water color like this app does, and how the background UIImageView has a texture on it?
https://itunes.apple.com/us/app/hello-watercolor/id539414526?mt=8
or checkout water paint in this. http://www.fiftythree.com/paper
I created a bounty on this as I am really having a hard time to grasp how to derive such smooth flowing colors out of the normal colors. Even if you guys point me in the right direction, or to some sample code on how I can get the effect of water-paint, it would be really helpful ^_^
And as a bonus, it would be also be helpful if you can point out to me how to get canvas on which it is painted on looks realistic, and blended with the paint? Does Blending/GLSL have to do with any of this?
Is there any sample project on this?
If you are still struggling with the basics of getting realistic looking water colors working, you may want to experiment/prototype in photoshop first.
http://www.zoepiel.com/tutorials/watercolor/ shows some very effective tricks for creating watercolor images with simple tools.
The most interesting one is to multiply a group of watercolor layers with a greyscale watercolor paper image. The texture of the paper makes some parts remain white, and other parts saturate with color, just like real watercolor.
Each layer remains 'wet' in the sense that the colors within it blend, but the layers are 'dry' with respect to each other.
She also explains some of her brush and blur settings and shows what they do.
Once you can produce the desired effect in photoshop, you'll have clear specifications of what you want to do and you'll be quite a bit closer to programming it out.
Looking at the examples you posted, it looks like they are using a simple Gaussian Blur with a radius of double your brush size. This may be an incomplete solution, but it's at least the first level.

Render water-paint in iOS

I have been working with OpenGL in iOS, and setting the colors with glColor4f(r,g,b,a) and then drawing my own color on a white UIImageView. I basically have a brush, which is then moved around my user's touch, and then it paints the color onto the canvas. But this color needs to be water paint (like smudged color)
Does anyone understand/knows how to get a water color like this app does, and how the background UIImageView has a texture on it?
https://itunes.apple.com/us/app/hello-watercolor/id539414526?mt=8
or checkout water paint in this. http://www.fiftythree.com/paper
I created a bounty on this as I am really having a hard time to grasp how to derive such smooth flowing colors out of the normal colors. Even if you guys point me in the right direction, or to some sample code on how I can get the effect of water-paint, it would be really helpful ^_^
And as a bonus, it would be also be helpful if you can point out to me how to get canvas on which it is painted on looks realistic, and blended with the paint? Does Blending/GLSL have to do with any of this?
Is there any sample project on this?
If you are still struggling with the basics of getting realistic looking water colors working, you may want to experiment/prototype in photoshop first.
http://www.zoepiel.com/tutorials/watercolor/ shows some very effective tricks for creating watercolor images with simple tools.
The most interesting one is to multiply a group of watercolor layers with a greyscale watercolor paper image. The texture of the paper makes some parts remain white, and other parts saturate with color, just like real watercolor.
Each layer remains 'wet' in the sense that the colors within it blend, but the layers are 'dry' with respect to each other.
She also explains some of her brush and blur settings and shows what they do.
Once you can produce the desired effect in photoshop, you'll have clear specifications of what you want to do and you'll be quite a bit closer to programming it out.
Looking at the examples you posted, it looks like they are using a simple Gaussian Blur with a radius of double your brush size. This may be an incomplete solution, but it's at least the first level.

ccDraw. Fill screen everywhere except on sprite

So I am trying to get a very basic "flashlight"-style thing going in one of my games.
The way I was getting it to work, was having a layer on top of my game screen, and this layer would draw a black rectangle with ~ 80% opacity, creating the look of darkness on top of my game scene.
ccDrawSolidRect(ccp(0,0), ccp(480,320), ccc4f(0, 0, 0, 0.8));
What I want to do is draw this rectangle EVERYWHERE on the screen, except for around a cone of vision that will represent the "light source".
What this would create would be a dark overlay on top of everything except for the light, giving it the illusion of a torch/light/flashlight.
The only way I can foresee this happening is by using ccDrawSolidPoly(), but since the position of the light source changes, so would the vertices for the poly.
Any suggestions on how to achieve this would be great.
You can use ccDrawSolidPoly() and avoid having to manually update vertices. For this you can create a new subclass of CCNode representing your light object, and do your custom shape drawing in its -(void)draw method.
The ccDraw...() functions will draw relative to the local sprite coordinates, so you can then move and rotate your new sprite to suit your needs and cocos2d will do the vertices transformations for you.
Update: I found out that you might be better off subclassing CCDrawNode instead of CCNode, as it has some facilities for raw OpenGL drawing (OpenGL's vertexArrayBuffer and vertexBufferObject internal variables and a buffer for vertices, their colors and their texCoords). If your stuff is very simple, maybe subclassing the plain CCNode is enough.
Could a png be used instead as a mask, as the layer above
Like that binocular vision you sometimes see in cartoons?
Or a filter similar to a photoshop mask that darkens as it grows outwardly to wards the edge of the screen
Just a thought anyway...
A picture of more of what your trying to explain might be good too

Drawing back to transparent in actionscript

When I have a movie clip, it starts out s transparent.
I can draw on this movie clip, producing essentially a transparent image. That is, wherever I have not yet drawn, shows the layer below, and where I have drawn, it shows what I have just drawn.
Question is, how to "undraw" things in this movie clip, so that I can see what is behind it. I know I could erase the movie clip, but is there a way to un-draw parts of the movie clip to get it back to transparent?
You can use another movie clip as a mask. I think it's setMask() in MovieClip to set another movieclip as its mask. Then you can draw on the mask movieclip the areas you want to show. Unfortunately in AS2, you can only use vector shapes as masks.

Resources