ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Drawera fill and fill2 primitives - cannot fill with transparent color ?
Posted by Daniel on Nov-10-2016 20:27
Attachments:
Hi Peter,

I am trying to produce "ring-shapes" with drawarea-area objects from chartdirector and using the circleshape and fill (or fill2) primitives. It looks like I cannot fill the inner circle with the CD transparent color. I resorted to use a near-to-transparent color.

Am missing something here? Or am I correct. And there is there really no way to fill with transparent or erase an existing colored zone on a transparent-aware drawarea. Not really an issue since Transparent and, say, 0xFEFFFFFF are of course visually equivalent:)

CD API is definitely great by the way:)

Cheers - Daniel

oDraw = oManager.Drawarea()
oDraw.setSize(iWidth+4,iHeight+4)
oDraw.setTransparentColor(0x00AAAAAA)
oDraw.setBgColor(oManager.Transparent)
oDraw.circleShape(2+iWidth/2,2+iHeight/2,iWidth/2,iHeight/2,0,0x00FF0000)
oDraw.circleShape(2+iWidth/2,2+iHeight/2,iWidth/2 - iCircleWidth,iHeight/2 - iCircleWidth,0,0x00FFFFFE)
oDraw.Fill(1+iWidth/2,1+iHeight/2,0xFEFFFFFF)
test.png

  Re: Drawera fill and fill2 primitives - cannot fill with transparent color ?
Posted by Daniel on Nov-10-2016 20:28
Sorry there was an error in the pseudo-code (extra useless line):

oDraw = oManager.Drawarea()
oDraw.setSize(iWidth+4,iHeight+4)
oDraw.setBgColor(oManager.Transparent)
oDraw.circleShape(2+iWidth/2,2+iHeight/2,iWidth/2,iHeight/2,0,0x00FF0000)
oDraw.circleShape(2+iWidth/2,2+iHeight/2,iWidth/2 - iCircleWidth,iHeight/2 - iCircleWidth,0,0x00FFFFFE)
oDraw.Fill(1+iWidth/2,1+iHeight/2,0xFEFFFFFF)

  Re: Drawera fill and fill2 primitives - cannot fill with transparent color ?
Posted by Peter Kwan on Nov-11-2016 01:51
Hi Daniel,

Unluckily, it is true that the fill and fill2 API cannot fill using the completely transparent color. It would have no effect.

Regards
Peter Kwan

  Re: Drawera fill and fill2 primitives - cannot fill with transparent color ?
Posted by Daniel on Nov-14-2016 00:15
Hi Peter,


Unluckily, it is true that the fill and fill2 API cannot fill using the completely transparent color. It would have no effect.


I discovered that the solution I proposed, filling the object with "pseudo-transparent color" works only when outputting the content to a raster format, say png.

When spitting out the content to vectorial pdf ( did not test SVG), the "erasing" effect does not work at last.Vectorial output is a difficult beast. So in this very case we add to make sure the object was used as a raster resource (in this case a png).

The good news, here: CD API is indeed flexible. We just inserted the two lines below before using the "DrawArea" Object before outputting to a vectorial format:

oDraw.Outpng("tempresource.png")
oDraw.LoadPng("tempresource.png")

Of course it partly defeats the vectorial content with some raster content. But here we have, not a a solution, but a workable fix:)

Daniel

  Re: Drawera fill and fill2 primitives - cannot fill with transparent color ?
Posted by Peter Kwan on Nov-14-2016 00:55
Hi Daniel,

The fill and fill2 are for "flood-fill". This is a concept used in bitmap graphics and has no equivalent in vector graphics. To really draw a donut in vector graphics, one method is to use a small Donut chart. You can use BaseChart.makeChart3 to obtain the DrawArea from a donut chart.

Regards
Peter Kwan

  Re: Drawera fill and fill2 primitives - cannot fill with transparent color ?
Posted by Daniel on Nov-15-2016 03:40
The fill and fill2 are for "flood-fill". This is a concept used in bitmap graphics and has no equivalent in vector graphics. To really draw a donut in vector graphics, one method is to use a small Donut chart. You can use BaseChart.makeChart3 to obtain the DrawArea from a donut chart.

Hi Peter,

May I say first thank you for your patient explanations all along this thread:)

We are using these drawarea-based primitives as a way to enhance an existing "base document" with initDynamicLayer, decorating this document with run-time-imposed "drawarea(s)" and saving it for display then rolling the whole stuff back with removeDynamicLayer.

This has allowed us to add a pretty high-level of interaction (this is not a local app). Since we handle drag-and-drop operations, we of course care about performance. Up to now we found that this application reacts pretty well up to a couple of 100 of drawarea-based additions. The D'n-d operations remain fluid.

I was under the impression that embedding full "CD-chart-objects" would possibly be a lot heavier than decorating the base-chart with drawarea primitives. In your opinion, do you reckon the cost of building small and simple basecharts would be reasonable in terms of cpu-consumption as compared to drawarea-based primitives?

Daniel

  Re: Drawera fill and fill2 primitives - cannot fill with transparent color ?
Posted by Peter Kwan on Nov-15-2016 18:37
Hi Daniel,

The overhead of the PieChart is not big. For your case, I think a PieChart may even be faster than the DrawArea because it avoids creating the PNG file and then reloading it.

Regards
Peter Kwan

  Re: Drawera fill and fill2 primitives - cannot fill with transparent color ?
Posted by Daniel on Nov-18-2016 17:19
Hi Peter,

Thanks for the feedback and detailed info all along the thread. The more I go the more I discover CD API is flexible. Chartdirector building blocks can really added, layers upon layers, and drawearas upon drawareas to each other in a highly manageable and predictable way.

Since speed is always there thanks to ASE great C-family-code base, it's a joy to work with:)

Daniel