I want to achieve the effect of some object being frozen
For example something like this:
This is normal - no effect:
And this is with effect:
I thought that maybe i could do it with color tint on sprite batch, but it doesn't work since white is default color for tint in sprite batch
Related
I'm trying to have a better render on my scene. So I added directional and ambiant lights. So Shadows are generated. Here's the
Result
I wonder if there is a way to have softer shadows.
The model has been created with Sweet Home : http://www.sweethome3d.com/
On the scene element, you could try to change the default type of the shadows:
<a-scene shadow="type: pcfsoft">
https://aframe.io/docs/0.8.0/components/shadow.html#scene_properties_type
Also worth experimenting with the properties on the light itself:
Adjust the shadow camera position and frustum (shadowCameraTop, shadowCameraRight, …) of the directional light, until it envelops the scene tightly. If the frustum is too small, shadows will be missing or partially clipped. If the frustum is too large, shadows will appear coarse or pixelated
https://aframe.io/docs/0.8.0/components/light.html#adding-real-time-shadows
https://aframe.io/docs/0.8.0/components/light.html#configuring-shadows
Turn up the ambient light to change the shadow color.
Play with light.shadowRadius property (currently master branch of A-Frame). And decrease shadow map resolution.
<a-scene shadow="type: pcfsoft">
I'm having difficulty with transforming colour in Flash. It should be easy I think, but for some reason my code isn't working as expected.
I have a bitmap graphic consisting of a colour spectrum from red to yellow to green (you know, like you see in an audio level meter).
I simply want to sample a colour from that bitmap and then tint a movie clip on stage that sampled colour. (the effect I'll be going for is coloured progress - the closer you get to 100% green is displayed, the closer you are to 0% it's red - I haven't implemented that part yet, but I'm not worried about that).
Anyhow, I sample the colour just fine, and tint my clip, but no matter what I tint the clip it comes up a different colour than what I've sampled (the trace is a different colour than what I see on the clip). I can't see where I'm going wrong - I'm hoping it's a stupid mistake and someone can spot it easily.
import flash.display.BitmapData;
var bmd:BitmapData = new BitmapData(mc_colourbar.width, mc_colourbar.height);
bmd.draw(mc_colourbar);
var pixelvalue:uint = bmd.getPixel(0, 1);
trace(pixelvalue.toString(16));
var colourtransform:ColorTransform = mc_box.transform.colorTransform;
colourtransform.color = uint("0xff" + pixelvalue);
mc_box.transform.colorTransform = colourtransform ;
mc_box is the clip on stage I'm trying to tint - it's simply a white square.
Any help is appreciated, thanks in advance!
ColorTransform.color expects an RGB value, and it appears as though you're attempting to give it an ARGB value*.
Change the line:
colourtransform.color = uint("0xff" + pixelvalue);
to just:
colourtransform.color = pixelvalue;
and your code should work as expected.
*Though I don't think the way you're trying to do it here is correct.
I have an hourglass like vector shape and I'd like to use it to mask an image. I'd like to feather the edges - have a soft falloff in transparency that follows the contours of the hour glass. Any ideas how I can do this?
I tried using a gradient fill on a closed shape (using beginGradientFill() and curveTo() functions) but that falloff doesn't follow the contour of the vector shape, it can only go one direction.
Maybe there is a better solution but until somebody comes up with it... I assume you could do the following:
Draw whatever shape you want to use as mask into a transparent bitmap.
Scale a bit the bitmap down (or use a matrix while drawing its bitmapdata).
Apply a blur filter to it.
Put the bitmap's center to the masked clip's center so they are aligned.
Set the masked clip's cacheAsBitmap property to true.
I have myself a movieclip that has multiple images in, I want to be able to use AS3
to change the Hue and Saturation so the client can choose a colour and it will change the colour of the movieclip to their settings.
I have tried this
var my_color:ColorTransform = new ColorTransform();
my_color.color = 0x550000;
tempPlayer.transform.colorTransform = my_color;
But the movieclip just becomes completely red, I just want to be able to add a touch of colour, and then make the colour stand out a bit using AS3. Basically something like this
but from grey to one colour
Canvas
For saturation it gets a little more complicated than the traditional ColorTransform. Often, you will need to use ColorMatrixFilter.
This feature is quite complicated, but this blog post describes the process quite well and gives you code for a couple common effects.
That said, you can add just a little color to an object with ColorTransform by using the *Offset and *Multiplier properties like greenOffset and redMultiplier. This lets you offset the red, green or blue values a little to give different effects.
I have a BitmapData object named myBitmapData. It was loaded of PNG of size 104x104. This PNG represents a red circle on the transparent background.
There is also a Sprite object named myBackground. I want render that red circle into myBackground.
myBackground.graphics.beginBitmapFill(myBitmapData);
myBackground.graphics.drawRect(0, 0, myBitmapData.width, myBitmapData.height);
myBackground.graphics.endFill();
addChild(myBackground);
Everything is fine. I see a red circle in the left top of myBackground.
But when I change the third line to
myBackground.graphics.drawRect(0, 52, myBitmapData.width, myBitmapData.height);
and expect my circle to be translated 52 pixels down, I actually obtain something strange (for me :)): there are two red half-circles (they form like hourglass).
So, the question is: how do I render myBitmapData into the random position of myBackground?
P.S.
In the case of
myBackground.graphics.drawRect(0, 104, myBitmapData.width, myBitmapData.height);
it is circle again :)
This is caused by beginBitmapFill's default repeat = true parameter. There's an example in the docs. Disabling the repetition won't work though, you'd just get a half circle then.
There are several ways to fix this:
Use a Matrix with a translation (displacement) as argument in beginBitmapFill.
Draw the rectangle at 0,0 on another Sprite, and move that sprite to where you want it on the background.
Don't draw directly to the background, but to another bitmap using copyPixels. Then fill the background with that bitmap.