gradient

Drawing Circular Gradient

≡放荡痞女 提交于 2019-12-03 08:28:29
I would like to draw a circular gradient like in the example picture below. I can manage a radial gradient easily but I am not sure how to do a circular one. I was thinking of drawing a gradient on a line and then transforming it to a circle. Would that be possible? This is how I draw the radial gradient: CGFloat a = MIN(self.frame.size.width, self.frame.size.height) - _lineWidth; //Get current context CGContextRef mainContext = UIGraphicsGetCurrentContext(); CGRect newRect = rect; newRect.origin.x = ((self.frame.size.width - a)/2.0f); newRect.origin.y = ((self.frame.size.height - a)/2.0f);

ggplot2 : Add a gradient colored square according to values

六眼飞鱼酱① 提交于 2019-12-03 07:34:52
问题 I have a tricky question regarding to what i'm trying to do. I have a plot with two lines (the mean of two conditions) on it. I want to add on the same plot a square reflecting the t-values (and colored according to these values in a gradient way). How could i add this square? Well since i don't know if i'm clear, here is a figure of what i try to achieve. Thank you for any help! 回答1: Try this for ggplot2 way: x <- seq(-10, 10, 0.1) df <- data.frame(x, y1 = pnorm(x), y2 = pnorm(x) * 2) df$t <

Image Gradient Vector Field in Python

跟風遠走 提交于 2019-12-03 07:28:08
I am trying to get the Gradient Vector Field of an image using Python (similar to this matlab question ). This is the original image: Here is my code: import numpy as np import matplotlib.pyplot as plt import Image from PIL import ImageFilter I = Image.open('test.png').transpose(Image.FLIP_TOP_BOTTOM) I = I.filter(ImageFilter.BLUR) p = np.asarray(I) w,h = I.size y, x = np.mgrid[0:h:500j, 0:w:500j] dy, dx = np.gradient(p) skip = (slice(None, None, 3), slice(None, None, 3)) fig, ax = plt.subplots() im = ax.imshow(I, extent=[x.min(), x.max(), y.min(), y.max()]) ax.quiver(x[skip], y[skip], dx[skip

Gradient calculation with python

不问归期 提交于 2019-12-03 07:27:29
I would like to know how does numpy.gradient work. I used gradient to try to calculate group velocity (group velocity of a wave packet is the derivative of frequencies respect to wavenumbers, not a group of velocities). I fed a 3 column array to it, the first 2 colums are x and y coords, the third column is the frequency of that point (x,y). I need to calculate gradient and I did expect a 2d vector, being gradient definition df/dx*i+df/dy*j+df/dz*k and my function only a function of x and y i did expect something like df/dx*i+df/dy*j But i got 2 arrays with 3 colums each, i.e. 2 3d vectors; at

How to create multiple stop gradient fragment shader?

◇◆丶佛笑我妖孽 提交于 2019-12-03 07:19:42
I'm trying to create an OpenGL ES 2.0 fragment shader that outputs multiple stop gradient along one axis. It should interpolate between multiple colors at points defined in percents. I've achieved this by using if s the fragment shader, like this: float y = gl_FragCoord.y; float step1 = resolution.y * 0.20; float step2 = resolution.y * 0.50; if (y < step1) { color = white; } else if (y < step2) { float x = smoothstep(step1, step2, y); color = mix(white, red, x); } else { float x = smoothstep(step2, resolution.y, y); color = mix(red, green, x); } They say that branching in fragment shader can

Is it possible to make a gradient-transparent/layer masking image using canvas?

穿精又带淫゛_ 提交于 2019-12-03 05:40:46
I've been following the lessons about transparency and gradients on the Mozilla site: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Canvas_tutorial/Applying_styles_and_colors but I have not been able to figure this one out. I know I can achieve these effects with a png image; however, in the program I am working on the gradient will change constantly according to where the image is moved. Here's an example of the effect I'm looking for. http://home.insightbb.com/~epyonxl1/gradientex.jpg I've aded some code here http://code.google.com/p/canvasimagegradient/ that adds a

White to transparent gradient with background image

老子叫甜甜 提交于 2019-12-03 05:40:24
问题 I need to apply a white to transparent gradient which covers about a 1/4 of the top of the page and a background image visible for the rest of the page. Im looking to achieve a seamless blend from a gradient to a textured image and to do this in CSS3. 回答1: I recommend Ultimate CSS Gradient Generator - ColorZilla.com It's a well designed tool and there's a white to transparent preset. The CSS code that it generates for a white to transparent gradient is this: background: -moz-linear-gradient

Gradient opacity on the bottom of div

人走茶凉 提交于 2019-12-03 05:20:39
I would like to create effect like on this image - gradient opacity on the bottom of content: How can i do it? Love Trivedi You can use this HTML <div class="content"> Loriem ispsum is simply dummy text<br> Loriem ispsum is simply dummy text<br> Loriem ispsum is simply dummy text<br> Loriem ispsum is simply dummy text<br> Loriem ispsum is simply dummy text<br> Loriem ispsum is simply dummy text<br> Loriem ispsum is simply dummy text<br> Loriem ispsum is simply dummy text<br> Loriem ispsum is simply dummy text<br> Loriem ispsum is simply dummy text<br> Loriem ispsum is simply dummy text<br>

How do I combined CSS text-shadow and “background-image: -webkit-gradient”

假装没事ソ 提交于 2019-12-03 05:07:22
I am trying to achieve a gradient + text shadow effect in Chrome/Safari using CSS text-shadow and a combination of text-shadow and background-image: -webkit-gradient, see example blw. I can only make one of the effects apply(if I add the shadow the gradient disappears. What am I doing wrong? h1 { font-size: 100px; background-image: -webkit-gradient(linear, left top, left bottom, from(white), to(black)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; text-shadow: 0 1px 1px #fff; } The gradient "disappears" because the text-shadow is on a level above the background. The

Gradient in noisy data, python

丶灬走出姿态 提交于 2019-12-03 04:35:23
问题 I have an energy spectrum from a cosmic ray detector. The spectrum follows an exponential curve but it will have broad (and maybe very slight) lumps in it. The data, obviously, contains an element of noise. I'm trying to smooth out the data and then plot its gradient. So far I've been using the scipy sline function to smooth it and then the np.gradient(). As you can see from the picture, the gradient function's method is to find the differences between each point, and it doesn't show the