Draw rounded linear gradient (or extended radial gradient) with CoreGraphics
Date : March 29 2020, 07:55 AM
hop of those help? I don't think there is an API for that, but you can get the same effect if you first draw a radial gradient, say, in an (N+1)x(N+1) size bitmap context, then convert the image from the context to a resizable image with left and right caps set to N. Pseudocode: UIGraphicsBeginImageContextWithOptions(CGSizeMake(N+1,N+1), NO, 0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
// <draw the gradient into 'context'>
UIImage* gradientBase = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImage* gradientImage = [gradientBase resizableImageWithCapInsets:UIEdgeInsetsMake(0,N,0,N)];
|
How to overlay a radial gradient over a linear gradient within a fragment shader?
Date : March 29 2020, 07:55 AM
this one helps. I am stuck with a fragment shader. I managed to display a linear gradient from top to bottom (cp. left image). The goal is to overlay a radial white gradient to this linear gradient (illustrated as the black dotted line in the left image => the right image illustrates the goal). , Here is some code which should do what you need: // Precision
precision highp float;
// Uniforms
uniform vec2 uResolution;
// Colors
uniform vec3 uColor1;
uniform vec3 uColor2;
// parameters of the radial gradient
uniform vec2 uRadialFxCenter; // this should be in [0-1], so normalized screen coords
uniform float uRadialFxRadius; // this should be in [0-1], so normalized screen coords
uniform vec3 uRadialFxColor; // should be white
uniform float uRadialFxOpacity; // between [0-1]
void main(void) {
vec2 position = gl_FragCoord.xy/uResolution;
vec3 color = vec3(uColor2.x+(uColor1.x-uColor2.x)*position.y,
uColor2.y+(uColor1.y-uColor2.y)*position.y,
uColor2.z+(uColor1.z-uColor2.z)*position.y);
// compute radial fx opacity => alpha
vec2 posToRadialFxCenter = uRadialFxCenter - position;
float distToCenterNormalized = min((length(posToRadialFxCenter)/uRadialFxRadius), 1.0);
float alpha = (1.0-distToCenterNormalized) * uRadialFxOpacity;
// alpha blending radialFxColor / color
color = color * (1.0-alpha) + uRadialFxColor * alpha;
//
gl_FragColor = vec4(color.x, color.y, color.z, 1.);
}
distToCenterNormalized = pow(distToCenterNormalized, slope);
|
WPF Radial Progress Bar with Radial Gradient
Tag : chash , By : user107506
Date : March 29 2020, 07:55 AM
wish helps you Since the RadialGradient you are using is most likely Relative, it will change its center depending on the actual size of the arc. When the arc is at 75% or higher, the Geometry generated by Arc is at its maximum Width and Height and therefore stable and covering the entire control. protected override void OnRender(DrawingContext drawingContext)
{
// half the width and height of the Arc
double radiusX = RenderSize.Width / 2;
double radiusY = RenderSize.Height / 2;
// the outlines of the "original" Arc geometry
PathGeometry clip = GetArcGeometry().GetWidenedPathGeometry(
new Pen(Stroke, StrokeThickness));
// draw only in the area of the original arc
drawingContext.PushClip(clip);
drawingContext.DrawEllipse(Stroke, null, new Point(radiusX, radiusY), radiusX, radiusY);
drawingContext.Pop();
}
|
CSS: Slice radial-gradient 50% on bottom for another similar radial-gradient?
Tag : css , By : user93312
Date : March 29 2020, 07:55 AM
Hope that helps Cover with a linear gradient Paint a half transparent, half black linear gradient on top of it. .bg {
width: 100vh;
height: 100vh;
background: linear-gradient(to bottom, transparent 50%, black 50%),
radial-gradient(circle closest-side, #00bffb, black);
}
body {
margin: 0;
}
<div class="bg"></div>
.bg {
position: relative;
width: 100vh;
height: 100vh;
background: radial-gradient(circle closest-side, yellow, black);
}
.bg::before {
display: block;
position: absolute;
top: 0;
left: 0;
width: 100vh;
height: 50%;
background: radial-gradient(circle closest-side, #00bffb, black);
background-size: 100% 200%; /** we need to compensate for the 50% height **/
content: '';
}
body {
margin: 0;
}
<div class="bg"></div>
|
I`m trying to apply linear-gradient to my body, but it doesn't work. Now, when I use radial-gradient it works. Why is th
Tag : css , By : Igor Carron
Date : March 29 2020, 07:55 AM
I hope this helps you . With a correct value for the direction it works. "to left right" is not a direction, "to left" would be, "to left top" would work or an angle. /* COLORS */
:root{
--color-primary: #eb2f64;
--color-primary-light: #FF3366;
--color-primary-dark: #BA265D;
--color-grey-light-1: #faf9f9;
--color-grey-light-2: #f4f2f2;
--color-grey-light-3: #f0eeee;
--color-grey-light-4: #ccc;
--color-grey-dark-1: #333;
--color-grey-dark-2: #777;
--color-grey-dark-3: #999;
}
/* ============================================================== */
*{
margin: 0;
padding: 0;
}
*,
*::after,
*::before{
box-sizing: inherit;
}
html{
box-sizing: border-box;
font-size: 62.5%;
min-height: 100vh;
}
body{
font-family: 'Open Sans', sans-serif;
font-weight: 400;
line-height: 1.6;
background-image: linear-gradient(to left top, var(--color-primary-light), var(--color-primary-dark)); /* IT DOES NOT WORK*/
/* background-image: radial-gradient(circle at center, var(--color-primary-light), var(--color-primary-dark)); IT WORKS */
background-size: cover;
background-repeat: no-repeat;
min-height: 100vh;
}
<body>
<h1>Some content</h1>
</body>
|