Improving 3D look lazarus / 55-TAChart ---------------------------------------------------------------------- JD · 2012-10-18 14:52 Hi there guys, Let me join in this discussion. You guys (wp and Ask) have done a great job. I've learned a lot from your persistence in improving this charting component. However, one of the improvements I've longed to see in TAChart is its 3D charting abilities. Drawing 3D bar charts in TAChart look "off" compared to Delphi's TeeChart or even the deprecated Lazarus TBarChart. If at the minimum, TAChart can adopt TBarChart's rendering of 3D chart objects, it would make a great deal of difference from what exists actually. The attached screenshot will better explain what I'm trying to say. JD ---------------------------------------------------------------------- Ask · 2012-10-18 15:34 I have split your post in a separate topic, since it is tangential to the discussion it appeared in. You are correct, 3D is probably the weakest part of TAChart now. Unfortunately, there are some difficulties, mostly related to the fact that all the existing features must be made to work in 3-D mode, which is sometimes non-trivial. Nevertheless, I do plan to work in this, but have no time right now. Meanwhile, you can slightly improve your example by increasing ZPosition property of axises. ---------------------------------------------------------------------- lainz · 2012-10-18 16:40 Quote from: Ask on October 18, 2012, 05:34:32 pmI have split your post in a separate topic, since it is tangential to the discussion it appeared in. You are correct, 3D is probably the weakest part of TAChart now. Unfortunately, there are some difficulties, mostly related to the fact that all the existing features must be made to work in 3-D mode, which is sometimes non-trivial. Nevertheless, I do plan to work in this, but have no time right now. Meanwhile, you can slightly improve your example by increasing ZPosition property of axises. Hi Ask, I want to create charts from images, I've done something like that with Flash, but now that BGRABitmap has 9-slice scaling I think that I can do something in Lazarus http://www.youtube.com/watch?v=YTtg9WfdNao&feature=plcp Those are 2 images (flash vectorial, but with BGRABitmap we can use any bitmap to be scaled). I can create the animation with a timer and a bgravirtualscreen, the bars are just png files drawed with a TBGRASliceScaling. You have some link to understand how TAChart works? Or any link that help me to create a chart component. Thanks. ---------------------------------------------------------------------- Ask · 2012-10-18 17:05 I do not quite what "charts from images" means. Do you want to create a chart based on property of some image, like color distribution? Do you want a component which analyses given image of a chart, and creates a similar chart? Or something else? Looking at the video you linked, perhaps you want to create a chart with animated growing bars? If so, it is already possible -- look at "animate" demo. QuoteYou have some link to understand how TAChart works?Start from the main wiki page. There you will find links to documentation and a set of tutorials. QuoteOr any link that help me to create a chart component.I am afraid that such a task would require much more than a link :-) Why not help improving TAChart instead? ---------------------------------------------------------------------- lainz · 2012-10-18 17:16 Quote from: Ask on October 18, 2012, 07:05:35 pmI do not quite what "charts from images" means. Do you want to create a chart based on property of some image, like color distribution? Do you want a component which analyses given image of a chart, and creates a similar chart? Or something else? Looking at the video you linked, perhaps you want to create a chart with animated growing bars? If so, it is already possible -- look at "animate" demo. QuoteYou have some link to understand how TAChart works?Start from the main wiki page. There you will find links to documentation and a set of tutorials. QuoteOr any link that help me to create a chart component.I am afraid that such a task would require much more than a link :-) Why not help improving TAChart instead? Well the thing is drawing the bars from bitmap (it gives the pseudo-3d look), the 9-slice scaling thechnique applied to this is to don't resize the borders, so the bars will have the correct proportion in any size (is like an advanced stretch). I can't find the Animate demo, is in SVN? or in lazarus 1.0. Ok I'll see the docs. ---------------------------------------------------------------------- Ask · 2012-10-18 17:26 Quotedrawing the bars from bitmap (it gives the pseudo-3d look)Ah, I see -- you can use OnBeforeDrawBar event for that. QuoteI can't find the Animate demo, is in SVN?Yes. ---------------------------------------------------------------------- lainz · 2012-10-18 17:39 Quote from: Ask on October 18, 2012, 07:26:15 pmQuotedrawing the bars from bitmap (it gives the pseudo-3d look)Ah, I see -- you can use OnBeforeDrawBar event for that. QuoteI can't find the Animate demo, is in SVN?Yes. Thankyou! ---------------------------------------------------------------------- lainz · 2012-10-18 20:53 It works nicely =) I've uploaded the test to bgracontrols svn, to don't lose it. (It requires BGRABitmap and BGRAControls - only slicescaling.pas). ---------------------------------------------------------------------- Ask · 2012-10-19 06:46 Yes, looks good. QuoteBGRABitmap and BGRAControlsWhy BGRAControls? I could include this example in "bgra" demo if it would only depend on BGRABitmap. ---------------------------------------------------------------------- lainz · 2012-10-20 14:56 Hi Ask, attached the demo, it now requires only BGRABitmap latest svn. ---------------------------------------------------------------------- Silvio Clécio · 2013-01-30 18:29 Please ask to add the demo "tachartslicescaling.zip" in TAChart demos. It's a nice demo. ---------------------------------------------------------------------- circular · 2013-01-30 18:48 What about adding a demo using phong shading from BGRABitmap too ? You could have something like this : ---------------------------------------------------------------------- Silvio Clécio · 2013-01-30 18:50 V.E.R.Y nice! ---------------------------------------------------------------------- Ask · 2013-01-31 06:57 Added slice and texture to the bgra demo in r40083. I have noticed that TBGRASliceScaling lacks an option to preserve proportions of "fixed" parts. I had to use a temporary bitmap to achieve that. Texture part is based on http://wiki.freepascal.org/BGRABitmap_tutorial_9 ---------------------------------------------------------------------- circular · 2013-01-31 08:46 Hello Ask, Here is a modified version of Main unit of bgrademo with a better rendering : Code: [Select]unit Main; {$mode objfpc}{$H+} interface uses   Classes, ComCtrls, ExtCtrls, StdCtrls, SysUtils, FileUtil, Forms,   Controls, Graphics, Dialogs,   TAGraph, TASeries, TASources, TAAnimatedSource, TACustomSource,   BGRASliceScaling; type   { TForm1 }   TForm1 = class(TForm)     btnStartStop: TButton;     cbAntialiasing: TCheckBox;     cbPie: TCheckBox;     chSimple: TChart;     chSimpleAreaSeries1: TAreaSeries;     chSimpleBarSeries1: TBarSeries;     chSimpleLineSeries1: TLineSeries;     chSimplePieSeries1: TPieSeries;     chBarEffects: TChart;     chBarEffectsBarSeries1: TBarSeries;     Image1: TImage;     ListChartSource1: TListChartSource;     PageControl1: TPageControl;     PaintBox1: TPaintBox;     Panel1: TPanel;     Panel2: TPanel;     RandomChartSource1: TRandomChartSource;     rgAnimation: TRadioGroup;     rgStyle: TRadioGroup;     Splitter1: TSplitter;     tsSimple: TTabSheet;     tsBarEffects: TTabSheet;     procedure btnStartStopClick(Sender: TObject);     procedure cbAntialiasingChange(Sender: TObject);     procedure cbPieChange(Sender: TObject);     procedure chSimpleAfterPaint(ASender: TChart);     procedure chBarEffectsBarSeries1BeforeDrawBar(ASender: TBarSeries;       ACanvas: TCanvas; const ARect: TRect; APointIndex, AStackIndex: Integer;       var ADoDefaultDrawing: Boolean);     procedure FormCreate(Sender: TObject);     procedure FormDestroy(Sender: TObject);     procedure PaintBox1Paint(Sender: TObject);     procedure rgAnimationClick(Sender: TObject);   private     FAnimatedSource: TCustomAnimatedChartSource;     FSliceScaling: TBGRASliceScaling;     procedure OnGetItem(       ASource: TCustomAnimatedChartSource;       AIndex: Integer; var AItem: TChartDataItem);   end; var   Form1: TForm1; implementation {$R *.lfm} uses   Math, BGRABitmap, BGRABitmapTypes, BGRAGradients,   TAChartUtils, TADrawerBGRA, TADrawerCanvas, TADrawUtils, TAGeometry; function CreateChocolateBar(ALightPos: TPoint; ARect: TRect; ABackColor: TBGRAPixel; ARoundedCorners: boolean; AOptions: TRectangleMapOptions): TBGRABitmap; var   phong: TPhongShading;   tx, ty: integer; begin   tx := ARect.Right-ARect.Left;   ty := ARect.Bottom-ARect.Top;   if tx < 0 then tx := 0;   if ty < 0 then ty := 0;   Result := TBGRABitmap.Create(tx, ty, ABackColor);   if (tx = 0) or (ty = 0) then exit;   phong := TPhongShading.Create;   try     phong.AmbientFactor := 0.5;     phong.LightPosition := Point(ALightPos.X-ARect.Left, ALightPos.Y-ARect.Top);     phong.DrawRectangle(Result, rect(0,0,tx,ty), tx div 8, tx div 8, GammaCompression(SetIntensity(GammaExpansion(BGRA(86, 41, 38)),30000)), ARoundedCorners, AOptions);   finally     phong.Free;   end; end; { TForm1 } procedure TForm1.btnStartStopClick(Sender: TObject); begin   if FAnimatedSource.IsAnimating then     FAnimatedSource.Stop   else     FAnimatedSource.Start; end; procedure TForm1.cbAntialiasingChange(Sender: TObject); begin   if cbAntialiasing.Checked then     chSimple.AntialiasingMode := amOn   else     chSimple.AntialiasingMode := amOff; end; procedure TForm1.cbPieChange(Sender: TObject); begin   chSimplePieSeries1.Active := cbPie.Checked; end; procedure TForm1.chSimpleAfterPaint(ASender: TChart); begin   Unused(ASender);   PaintBox1.Invalidate; end; procedure TForm1.chBarEffectsBarSeries1BeforeDrawBar(ASender: TBarSeries;   ACanvas: TCanvas; const ARect: TRect; APointIndex, AStackIndex: Integer;   var ADoDefaultDrawing: Boolean); var   temp, chocolate: TBGRABitmap;   sz: TPoint;   lightPos: TPoint;   stretched: TBGRABitmap; begin   Unused(ASender);   Unused(APointIndex, AStackIndex);   ADoDefaultDrawing := false;   sz := ARect.BottomRight - ARect.TopLeft;   case rgStyle.ItemIndex of     0: begin       temp := TBGRABitmap.Create(         FSliceScaling.BitmapWidth,         Round(FSliceScaling.BitmapWidth * sz.Y / sz.X));       stretched := nil;       try         FSliceScaling.Draw(temp, 0, 0, temp.Width, temp.Height);         temp.ResampleFilter := rfLinear;         stretched := temp.Resample(sz.x,sz.Y,rmFineResample) as TBGRABitmap;;         stretched.Draw(ACanvas, ARect, False);       finally         temp.Free;         stretched.Free;       end;     end;     1: begin       lightPos := Point(chBarEffects.ClientWidth div 2,0);       chocolate := CreateChocolateBar(lightPos, ARect, BGRAPixelTransparent, False, [rmoNoBottomBorder]);       chocolate.Draw(ACanvas, ARect.Left,ARect.Top, False);       chocolate.Free;     end;   end; end; procedure TForm1.FormCreate(Sender: TObject); begin   FAnimatedSource := TCustomAnimatedChartSource.Create(Self);   FAnimatedSource.Origin := ListChartSource1;   FAnimatedSource.AnimationInterval := 30;   FAnimatedSource.AnimationTime := 1000;   FAnimatedSource.OnGetItem := @OnGetItem;   chBarEffectsBarSeries1.Source := FAnimatedSource;   chBarEffects.BackColor:= BGRAToColor(CSSDarkSlateBlue);   chSimple.BackColor:= BGRAToColor(CSSYellowGreen);   chSimple.Color:= BGRAToColor(CSSYellowGreen);   chSimple.BackColor := BGRAToColor(CSSBeige);   FSliceScaling := TBGRASliceScaling.Create(Image1.Picture.Bitmap, 70, 0, 35, 0);   FSliceScaling.AutodetectRepeat; end; procedure TForm1.FormDestroy(Sender: TObject); begin   FSliceScaling.Free; end; procedure TForm1.PaintBox1Paint(Sender: TObject); var   bmp: TBGRABitmap;   id: IChartDrawer;   rp: TChartRenderingParams; begin   bmp := TBGRABitmap.Create(PaintBox1.Width, PaintBox1.Height);   chSimple.DisableRedrawing;   try     chSimple.Title.Text.Text := 'BGRABitmap';     id := TBGRABitmapDrawer.Create(bmp);     id.DoGetFontOrientation := @CanvasGetFontOrientationFunc;     rp := chSimple.RenderingParams;     chSimple.Draw(id, Rect(0, 0, PaintBox1.Width, PaintBox1.Height));     chSimple.RenderingParams := rp;     bmp.Draw(PaintBox1.Canvas, 0, 0);     chSimple.Title.Text.Text := 'Standard';   finally     chSimple.EnableRedrawing;     bmp.Free;   end; end; procedure TForm1.OnGetItem(   ASource: TCustomAnimatedChartSource;   AIndex: Integer; var AItem: TChartDataItem); begin   case rgAnimation.ItemIndex of   0: AItem.Y *= ASource.Progress;   1:     if ASource.Count * ASource.Progress < AIndex then       AItem.Y := 0;   2:     case Sign(Trunc(ASource.Count * ASource.Progress) - AIndex) of       0: AItem.Y *= Frac(ASource.Count * ASource.Progress);       -1: AItem.Y := 0;     end;   end; end; procedure TForm1.rgAnimationClick(Sender: TObject); begin   FAnimatedSource.Start; end; end. ---------------------------------------------------------------------- circular · 2013-01-31 08:55 How can one know the 3D parameters of a bar in the OnBeforeDrawBar event? There is only a ARect value for the front side, right? ---------------------------------------------------------------------- JD · 2013-01-31 10:19 @circular Well done! Now that's looking more like it. A few more iterations like that and it'll be perfect. We are competing against Flash charts and other stuff created with AJAX so the competition is fierce. Looks are everything to a client. Thanks, JD ---------------------------------------------------------------------- Ask · 2013-01-31 12:19 Quote from: circularHere is a modified version of Main unit of bgrademo with a better renderingThanks, committed in r40095. QuoteHow can one know the 3D parameters of a bar in the OnBeforeDrawBar event?TAChart does not support "true" 3D, but only a limited isometric projection from 45 degree angle. So, 3D parameters of all bars are the same, you can access them by using ASender.ZPosition and ASender.Depth properties. ---------------------------------------------------------------------- circular · 2013-01-31 14:19 Thanks. ---------------------------------------------------------------------- circular · 2013-01-31 15:13 Ok, so here is a function to draw 3D bar with BGRA : Code: [Select]procedure DrawPhong3DBar(AChart: TChart; ASeries: TBarSeries; ACanvas: TCanvas; ARect: TRect);   function CreatePhong3DBar(ALightPos: TPoint; ARect: TRect; ADepth: integer; AColor: TBGRAPixel): TBGRABitmap;   var     phong: TPhongShading;     i,tx, ty: integer;     map: TBGRABitmap;     h: TBGRAPixel;   begin     tx := ARect.Right-ARect.Left;     ty := ARect.Bottom-ARect.Top;     if tx < 0 then tx := 0;     if ty < 0 then ty := 0;     map := TBGRABitmap.Create(tx+ADepth,ty+ADepth);     map.FillRect(0,ADepth,tx,ty+ADepth,BGRAWhite,dmSet);     for i := 1 to ADepth do     begin       h := MapHeightToBGRA((ADepth-i)/ADepth,255);       map.SetHorizLine(i,ADepth-i,tx-1+i-1,h);       map.SetVertLine(tx-1+i,ADepth-i,ty+ADepth-1-i,h);     end;     Result := TBGRABitmap.Create(tx+ADepth, ty+ADepth);     if (result.width = 0) or (result.height = 0) then exit;     phong := TPhongShading.Create;     try       phong.AmbientFactor := 0.5;       phong.LightPosition := Point(ALightPos.X-ARect.Left, ALightPos.Y-ARect.Top);       phong.Draw(Result, map, ADepth, 0,0, AColor);     finally       phong.Free;       map.Free;     end;   end; var origin,lightPos: TPoint;   bar,temp: TBGRABitmap;   margin,depth: integer;   size: TSize; begin   lightPos := Point(AChart.ClientWidth div 2,0);   depth := ASeries.Depth;   size := ARect.BottomRight - ARect.TopLeft;   bar := CreatePhong3DBar(lightPos, ARect, depth, ColorToBGRA(ASeries.BarBrush.Color));   origin := point(0,0);   if ASeries.BarPen.Style <> psClear then   begin     if ASeries.BarPen.Width > 1 then     begin       margin := (ASeries.BarPen.Width+1) div 2;       origin := point(margin,margin);       temp := TBGRABitmap.Create(bar.width+2*margin,bar.Height+2*margin);       temp.PutImage(origin.x,origin.y,bar,dmSet);       BGRAReplace(bar,temp);     end;     with bar.CanvasBGRA do     begin       Pen.Assign(ASeries.BarPen);       Brush.Style := bsClear;       Polygon([Point(origin.x+0,origin.y+depth),Point(origin.x+depth,o rigin.y+0),          Point(origin.x+size.cx- 1+depth,origin.y+0),Point(origin.x+size.cx-1+depth,origin.y+size.cy- 1),          Point(origin.x+size.cx-1,origin.y+size.cy- 1+depth),Point(origin.x+0,origin.y+size.cy-1+depth)]);     end;   end;   bar.Draw(ACanvas, ARect.Left-origin.X,ARect.Top-origin.Y-depth, False);   bar.Free; end;    How to use, for example, add an option rgStyle radiobuttons, and in the draw handler : Code: [Select]procedure TForm1.chBarEffectsBarSeries1BeforeDrawBar(ASender: TBarSeries;   ACanvas: TCanvas; const ARect: TRect; APointIndex, AStackIndex: Integer;   var ADoDefaultDrawing: Boolean); ... begin   Unused(APointIndex, AStackIndex);   ADoDefaultDrawing := false;   sz := ARect.BottomRight - ARect.TopLeft;   case rgStyle.ItemIndex of     ...     2: DrawPhong3DBar(chBarEffects, ASender, ACanvas, ARect);   end; end; ---------------------------------------------------------------------- lainz · 2013-01-31 22:15 Nice that's reall 3D ---------------------------------------------------------------------- Ask · 2013-02-01 08:59 Quotehere is a function to draw 3D bar with BGRA: Committed with minor changes in r40108. ---------------------------------------------------------------------- circular · 2013-02-01 09:34 Cool. The labels of the bottom axis are not completely visible with 3D bars. ---------------------------------------------------------------------- circular · 2013-02-01 13:00 Hey ask, here is a patch for TAChartBGRA package, with a class to create BGRA bar series. To use it : Code: [Select]var     FBar: TBGRABarSeries; begin   FBar := TBGRABarSeries.Create(Chart1);   FBar.Depth := 10;   FBar.Title := 'bars';   FBar.SeriesColor := clBlue;   //FBar.BGRADrawingOption := doBGRAChocolate;  //uncomment this line to have a chocolate effect   Chart1.AddSeries(FBar); Or by installing the package, the BGRA series appears when editing Series property. I was thinking ask about the fact that this works only when drawing on the canvas. Otherwise, the event do not happen. So I would propose you to move the TAChart code that draw the 3D bar into the drawer with a virtual function, so that it can be overloaded. So in the BGRADrawer, it would be possible to check if it is a BGRA series, and in this case call a method dedicated to this, that would be supplied by the BGRA series object. I was also wondering how to now if a bar goes upwards or is upside down. ---------------------------------------------------------------------- Ask · 2013-02-01 14:25 Quotelabels of the bottom axis are not completely visible with 3D bars.Fixed in r40113. Quotethis works only when drawing on the canvasUsing OnBeforeDrawBar event is nice for demos and quick hacks, but it is not intended as way to extend bar series for general purpose. It was added before I created drawers, and the only reason it still accepts TCanvas is backwards compatibility. I have tried to design a general mechanism for extending series based on specific capabilities of a drawer, but stopped working on this after encountering some difficulties. Perhaps I'll resume now. Meanwhile, perhaps a good first step would be to just add DrawPhong3DBar and DrawChocolateBar procedures, since they do not depend in TAChart architecture. QuoteI was also wondering how to now if a bar goes upwards or is upside down.TAChart does not support upside-down bars, only rotated (ASeries.IsRotated) and "negative" (ASeries.Source[APointIndex]^.Y < ASeries.ZeroLevel). The last check is actually slightly more complex due to possibility of stacked bars. ---------------------------------------------------------------------- circular · 2013-02-01 14:31 Quote from: Ask on February 01, 2013, 03:25:33 pmQuotethis works only when drawing on the canvasUsing OnBeforeDrawBar event is nice for demos and quick hacks, but it is not intended as way to extend bar series for general purpose. It was added before I created drawers, and the only reason it still accepts TCanvas is backwards compatibility. I have tried to design a general mechanism for extending series based on specific capabilities of a drawer, but stopped working on this after encountering some difficulties. Perhaps I'll resume now. Meanwhile, perhaps a good first step would be to just add DrawPhong3DBar and DrawChocolateBar procedures, since they do not depend in TAChart architecture.Hmm... there are additional options, i.e, the type of 3D bar, so it is useful to have a specific type, or an additional property in the "normal" type. With the drawer, however, it is possible to handle drawing 3D bars in general, with a property for the drawer, so that "normal" type can be represented with special 3D routines. QuoteQuoteI was also wondering how to now if a bar goes upwards or is upside down.TAChart does not support upside-down bars, only rotated (ASeries.IsRotated) and "negative" (ASeries.Source[APointIndex]^.Y < ASeries.ZeroLevel). The last check is actually slightly more complex due to possibility of stacked bars. By upside-down, I mean what you call "negative". It would be useful to have a boolean for that, because in some cases, the 3D bar looks differently (for example with chocolate if there is no border from the zero level). ---------------------------------------------------------------------- circular · 2013-02-01 14:37 As long as BGRABitmap is not part of the LCL or TAChart, it is useful to have a specific series type anyway, so that it is possible to have BGRA rendering at design time. Thus there is no need to do some complex code to draw it on a paintbox, only visible at runtime. Otherwise, what you can do is provide a way to create a BGRA chart class : Code: [Select]type TBGRAChart = class(TChart)With functions to override. Note that still additional properties may be useful to defined the 3D look. ---------------------------------------------------------------------- circular · 2013-02-03 20:07 Hello, Here is a patch to have some basic 3D lighting to bar series for any drawer : ---------------------------------------------------------------------- Ask · 2013-02-04 02:22 I have a couple of questions: 1) Why do you modify the color of the bars' front? After you patch, the color user have selected will be actually the color of top side of the bar. I believe it would be better to modify "right" and "top" colors, leaving "front" color as-is. 2) User has no control over modified colors -- at a minimum, this should be protected by boolean switch. However, I would prefer mode detailed control -- can you (or anybody else) check what is the corresponding API in TeeChart (or other charting components)?. ---------------------------------------------------------------------- circular · 2013-02-04 10:39 1) First about the reflection of the light. If you consider that the light is coming from above your head, it will bounce on the bars and get back to the viewer, thus giving a white reflection. It will bounce on the top of the bars, but continue going forward, so no reflection. It will not bounce much on the right side of the bar. Secondly, about the luminosity, front and top sides of the bars will be illuminated, so there will not be darkened. The right side of the bars is not directly illuminated, thus it is darkened. 2) What do you mean by protected ? It is beautiful, right ? Well I don't know TeeChart, but you can parametrize this using two parameters for each side : one for the light reflection, and one for the ambiant light (darkening). So you have for each RGB component : Code: [Select]ResultingValue := Min(255, (OriginalValue * AmbiantLight) div 255 + ReflectedLight)(EDIT : modified the formula so that reflected light is just between 0..255) But I'm sure most people will not want to touch those parameters. Maybe a parameter about the strength of the effect could be interesting. It is also possible to have full phong lighting computation. In all cases, I have a query that you add a virtual function in the drawer to draw a 3D bar, which can for example return a boolean value if it does something, so that the normal drawing is not used. Same thing for all ojects, so that a custom drawing can be used with a drawer. ---------------------------------------------------------------------- circular · 2013-02-04 10:56 About the TABGRAUtils unit, after you've decided the best parameters for the functions, can you add it to the TAChartBGRA package ? ---------------------------------------------------------------------- Ask · 2013-02-04 12:48 1) About sides -- I do understand and agree with the relative brightness of the sides. My suggestion was to left the front side unchanged, and calculate top and right sides from that. I believe it will be more intuitive to the user -- the "main" part of the bar will not change color while switching between 2D and 3D. Anyway, this part is not a problem -- I can easily implement it myself, just wanted to understand your reasoning. QuoteWhat do you mean by protectedI meant boolean property "Colors3D" of similar. However, as I already said, this control is perhaps too coarse. QuoteI'm sure most people will not want to touch those parameters. Maybe a parameter about the strength of the effect could be interesting.This is exactly the hardest part of any design -- inventing a good API Yes, perhaps a single "LightingLevel"control would be good. On the other hand, if there are several series on the chart, it may be preferable to have these parameters synchronized, so perhaps this property should be on TChart? We should also consider other series types -- at a minimum, area and line series. For those, amount of light should probably depend on angle, which might require a separate parameter to set light direction. QuoteI have a query that you add a virtual function in the drawer to draw a 3D bar ... same thing for all objects Unfortunately, this is not enough -- I do not want a separate drawer for each graphical effect. I am planning a special interface for effects, but it is not finished yet. Still, I am working on a first step right now QuoteAbout the TABGRAUtils unit, after you've decided the best parameters for the functions, can you add it to the TAChartBGRA package ?It should already be in the package -- why do you think it is not? ---------------------------------------------------------------------- circular · 2013-02-04 15:17 Quote from: Ask on February 04, 2013, 01:48:29 pm1) About sides -- I do understand and agree with the relative brightness of the sides. My suggestion was to left the front side unchanged, and calculate top and right sides from that. I believe it will be more intuitive to the user -- the "main" part of the bar will not change color while switching between 2D and 3D. Anyway, this part is not a problem -- I can easily implement it myself, just wanted to understand your reasoning.I suppose you would like to make the top of the bar brighter instead of the front, but this does not makes sense from a lighting point of view. If the reflection is on the top of the bar, it means that the light is behind the bars, so that the front will not be lightened at all. QuoteQuoteWhat do you mean by protectedI meant boolean property "Colors3D" of similar. However, as I already said, this control is perhaps too coarse.Hmm, maybe anyway it would be simpler to add this lighting option in TChart directly. QuoteYes, perhaps a single "LightingLevel"control would be good. On the other hand, if there are several series on the chart, it may be preferable to have these parameters synchronized, so perhaps this property should be on TChart?Yes, and LightingLevel of zero would mean "no lighting". QuoteWe should also consider other series types -- at a minimum, area and line series. For those, amount of light should probably depend on angle, which might require a separate parameter to set light direction.Sure, and you can see here that anyway, either the top of "lines with depth" or the front of "areas" will have some lighting effect, so about bars, you will have the same thing. If you prefer to have the reflection on the top of the bar, then horizontal lines will have a reflection too. If you don't want to get to deep into lighting considerations, you can consider a phong lighting using light at infinity. So for each surface, you need to compute the normal vector, and then compute the lighting effect according to light direction. There are two components of the lighting effect : ambiant and reflection (specular). These are computed differently. Ambiant can increase the color intensity without making it white, while specular adds whiteness to it, even if the object is dark. QuoteUnfortunately, this is not enough -- I do not want a separate drawer for each graphical effect. I am planning a special interface for effects, but it is not finished yet. Still, I am working on a first step right now Well, if it is possible to customize the rendering at the end with the drawer, that's ok. Just keep in mind that all drawers cannot do the same things. QuoteQuoteAbout the TABGRAUtils unit, after you've decided the best parameters for the functions, can you add it to the TAChartBGRA package ?It should already be in the package -- why do you think it is not?Simply because it is not in the last subversion : Code: [Select]{ This file was automatically created by Lazarus. Do not edit!   This source is only used to compile and install the package.  } unit TAChartBgra; interface uses   TADrawerBGRA, LazarusPackageIntf; implementation procedure Register; begin end; initialization   RegisterPackage('TAChartBgra', @Register); end. ---------------------------------------------------------------------- Ask · 2013-02-04 15:32 Quotethe front will not be lightened at allI meant that the top side should be darkened, and right side -- darkened even further, so that the front, while retaining original color, will be lightest. QuoteSimply because it is not in the last subversionOops, I mixed up revisions -- sorry for that. Should be fixed as a side-effect of r40178 ---------------------------------------------------------------------- circular · 2013-02-04 15:53 Quote from: Ask on February 04, 2013, 04:32:48 pmQuotethe front will not be lightened at allI meant that the top side should be darkened, and right side -- darkened even further, so that the front, while retaining original color, will be lightest.I see. Well this is not cool enough for me. I advice you to implement the phong model. If you have any question, about it, feel free to ask.  QuoteQuoteSimply because it is not in the last subversionOops, I mixed up revisions -- sorry for that. Should be fixed as a side-effect of r40178Alright. ---------------------------------------------------------------------- circular · 2013-02-07 09:26 Here is a tutorial on how to improve TAChart rendering with BGRABitmap : http://wiki.freepascal.org/BGRABitmap_tutorial_TAChart