Recent

Author Topic: [Wiki] Sample Graphics  (Read 37615 times)

circular

  • Hero Member
  • *****
  • Posts: 4450
    • Personal webpage
Re: [Wiki] Sample Graphics
« Reply #15 on: March 21, 2011, 04:29:55 pm »
You mean the problem of multiple back-ends ?

Well I think that it would be solved by making TAChart draw on a generic back-end, using a generic class with abstract methods, and with this, a series of units for each back-end.

For example :
Code: Pascal  [Select][+][-]
  1. Uses TAChart, BGRABackEnd;
  2.  
  3. var
  4.    MyChart: TAChart;
  5.  
  6. begin
  7.   MyChart := TAChart.Create(TBGRABackEnd.Create);
  8. end;

Or, if it is a component, something like :
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Create(Sender: TObject);
  2. begin
  3.   MyChart.BackEnd := TBGRABackEnd.Create;
  4. end;
Conscience is the debugger of the mind

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: [Wiki] Sample Graphics
« Reply #16 on: March 21, 2011, 05:37:29 pm »
Quote
You mean the problem of multiple back-ends ?

No, that's already done.

I want to add gradients to TChart.
What properties/methods should I add, and to which classes?
Gradients may be used in chart background, title, axises, series...
They could be linear, multi-color, even phong ;-)
Besides gradients, where may be other embellishments:
shadows, transparency, etc.
At the same time, some embellishments may be available only for certain back-ends.
I need a design which will be compact, general and extensible enough.

circular

  • Hero Member
  • *****
  • Posts: 4450
    • Personal webpage
Re: [Wiki] Sample Graphics
« Reply #17 on: March 21, 2011, 05:52:51 pm »
About gradients, I came up in BGRABitmap with a function with these arguments :
color1, color2, gradientType, origin1, origin2

origin1 is filled with color1, origin2 with color2, and the gradient type can be linear, reflected, radial or diamond. Do you think that's enough gradients, or do you want to add more ?

About phong, I think that it should be reserved for bars and other chart pieces. A phong background does not make much sense, except of course if you want to give the whole graph a phong border, but it would be slow, so I'm not sure it's a good idea.

Transparency is just an Opacity:Byte property for each thing.

About shadows, well, you can wait a little before adding it.  :)
Conscience is the debugger of the mind

JD

  • Hero Member
  • *****
  • Posts: 1908
Re: [Wiki] Sample Graphics
« Reply #18 on: March 26, 2011, 10:26:16 pm »
@circular
The mock up chart you created using BGRABitmap look great. TaChart needs a face lift now that BGRABitmap is available.
Linux Mint - Lazarus 4.0/FPC 3.2.2,
Windows - Lazarus 4.0/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: [Wiki] Sample Graphics
« Reply #19 on: March 27, 2011, 10:10:49 am »
I agree. However, I wish to implement a drawer-independent interface for TChart
embellishments, so other back-ends benefit too.

If you have concrete proposals for such an API, I would be glad to hear them.

circular

  • Hero Member
  • *****
  • Posts: 4450
    • Personal webpage
Re: [Wiki] Sample Graphics
« Reply #20 on: March 27, 2011, 10:52:03 pm »
@circular
The mock up chart you created using BGRABitmap look great.
Thanks.
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4450
    • Personal webpage
Re: [Wiki] Sample Graphics
« Reply #21 on: March 27, 2011, 10:55:11 pm »
I agree. However, I wish to implement a drawer-independent interface for TChart
embellishments, so other back-ends benefit too.
Do you mean you would like to include phong drawing with other back-ends ?
Well I think that it is possible to adapt such code. But it is quite linked to BGRABitmap.
Conscience is the debugger of the mind

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: [Wiki] Sample Graphics
« Reply #22 on: March 27, 2011, 11:50:28 pm »
Although that may be a good idea in itself, it is not quite what I meant.
I accept the fact that different back-ends have different capabilities,
and so TChart functionality may be limited when using them.
Otherwise, there would be little point in creating back-ends in the first place.

For example, currently AggPas supports antialiasing and rotated text,
but does not support pen styles, BGRABitmap supports antialiasing and pen styles,
but not rotated text, TCanvas supports rotated text and pen styles, but not antialiasing.

However, my goal is to design common API, so that the TChart-using
code may be ported to a different back-end with no effort.

Ideally, the API should both degrade gracefully in case some features are unavailable
and be extensible for the future embellishments.

For example, if one day user requests three-color gradients
(and, believe it or not, at least one user already asked for *six*-color gradients),
I want to be able to add them with minimal disturbance to the other code.

circular

  • Hero Member
  • *****
  • Posts: 4450
    • Personal webpage
Re: [Wiki] Sample Graphics
« Reply #23 on: March 28, 2011, 11:29:29 am »
I understand. But I don't understand why you specify this because you already said that you wanted to use multiple back-ends.

Do you want to say that you are worried that adding some capabilities might make your chart not work with other back-ends ?

