The filters we will use:
- BevelFilter
- BitmapFilter
- BlurFilter
- ColorMatrixFilter
- ConvolutionFilter
- DisplacementMapFilter
- DropShadowFilter
- GlowFilter
- GradientBevelFilter
- GradientGlowFilter
The filters we will use:
1 | import flash.filters.BevelFilter |
1 | BevelFilter = new BevelFilter ([Settings]) |
Distance: Default = 4
The distance of the bevel, this should be given as a number equating to pixels.
Angle: Default = 45
The angle of the bevel, this should be given as a number between 0 and 360, if 0 is used then there is no offset and will have no effect on the bevel.
Highlight Colour: Default = 0xFFFFFF
The highlight colour of the bevel, this should be given in hexidecimal format such as 0xFF33cc, or 0x33cc33
Highlight Alpha: Default = 1The transparency value of the highlight colour, this should be given as a value between 0 and 1, so .25 would be 25% and .36 would be 36%, Remember 1 is completely opaque and 0 is completely transparent.
Shadow Colour: Default = 0×000000
The shadow colour of the bevel, another hexadecimal format.
READ MORE »
1 | import flash.display.BitmapData |
The bitmap filter is one of the most advanced filters with 29 operations attached:
Phew – all having individual parameters and effects!
In order to initiate a bitmapData you use:
1 | bitmapData = new BitmapData(width, height, transparent, colour) |
so for example:
1 | bitmapData = new BitmapData(Stage.width, Stage.height, false, 0x00000000) |
I’m not going to go through each operation with explanations but they will appear in future tutorials – look out
1 | import flash.filters.BlurFilter |
The filter itself only uses three settings; xblur, yblur and quality
1 2 3 4 | Blur = new BlurFilter(100,200,3) Filters = new Array() Filters.push(Blur) Object.filters = Filters |
So now the object with instance name Object has the blur filter applied to it.
The blur filter is one of the easiest filters to use and here’s why:
xblur : the distance of blur on the x axis
yblur : the distance of blur on the y axis
quality : the quality of the blur, for lots of blurs minimise this but for limited then you can use a higher quality. There isn’t much difference just the sharpness.
The ColorMatrixFilter class is used to manipulate the color and alpha values of the filtered object. This allows you to create saturation changes, hue rotation (shifting a palette from one range of colors to another), luminance-to-alpha changes, and other color manipulation effects using values from one color channel and potentially applying them to other channels.
I find this one of the hardest filters/effects to understand but basically the filter goes through each of the pixels in the source one by one and separates each pixel into its red, green, blue, and alpha parts. It hen does some crazy shiz to them by multiplying by the color matrix and works out the final colours.
The matrix property of the filter is an array of 20 numbers that are used in calculating the final color.
Think of it as a way to alter colours and effectively be able to tween between; contrasts, hues and saturations. Not to mention brightnesses, this is sometimes used in films to simulate “waking up” and everything, from blurry, bright and high in contrasts fades back to original colours. But apart from that – i see limited uses of this
Basically it’s a matrix. I prefer to call it an array – we all know what they are…
Anyway, it’s a 20 part array, a 5×4 (20) element array. Let’s take a look at one…
| R | G | B | A | Off | |
| R | 1 | 0 | 0 | 0 | 0 |
| G | 0 | 1 | 0 | 0 | 0 |
| B | 0 | 0 | 1 | 0 | 0 |
| A | 0 | 0 | 0 | 1 | 0 |
So, let’s take a look at the formula…
1 2 3 4 | red = a[0] * origRed + a[1] * origGreen + a[2] * origBlue + a[3] * origAlpha + a[4] green = a[5] * origRed + a[6] * origGreen + a[7] * origBlue + a[8] * origAlpha + a[9] blue = a[10] * origRed + a[11] * origGreen + a[12] * origBlue + a[13] * origAlpha + a[14] alpha = a[15] * origRed + a[16] * origGreen + a[17] * origBlue + a[18] * origAlpha + a[19] |
This shows us that;
Tthe values in the first row determine the resulting red value, the second row the green value, the third row the blue value, and the fourth row the alpha value. You can also see that the values in the first four columns are multiplied with the source red, green, blue, and alpha values, while the fifth column value is added (offset). Note that the source and result values for each channel range between 0 and 255.
Every pixel is made up of red, green and blue…
So, if we have 100% red, green and blue – we get white, 0% we get black…
So logically if we increase the red green and blue equally we should increase the brightness. Any offset larger than 0 adds colour, below 0 removes colour…
Let’s take another look at our array:
| R | G | B | A | Off | |
| R | 1 | 0 | 0 | 0 | 0 |
| G | 0 | 1 | 0 | 0 | 0 |
| B | 0 | 0 | 1 | 0 | 0 |
| A | 0 | 0 | 0 | 1 | 0 |
So, if we offset it all by 50 we should get:
| R | G | B | A | Off | |
| R | 1 | 0 | 0 | 0 | 50 |
| G | 0 | 1 | 0 | 0 | 50 |
| B | 0 | 0 | 1 | 0 | 50 |
| A | 0 | 0 | 0 | 1 | 0 |
How can we accomplish this… Let’s take another look at the matrix:
| R | G | B | A | Off | |
| R | 1 | 0 | 0 | 0 | 0 |
| G | 0 | 1 | 0 | 0 | 0 |
| B | 0 | 0 | 1 | 0 | 0 |
| A | 0 | 0 | 0 | 1 | 0 |
Ok, so if we think about it if we had all the red, green and blue channels the same that would be greyscale
That’s because there is no more red than green or blue and so it will be grey…
ok, let’s see:
| R | G | B | A | Off | |
| R | 0.5 | 0.5 | 0.5 | 0 | 0 |
| G | 0.5 | 0.5 | 0.5 | 0 | 0 |
| B | 0.5 | 0.5 | 0.5 | 0 | 0 |
| A | 0 | 0 | 0 | 1 | 0 |
Half of all the colours resulting in mid-grey and also all the same resulting in a greyscale effect…
Saturation in the colour matrix filter is hard, along with hue shifting and changing the contrast.
So first we need a way of converting RGB values into the Luminance constants which we need…
The values I am going to use are:
1 2 3 | redLuminance = 0.3086 greenLuminance = 0.6094 blueLuminance = 0.0820 |
So…
Say for example our saturation value is in the variable saturationValue
then we could use:
1 2 3 4 5 | value = 1-saturationValue redSat = value * redLuminance greenSat = value * greenLuminance blueSat = value * blueLuminance |
Now, all we need is that array…
1 | change = new Array(redSat + value, greenSat, blueSat, 0, 0, redSat, greenSat + value, blueSat, 0, 0, redSat, greenSat, blueSat + value, 0, 0, 0, 0, 0, 1, 0 ) |
Contrast time
Firstly, we need an input; redSaturation greenSaturation and blueSaturation are your input variables.
1 2 3 | redSaturation += 1 greenSaturation += 1 bueSaturation += 1 |
Now, all we need is that array…
1 | change = new Array(redSaturation, 0, 0, 0, 128*(1-redSaturation), 0, greenSaturation, 0, 0, 128*(1-greenSaturation), 0, 0, bueSaturation, 0, 128*(1-bueSaturation), 0, 0, 0, 1, 0) |
EvoLve theme by Theme4Press • Powered by WordPress Stormation
Innovation through Creation - Flash | PHP | HTML | XML | CSS | SQL - By Eliott Robson
