Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 599067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:27:27+00:00 2026-05-13T16:27:27+00:00

The gradient in question is Figure 8-5 from the Quartz 2D Programming Guide, A

  • 0

The gradient in question is Figure 8-5 from the Quartz 2D Programming Guide, “A radial gradient that varies between a point and a circle”.

I’m trying to build a CGGradient object (not a CGShading object, which might be the problem) like so:

CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
CGFloat colors[] =
{
    0, 0, 0, 0.9,
    0, 0, 0, 0
};
CGGradientRef gradient = CGGradientCreateWithColorComponents(rgb, colors, NULL, sizeof(colors)/(sizeof(colors[0])*sizeof(CGFloat)));
CGContextClipToRect(context, rect);
CGContextDrawRadialGradient(context, gradient, startCenter, startRadius, endCenter, endRadius, gradientDrawingOptions);
CGGradientRelease(gradient);
CGColorSpaceRelease(rgb);

Of course, that isn’t exactly right — the centre points and radii are correct, but the actual gradient doesn’t look the same. I just wish Apple had provided the source code for each example! >:(

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:27:27+00:00Added an answer on May 13, 2026 at 4:27 pm

    UPDATE: These color values add the shading on top of other content (drawing from a point out to a circle):

    CGFloat colors[] =
    {
        0.0f, 0.0f, 0.0f, 0.0f,
        0.0f, 0.0f, 0.0f, 0.75f
    };
    

    Using these color values is pretty close (drawing from a point out to a circle):

    CGFloat colors[] =
    {
        0.0f, 1.0f, 1.0f, 1.0f,
        0.0f, 0.0f, 0.0f, 0.75f
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for noobish question about iPhone and Quartz programming. Just started my conversion from
This is a code organization question. I have code that will put a gradient
Something similar to this question has been asked here - HTML/CSS Gradient that stops
How do remove the gradient from a UIWebView - the one that you see
What is the gradient in circle animation in ProgressDialog? I would like to use
I am trying to figure out what the element name for the tooltip is
What I'm trying to accomplish is creating a gradient using only css... What I'm
I'm having an issue where I'm trying to update the background gradient of an
I'm implementing a coherent noise function, and was surprised to find that using gradient
the pixman image library can draw radial color gradients between two circles. I'd like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.