how to pass linear gradient in react-d3-speedometer - css

import ReactSpeedometer from "react-d3-speedometer"
<ReactSpeedometer
value={333}
segments={10}
segmentColors={[
"#51B8D0",
"#4BB7D8",
"#48B6E0",
"#48B7E0",
"#b48ead",]}
/>
Here I have a situation adding a linear gradient in this code but it will not accept gradient color so i don't know how pass linear gradient in react-d3-speedometer

Related

Is there a way to set the linear gradient stepwith in QML

I use a linear gradient to colorize a rectangle. On my Display (480px, EGLFS) i can clearly see 16 color-steps (see picture). Is there a way to increase the number of steps to have a more fluid gradient.
bad gradient
Rectangle {
width: 800
height: 480
gradient: Gradient{
GradientStop{position: 1.0; color: "#404040"}
GradientStop{position: 0.0; color: "black"}
}
}
The problem was, that the gradient has more colors than the display can show (850 for 256). This is called colour banding (https://en.wikipedia.org/wiki/Colour_banding).
After reducing the colors by using an indicated .png instead of the gradient it looks ok.

Translate CSS transition-timing-function to swiping

I am fading in a div (using CSS transitions) with a custom timing function (http://cubic-bezier.com/#1,0,1,1). The timing function is basically a more extreme version of 'ease-in'.
div {
opacity: 0;
transition: opacity 1s;
.in {
opacity: 1;
transition-timing-function: cubic-bezier(1, 0, 1, 1);
}
In addition to that, I want to be able to fade in the div by swiping across the screen. I am using the following Jquery to set the opacity according to how far the user has swiped:
documentWidth = $(document).width();
$(document).on('touchmove', function(e) {
// How much of the animation is completed (in %)
completion = e.changedTouches[0].pageX / documentWidth;
$('div').css('opacity', completion);
})
Nooooow, this is linear! Is there a clever Math-person out there who can figure out how to re-state that last line to represent my timing function?
So, for example, if completion is at 25%, the opacity should be around 2%. At 50%, it should be around 11% and at 75% it should be around 31%.
Start by finding a curve that approximates your cubic-bezier curve. With the given points and some online tools it's possible to draw a curve with this equation:
y = 464085.7 + (0.0174619 - 464085.7)/(1 + (x/22.88957)^4.174069)
in your case the x represents your completion variable and y the resulting opacity.
Then your code becomes
let completion = e.changedTouches[0].pageX / documentWidth;
let exponential = Math.pow((completion / 22.88957), 4.174069);
let opacity = 464085.7 + (0.0174619 - 464085.7)/(1 + exponential);
$('div').css('opacity', opacity);
(of course you may find a better equation that best fits your needs)

Can we place two gradients one over the other

Following is the linear gradient I have for a div :
div{
background: linear-gradient(112deg,#A0148C , #FF2896 37.1%, #F05A00 81.3%);
}
Can we place another CSS gradient over this one(like another layer over this gradient)?
Yes, you can just list backgrounds in the property, separated by commas. Remember there will need to be some transparency in the 'upper' gradient for the 'lower' gradient to be visible underneath:
div{
background: linear-gradient(rgba(255,0,0,0.2), rgba(0,0,255, 0.5)), linear-gradient(112deg,#A0148C , #FF2896 37.1%, #F05A00 81.3%);
}

Cannot get stroke on video mask to show in Flex

I am appending a mask to my mx:VideoDisplay element so that I can have rounded corners. The mask and even a dropshadow filter work great but I cannot get the stroke of the mask (using lineStyle) to show. Researched a ton and tried many fixes. At my wits end. Any help would be really appreciated.
private function applyMask():void {
myMask.graphics.clear();
myMask.graphics.lineStyle(2,0xFFFFFF);
myMask.graphics.beginFill(0xFFFFFF);
myMask.graphics.drawRoundRect(0, 0, 180, 156, 35);
myMask.x = 0;
myMask.y = 0;
videoMy.mask = myMask;
videoMy.filters = [new DropShadowFilter(3)]
}
later on I call the video element:
<mx:VideoDisplay id="videoMy" right="10" top="10" width="240" height="196"/>
You won't be able to do what you want with the mask directly-- it's a mask, so it is not drawn on, only used to mask other pixels.
What I would do is to create another child that is drawn on using the graphics calls you have above, but in a separate, normal display list sprite or some such added as an overlay of the masked VideoDisplay. This should accomplish what you're attempting to do.

How to move an object along a spline or sine function in Flex 3

I am trying to create a similar effect to what is used in CityVille for dropping coins and experience icons, they do a custom move animation and it first moves a little bit up and then down. It looks like it is following a spline or a sine function.
The Move effect in flex 3 only moves linearly.
Any help?
Use a tweening library such as Actuate http://code.google.com/p/actuate/
It lets you animate an object along a bezier curve or custom motion path like this:
var xPath:MotionPath = MotionPath.bezier (200, 20).line (400);
var yPath:MotionPath = MotionPath.bezier (0, 300).line (0);
Actuate.motionPath (MySprite, 1, { x: xPath, y: yPath } );
A very similar library is eaze
http://code.google.com/p/eaze-tween/
and it's mxml friendly wrapper:
http://code.google.com/p/eazefx/
You should be looking at Tweens instead of Moves. An example could be:
import mx.transitions.easing.*;
import mx.transitions.Tween;
new Tween(myMC, ‘_x’, Regular.easeOut, myMC._x, myMC._x + 300, 30);
new Tween(myMC, ‘_y’, Regular.easeIn, myMC._y, myMC._y + 300, 30);
Code is random Google result, so I post no guarantees. Also for myself I would prefer a tween engine like TweenLite: http://www.greensock.com/tweenlite/

Resources