gradient

How to interpolate hue values in HSV colour space?

自作多情 提交于 2019-11-28 19:36:50
I'm trying to interpolate between two colours in HSV colour space to produce a smooth colour gradient. I'm using a linear interpolation, eg: h = (1 - p) * h1 + p * h2 s = (1 - p) * s1 + p * s2 v = (1 - p) * v1 + p * v2 (where p is the percentage, and h1, h2, s1, s2, v1, v2 are the hue, saturation and value components of the two colours) This produces a good result for s and v but not for h. As the hue component is an angle, the calculation needs to work out the shortest distance between h1 and h2 and then do the interpolation in the right direction (either clockwise or anti-clockwise). What

Efficiently grab gradients from TensorFlow?

五迷三道 提交于 2019-11-28 19:14:22
问题 I'm trying to implement an asynchronous parameter server, DistBelief style using TensorFlow. I found that minimize() is split into two functions, compute_gradients and apply_gradients, so my plan is to insert a network boundary between them. I have a question about how to evaluate all the gradients simultaneously and pull them out all at once. I understand that eval only evaluates the subgraph necessary, but it also only returns one tensor, not the chain of tensors required to compute that

Draw gradient along a curved UIBezierPath

一笑奈何 提交于 2019-11-28 19:12:10
问题 In an app, I draw a curved UIBezierPath an an MKOverlayPathView class to show flight routes. This is the code I am using: - (UIBezierPath *)pathForOverlayForMapRect:(MKMapRect)mapRect { ... bla bla bla ... UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:s]; [path addQuadCurveToPoint:e controlPoint:cp1]; [path addLineToPoint:e2]; [path addQuadCurveToPoint:s2 controlPoint:cp2]; [path closePath]; return path; } - (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale

Can you overlay a transparent css3 gradient over a background image?

♀尐吖头ヾ 提交于 2019-11-28 18:51:35
问题 I'm trying to put a css3 gradient over the top of a background image. Using the code below puts a background image on top of my gradient, but i'm trying to do it the other way around, so the gradient acts as a mask on top. url(images/darkwood.png), -webkit-gradient(linear, 0 0, 0 100%, from(#EEF), to(#000)) 300px 50px no-repeat, -webkit-gradient(linear, 0 0, 0 100%, from(#EFE), to(#000)) 0 0 no-repeat; background: url(images/darkwood.png), -moz-linear-gradient(#EEF, rgba(0,0,0,1)) 300px 50px

How can I add gradient effect to background color of TextView in a ListView?

…衆ロ難τιáo~ 提交于 2019-11-28 18:39:40
问题 In reference to these questions : Adding gradient effect to TextView in a ListView generates NPE and How to change color and font on ListView I would like to know how to go about setting the background of a TextView in a ListView with gradient effect? In one of the questions above, I ended up having the gradient effect added to the text in the TextView . And after skimming through the second question, it seems I can add only fixed background colors. How do I go about adding gradient to

How to convert x,y coordinates to an angle?

人盡茶涼 提交于 2019-11-28 18:12:59
Microsoft provide an excellent SVG gradient maker so IE9 can also have "CSS3" gradients (click Custom). I currently utilise their logic for my Fireworks and Dreamweaver extensions to convert gradients to SVG, but I only know how to do it for standard top, bottom, left, right directions. If you enter an angle, I don't do the conversion, because I'm not sure how I would convert x1, x2, y1, y2 to CSS3 angle degrees. The gradient generator provides values like this: x1="0%" y1="0%" x2="56.262833675564686%" y2="68.29999651227678%" I'm not great with mathematics or trigonometry, so could somebody

How to implement alpha gradient on a image?

喜夏-厌秋 提交于 2019-11-28 17:58:40
I want to implement alpha gradient on an image. From 0.5 alfa on top of the image to 0.0 on bottom. Any advice, tutorial, link is welcome. You can use CGImageCreateWithMask to apply a masking image to it. You could generate an appropriate mask simply enough by drawing to a greyscale or alpha-only CGBitmapContext with CGContextDrawLinearGradient . If it's being displayed as the content of a CALayer, you could apply an appropriate masking layer to the parent layer's mask property. You could use a CAGradientLayer with appropriate colors to create this mask. You can draw the image to a

How to animate gradient?

时间秒杀一切 提交于 2019-11-28 17:19:49
How to animate gradient from color#1 to color#2? Something similar to I'm planning to use it as health-bar for unit (so, it will be finit animation starting with green and ending with red) Nexen While googling it, I found 2 ways to do it for android: use ShaderFactory or extends View, using new Shader(new LinearGradient()) . Both answers do the same - calling new Shader() every View.onDraw(Canvas canvas) method's call. Its really expensive if number of such animated gradients more than ~3. So I did it another way. I avoided calling new every onDraw() , using single precalculated LinearGradient

iPhone iOS how to add linear gradient to a UIButton under the button's text or image?

夙愿已清 提交于 2019-11-28 17:19:44
I'm working on creating fancy looking UIbuttons by adding linear gradient to the button. However I'm not sure at which index I need to add the gradient. The code that I have currently places the gradient over the image/text. How can I insert a sublayer to a UIButton under the text/image sublayer? It is important for me to keep the text and the image of a button visible! +(void)addLinearGradientToView:(UIView*)view TopColor:(UIColor*)topColor BottomColor:(UIColor*)bottomColor { for(CALayer* layer in view.layer.sublayers) { if ([layer isKindOfClass:[CAGradientLayer class]]) { [layer

UIButton w/ gradient, rounded corners, border, and drop shadow

只谈情不闲聊 提交于 2019-11-28 16:54:33
There are a few similar questions on the site, but I'm looking for something specific and slightly different. I followed the direction given here: http://www.cimgf.com/2010/01/28/fun-with-uibuttons-and-core-animation-layers/ to subclass UIButton in order to create a generic class that I can specify the gradient colors on, rather than trying to use a static image. I ran into a problem where the setMasksToBounds on the button's layer would either allow A) the drop shadow to show, but also allow the gradient layer to show beyond the rounded corners OR B) the gradient layer to clip to the rounded