gradient

Android: draw arc within canvas api with a gradient fill color

。_饼干妹妹 提交于 2019-11-30 15:00:58
I want to draw an arc using canvas using a gradient fill. How can achieve this? Hey I stole this from here: Draw an arc with a SweepGradient in Android but it works fine, I used a LinearGradient instead. Shader gradient = new SweepGradient (0,getMeasuredHeight()/2, Color.RED, Color.WHITE); lightRed.setShader(gradient); canvas.drawArc(rectf, -90, 360, false, lightRed); In my cause i I had to draw someone like this: Maybe you too. So, let's think! How does Sweep Gradient works? If you draw rect via this: private val colors = intArrayOf(ContextCompat.getColor(context, R.color.progress_from_color)

animate CSS3 gradient-positions using jQuery

a 夏天 提交于 2019-11-30 14:17:48
问题 Is it possible to animate the position of a CSS3-gradient-color using jQuery? I'd like to animate from this background: -moz-linear-gradient(top, #FF0000 0%, #FF0000 0%, #FFFFFF 0%, #FFFFFF 100%); /* firefox */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#FF0000), color-stop(0%,#FF0000), color-stop(0%,#FFFFFF), color-stop(100%,#FFFFFF)); /* webkit */ to this background: -moz-linear-gradient(top, #FF0000 0%, #FF0000 50%, #FFFFFF 50%, #FFFFFF 100%); /* firefox */

Compile error trying to use CAGradientLayer

旧巷老猫 提交于 2019-11-30 13:49:52
问题 I'm trying to use CAGradientLayer and getting an unhelpful compile error. Can't figure out whats wrong. All I'm doing so far is: CAGradientLayer *gradient = [CAGradientLayer layer]; I've imported <QuartzCore/QuartzCore.h> and I'm getting the warning > _OBJC_CLASS_$CAGradientLayer referenced from: objc-class-ref-to-CAGradientLayer symbol(s) not found. I've tried clean and build but no luck and I can't seem to target anything other than 4.1 in Xcode Cheers for any help. 回答1: You didn't

Fastest way to calculate colors for a gradient?

自闭症网瘾萝莉.ら 提交于 2019-11-30 13:29:35
I'm making a small collection of types/functions related to gradients for future use. I would like to make sure there's at least two procedures: ColorBetween and ColorsBetween. I may want to just get an array of TColor between any 2 colors (ColorsBetween), and I may also just need to know one color value at a percentage between two colors (ColorBetween). I already have it mostly done below. Except, I have two core questions: How do I calculate the in-between color of each RGB channel by a given percentage? (See below where I have [???] ) What's the fastest method to accomplish what I'm doing

2 color heatmap in R with middle color anchored to a specific value

左心房为你撑大大i 提交于 2019-11-30 12:42:53
This heatmap image was generated in Excel but as I'm trying to learn R I would like to know how to make a heatmap like that with R. Right now, this code is working but not as it was supposed to... (p <- ggplot(melt(heat), aes(Var2, Var1)) + geom_tile(aes(fill = value), colour = "white") + scale_fill_gradient(low = "red", high = "green")) I would like to have 2 gradients, green(highest value) to white (the number 1000) to red(lowest value). Is it possible in R? heat dataset: > heat[0:10,0:10] [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1000.000 0.000 0.0000 0.0000 757.0317 709.3896

How can I draw a “soft” line in WPF (presumably using a LinearGradientBrush)?

白昼怎懂夜的黑 提交于 2019-11-30 11:48:25
I'm trying to draw a line with soft edges, regardless of the slope. Here's the code I have so far: <Line HorizontalAlignment="Stretch" VerticalAlignment="Center" Stretch="Uniform" StrokeThickness="5" X1="0" Y1="0" X2="1" Y2="0"> <Shape.Stroke> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="Transparent" Offset="0" /> <GradientStop Color="Green" Offset="0.5" /> <GradientStop Color="Transparent" Offset="1" /> </LinearGradientBrush> </Shape.Stroke> </Line> This makes sense to me, since the line is horizontal, and the linear gradient is vertical, with the edges being

Issue with ComposeShader on Android 4.1.1

十年热恋 提交于 2019-11-30 11:29:10
I'm just trying to implement a color picker for my android application, and ran into a strange issue on Android 4.1.1. The following code does not create the expected gradients on Android 4.1.1, but it does on 2.3.7: Shader fadeInRight = new LinearGradient(0, 0, pWidth, 0, 0x00000000, 0xFF000000, Shader.TileMode.CLAMP); Shader blackToWhite = new LinearGradient(0, 0, 0, pHeight, 0xFF000000, 0xFFFFFFFF, Shader.TileMode.CLAMP); Shader whiteMask = new ComposeShader(blackToWhite, fadeInRight, PorterDuff.Mode.DST_IN); Shader blackToColor = new LinearGradient(0, 0, pWidth, 0, 0xFF000000, hue, Shader

My css gradient doesn't stretch, it repeats

微笑、不失礼 提交于 2019-11-30 11:28:29
问题 body{ padding:0; margin:0; font:normal 12px/16px Arial, Helvetica, sans-serif; color:#383634; background-image: -webkit-gradient( linear, left top, left bottom, color-stop(0.18, rgb(74,12,107)), color-stop(0.87, rgb(102,153,102)) ); background: -moz-linear-gradient(top, #4a0c6b 0%, #669966 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#4a0c6b), color-stop(100%,#669966)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #4a0c6b 0%,

animate CSS3 gradient-positions using jQuery

て烟熏妆下的殇ゞ 提交于 2019-11-30 10:34:24
Is it possible to animate the position of a CSS3-gradient-color using jQuery? I'd like to animate from this background: -moz-linear-gradient(top, #FF0000 0%, #FF0000 0%, #FFFFFF 0%, #FFFFFF 100%); /* firefox */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#FF0000), color-stop(0%,#FF0000), color-stop(0%,#FFFFFF), color-stop(100%,#FFFFFF)); /* webkit */ to this background: -moz-linear-gradient(top, #FF0000 0%, #FF0000 50%, #FFFFFF 50%, #FFFFFF 100%); /* firefox */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#FF0000), color-stop(50%,

Computing jacobian matrix in Tensorflow

安稳与你 提交于 2019-11-30 10:33:47
I want to calculate Jacobian matrix by Tensorflow. What I have: def compute_grads(fn, vars, data_num): grads = [] for n in range(0, data_num): for v in vars: grads.append(tf.gradients(tf.slice(fn, [n, 0], [1, 1]), v)[0]) return tf.reshape(tf.stack(grads), shape=[data_num, -1]) fn is a loss function, vars are all trainable variables, and data_num is a number of data. But if we increase the number of data, it takes tremendous time to run the function compute_grads . Any ideas? Assuming that X and Y are Tensorflow tensors and that Y depends on X : from tensorflow.python.ops.parallel_for.gradients