~eliasnaur/gio

2 2

LinearGradient and RadialGradient

Details
Message ID
<CABC=nZzyXfXVAO_+aCyVCmFQjsOi-LukeH87aOQh6eDVd0THHQ@mail.gmail.com>
DKIM signature
pass
Download raw message
I see that LinearGradient doesn't seem to have implemented angle yet.

> type LinearGradientOp struct {
> Stop1 f32.Point
> Color1 color.NRGBA
> Stop2 f32.Point
> Color2 color.NRGBA
> }


I want to implement RadialGradient, is there any reference material
that I can use?
Details
Message ID
<CAMAFT9UQ5_Rn-i5MLup503LWu2nH3k0D9z-ihxtbTPjJk9TMqw@mail.gmail.com>
In-Reply-To
<CABC=nZzyXfXVAO_+aCyVCmFQjsOi-LukeH87aOQh6eDVd0THHQ@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
On Sun, 1 May 2022 at 15:14, qiannian <qianniancn@gmail.com> wrote:
>
> I see that LinearGradient doesn't seem to have implemented angle yet.
>
> > type LinearGradientOp struct {
> > Stop1 f32.Point
> > Color1 color.NRGBA
> > Stop2 f32.Point
> > Color2 color.NRGBA
> > }
>
>
> I want to implement RadialGradient, is there any reference material
> that I can use?

Hi,

When in doubt about graphics, I ask Egon (CC'ed) or look up anything
by Raph. I'd start with

https://observablehq.com/@raphlinus/perceptually-smooth-multi-color-linear-gradients
or maybe
https://raphlinus.github.io/color/2021/01/18/oklab-critique.html

and work from there.

Elias
Details
Message ID
<CANtNKfoMHOjWNn5wRH9M5sbznZeyrqtf+rkAEOutnyM0TFbcig@mail.gmail.com>
In-Reply-To
<CAMAFT9UQ5_Rn-i5MLup503LWu2nH3k0D9z-ihxtbTPjJk9TMqw@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
I'm not quite sure what you mean by `angle` in this context?

For linear gradient it allows to specify start and end,
which don't have to be either horizontal or vertical.
Or in other words, it already supports an angle.

With regards to radial gradients I have a proof of concept at:
https://github.com/egonelbre/gio/tree/radial and discussion
https://github.com/gioui/gio/pull/28.

The basic idea is the same, that you provide the center and a major axis
edge point... + eccentricity (for ellipses). Then use the distance to calculate
the appropriate value.

+ Egon

On Mon, May 2, 2022 at 10:44 AM Elias Naur <mail@eliasnaur.com> wrote:
>
> On Sun, 1 May 2022 at 15:14, qiannian <qianniancn@gmail.com> wrote:
> >
> > I see that LinearGradient doesn't seem to have implemented angle yet.
> >
> > > type LinearGradientOp struct {
> > > Stop1 f32.Point
> > > Color1 color.NRGBA
> > > Stop2 f32.Point
> > > Color2 color.NRGBA
> > > }
> >
> >
> > I want to implement RadialGradient, is there any reference material
> > that I can use?
>
> Hi,
>
> When in doubt about graphics, I ask Egon (CC'ed) or look up anything
> by Raph. I'd start with
>
> https://observablehq.com/@raphlinus/perceptually-smooth-multi-color-linear-gradients
> or maybe
> https://raphlinus.github.io/color/2021/01/18/oklab-critique.html
>
> and work from there.
>
> Elias
Reply to thread Export thread (mbox)