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 7049271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:59:35+00:00 2026-05-28T02:59:35+00:00

If I was given color A and color B, how can one go aboit

  • 0

If I was given color A and color B, how can one go aboit generating a gradient on a canvas which can be later converted to a bitmap.

Such that

public Bitmap makeGradient(Color from, Color to){}

Would actually work?

I hope this is not too vague. I thankyou for your time and effort.

Ps. There is a question on stackoverflow that answers this but I amstill confused 🙁

Here it is: Generating gradients programmatically?

  • 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-28T02:59:35+00:00Added an answer on May 28, 2026 at 2:59 am

    One way to go about creating a radial gradient might be to define the focus point as well as the extent of the gradient and when you generate the image you’d calculate the distance between the current pixel and the focus point, divide it by the gradient extent and clip the result to 1. Then use the formula in the question you linked.

    Something like this pseudocode:

    double d = distance(currentPixel, focusPoint); //I'll leave the implementation for you
    double factor = Math.max(1.0, d/extent);
    
    int red = (int) (firstCol.getRed() * factor + secondCol.getRed() * (1.0 - factor) );
    int green= (int) firstCol.getGreen() * factor + secondCol.getGreen()* (1.0 - factor) );
    int blue = (int) (firstCol.getBlue() * factor + secondCol.getBlue()* (1.0 - factor) );
    

    This would mean that the farther a pixel is from the focus point the more firstCol will contribute to it (pixels that are outside the extent of the gradient will only use firstCol since factor should be 1.0 for those).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to color given area of bitmap. After show it on screen. Currently
How can I parse a String str = abc, \def,ghi\ ; such that I
Given 2 tables: Person PersonsFavoriteColors A person can have one or more favorite colors.
So the issue is the user can either give input that is one int,
I am using some functions such as color contour tracking and image matching which
I would like some one to provide me with a valid css which can
In how many ways we can give color info in X/HTML, css? I know
So I've been given an assignment in my Mobile apps class: make a color
I'm looking for a possibility to get the color of a pixel with given
I am looking to transform a input xml given below <profile name=default> <color id=forecolor

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.