Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 293643 - Create API for sophisticated linear and radial gradients
Summary: Create API for sophisticated linear and radial gradients
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.2   Edit
Hardware: PC Windows Vista
: P3 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-29 04:35 EDT by Kai Toedter CLA
Modified: 2020-03-25 15:47 EDT (History)
13 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kai Toedter CLA 2009-10-29 04:35:10 EDT
The SWT GC currently provides a very basic support for vertical and horizontal backgrounds. For e4 (styling) it is very important that SWT supports more sophisticated gradients. While I don't have a suggestion for an API yet, I would like the discussion here.

A good starting point for the possible capabilities could be the WebKit gradients based on css: http://webkit.org/blog/175/introducing-css-gradients/

Here is a list of possible features:
- radial and linear gradients
- list of color stops
- for linear gradients: free direction (start point/end point based)
- for radial gradients: lists of start points with radius and color-stops
Comment 1 Silenio Quarti CLA 2009-11-02 14:19:00 EST
There is already some API for this (see Pattern.java). It supports linear gradients with two color stops.
Comment 2 Kai Toedter CLA 2009-11-23 13:51:59 EST
Yes, I mentioned that in my original post, but this is way too basic for today's modern UIs.
Comment 3 Boris Bokowski CLA 2009-11-23 16:37:12 EST
Silenio, would it be possible/easy to add radial gradients? Do the platforms support this, or would we have to emulate anything?
Comment 4 Silenio Quarti CLA 2009-11-24 09:42:03 EST
Cairo/Gtk and the Quartz/Mac support radial gradients. There API is similar: the radial gradient is defined by two center points and two radius.

GDI+ has PathGradientBrush, which seems powerful, but I believe it is not possible to implement the same kind of API of Cairo/Quartz.

It may be possible to implement an API with one center point, one focal point and a radius. I will investigate.
Comment 5 Thomas Schindl CLA 2010-02-25 16:02:41 EST
Silenio, any news on this. I the light of the new CTabFolder stuff I've been experimenting renderers using SVG which provides the following features http://www.w3.org/TR/SVG11/pservers.html
Comment 6 Silenio Quarti CLA 2010-02-26 10:43:35 EST
Sorry, I spent some time trying to come with a common API for radial gradients, but I was not very successful. Given that we are so close to API freeze, I believe this is not going to happen for 3.6.
Comment 7 Carlo Salinari CLA 2011-04-28 15:56:15 EDT
Any chance to see this in 3.7?
Comment 8 Silenio Quarti CLA 2011-05-06 11:04:30 EDT
I will have to say sorry again. This API is not going to happen in 3.7.
Comment 9 Thomas Schindl CLA 2011-05-09 09:13:59 EDT
Well - here's my proposal instead of inventing an API for this why does SWT not simply provided a setStyle(String) method which allows to set an radial/linear/... gradient. 

I think this should be the solution for more advanced stuff, the current implementation of CSS stuff like gradient is more like a hack and other stuff like padding is not even implementable with it.
Comment 10 Jeremy Dowdall CLA 2012-05-19 19:34:29 EDT
I'd like to help get this bug closed out with the next release (3.9/4.3) and have taken a stab at it here: https://github.com/jeremy-dowdall/eclipse.platform.swt

The API and functionality follow SVG (http://www.w3.org/TR/SVG11/pservers.html - as mentioned earlier by Tom):

 // linear gradient
 Pattern pattern = new Pattern(device, x1, y1, x2, y2);
 pattern.setSpreadMethod(Pattern.REFLECT);
 pattern.addStop(color1, 0.0f, 255);
 pattern.addStop(color2, 0.6f, 128); // color, offset, alpha
 pattern.addStop(color3, 1.0f, 0);

 gc.setBackgroundPattern(pattern);
 gc.fillRoundRectangle(0, 0, 100,100, 10,10);

 // a radial gradient just takes an extra parameter:
 Pattern pattern = new Pattern(device, cx, cy, fx, fy, r);

The fork works on Cairo(32), Quartz(64), and GDI+(32). I've tried to make sure 32/64bit conversions are handled, but may have missed something as I don't have all environments up and running.
Comment 11 Jeremy Dowdall CLA 2012-07-25 19:46:53 EDT
Silenio, any update on this?  Let me know how I can help.
Comment 12 Eclipse Genie CLA 2020-03-25 15:47:09 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.