I don't think that it's a risk. You can implement an alternative behavior if phong drawing is not available. For example, you can draw with one solid color instead. If you want to make it more beautiful, you can draw light and shadow borders that are simply trapezoids. Then you only have to calculate 4 colors, for example the brightest at the top, next at the left, next at the right, and the darkest at the bottom.

If there is some capability that you need in BGRABitmap, just ask, and I'll see what I can do. If some capability is not completely necessary but would make your life easier, you can ask too. It would be clear for me if you gave me a list, and with each item if you absolutely need it or if it would be easier for you or if it's completely optional to achieve your work.
Conscience is the debugger of the mind

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: [Wiki] Sample Graphics
« Reply #24 on: March 28, 2011, 02:59:43 pm »
Quote
Do you want to say that you are worried that adding some capabilities might make your chart not work with other back-ends ?

No, no, as I already said, that is not the problem.

Let me illustrate with concrete example. Suppose I want to add gradients, say, to bar series.
A naive solution would be to add Color1, Color2 and GradientDirection properties to the
TBarSeries class.
However, individual bars can be colored differently by supplying color from the chart source,
so I need to deal with that. Say, I add another property "SourceColorGradientIndex",
which will allow user to replace either Color1 or Color2 with the chart source color.
Then, there are brush patterns, which should interact with gradients somehow --
either one should disable the other, or they should somehow be combined, perhaps
controlled by another property.
After that, there are multi-valued series (aka stacked bars, see multi demo).
The colors of multi-valued series are controlled by Styles property
of the TBarSeries.
So yet another property should be added to control how gradients work with multi-valued series.
After implementing all of the above, similar changes should be done to other series types
(there are currently 12 of those) and to elements of TChart itself, such as
backwall, title/footer and axises.
The above, although a lot of work, is not the problem yet.
But if, afterwards, a user comes and asks for three-color gradients -- then
all the steps above have to be repeated. THAT is the problem I am trying to avoid.

Quote
It would be clear for me if you gave me a list, and with each item if you absolutely need it or if it would be easier for you or if it's completely optional to achieve your work.
Sure. Only one item is absolutely needed -- that is a working package.
I have a implemented the back-end for a few days already, and it is not published only
because of this problem. For now, see attached screenshot instead of demo.

All others are "nice to have", but I'd say the "nicest" of them would be
1) Clipping
2) Font.Orientation
3) Brush.Style

circular

  • Hero Member
  • *****
  • Posts: 4450
    • Personal webpage
Re: [Wiki] Sample Graphics
« Reply #25 on: March 28, 2011, 07:32:25 pm »
Ok. So your problem is about how combining all possibilities. It's a matter of interdependance, how different attributes interact with each other.

This concerns only TAChart code that handles this. I was mistaken because I thought you were talking about back-ends independance.

To solve this, I think that you need to determine first what will be available in TAChart. Then, you need to produce a logical structure that combines all of them.

About getting the properties from a data source, it's almost an independant issue. These values just override the default property value. If you define gradients with Color1, Color2 and GradientDirection, I suppose you need to define :
- SourceColor1Index
- SourceColor2Index
- SourceGradientDirectionIndex
or something like that. It's kind of duplicating all properties with a source property.

I suppose the real invention here is to find the properties to handle all cases and the way they interact with each other. I don't think you should rush to publish anything before you have something coherent.

Quote
All others are "nice to have", but I'd say the "nicest" of them would be
1) Clipping
2) Font.Orientation
3) Brush.Style
I'll see what I can do for that.
Conscience is the debugger of the mind

lainz

  • Guest
Re: [Wiki] Sample Graphics
« Reply #26 on: March 31, 2011, 03:22:32 pm »
New Text Shadow example with BGRABitmap:
http://wiki.lazarus.freepascal.org/Sample_Graphics#Text_Shadow

And updated Lazarus Logo with AntiAliased Text:
http://wiki.lazarus.freepascal.org/Sample_Graphics#Lazarus_About

circular

  • Hero Member
  • *****
  • Posts: 4450
    • Personal webpage
Re: [Wiki] Sample Graphics
« Reply #27 on: March 31, 2011, 07:05:25 pm »
Lainz, I suggest you to do a text shadow using FilterBlurRadial(4,rbFast) or with another radius.
Conscience is the debugger of the mind

lainz

  • Guest
Re: [Wiki] Sample Graphics
« Reply #28 on: April 03, 2011, 12:59:45 am »
Lainz, I suggest you to do a text shadow using FilterBlurRadial(4,rbFast) or with another radius.

Updated: now using BGRAGradients 'TextShadow' function
http://wiki.lazarus.freepascal.org/Sample_Graphics#Text_Shadow

circular

  • Hero Member
  • *****
  • Posts: 4450
    • Personal webpage
Re: [Wiki] Sample Graphics
« Reply #29 on: April 03, 2011, 12:23:42 pm »
Cool.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018