[Gambas-user] Floodfill / pie chart

Jussi Lahtinen jussi.lahtinen at ...626...
Sun Mar 29 21:43:44 CEST 2009


Thanks Fabien!
It was very useful!
Now I got my code to work, and it's even simpler than the original vb6 version;

Sub PieChart()
Dim Angle As Float
Dim prevAngle As Float
Dim ii As Long

With Draw

.Begin(Me.PicPieChart)
.ForeColor = Color.Black
.LineWidth = 3
.Circle(105, 105, 105)
.LineWidth = 1
.FillStyle = Fill.Solid

For ii = 0 To 7

Select Case ii
Case 0
.FillColor = Color.Red
Case 1
.FillColor = Color.Yellow
Case 2
.FillColor = Color.Magenta
Case 3
.FillColor = Color.Cyan
Case 4
.FillColor = Color.Green
Case 5
.FillColor = Color.Blue
Case 6
.FillColor = Color.White
Case 7
.FillColor = Color.Black
End Select

 If ii <> 7 Then
 Angle = Rad(3.6 * Osa[ii]) + prevAngle
 Else
 Angle = 0
 Endif

.Circle(105, 105, 105, prevAngle, Angle)
prevAngle = Angle

Next

.End

End With

End Sub


Jussi



On Sun, Mar 29, 2009 at 13:28, Fabien Bodard <gambas.fr at ...626...> wrote:
> i think you will better see at my source code in gb.chart. for that
> download the gambas source and look in
> ~/gambas/comp/src/gb.chart/_CStylePie.class.
> you need to use ellipse or circle
>
> 2009/3/28 Jussi Lahtinen <jussi.lahtinen at ...626...>:
>> Hi!
>>
>> I noticed Start and End options to make sector (also in circle), but
>> how to fill them with color?
>>
>> Fabien, here it is, but I think it is not very useful.
>> It is made only for my special case. It has fixed sizes, and it is
>> limited to 8 sectors.
>>
>> Notice that Part() array have to sum up 100% to make this code to work.
>> Vb6 code:
>>
>> Sub PieChart()
>> Dim Angle As Single
>> Dim prevAngle As Single
>> Dim ii As Long
>>
>> With PieChartPic
>>
>> .Cls
>> PieChartPic.Circle (104, 104), 104, vbBlack' Bug in vb6, can't use
>> just .Line(... etc.
>> PieChartPic.Line (104, 104)-(104, 104 + 105), vbBlack
>>
>> For ii = 0 To 7
>> Angle = (Part(ii) * 0.062831853) + prevAngle
>>
>> PieChartPic.Line (104, 104)-(104 + ((Sin(Angle)) * 105), 104 +
>> ((Cos(Angle)) * 105)), vbBlack
>>
>> SelectObject .hdc, mBrush(ii)' Just for the colors.
>> Call ExtFloodFill(.hdc, (104 + Sin((Angle + prevAngle) / 2) * 100),
>> (104 + Cos((Angle + prevAngle) / 2) * 100), 13160660, 1)
>>
>> prevAngle = Angle
>> Next ii
>>
>> .Refresh
>>
>> End With
>>
>> End Sub
>>
>>
>> Jussi
>>
>>
>>
>>
>> On Fri, Mar 27, 2009 at 13:22, Fabien Bodard <gambas.fr at ...626...> wrote:
>>> hi jussi, can you send me the vb code ?
>>>
>>> i'm working on gb.chart component... it may interest me just to
>>> complete my component
>>>
>>> (this component work fine only on svn version)
>>>
>>>
>>> thanks
>>> Le 27 mars 2009 11:31, Benoît Minisini <gambas at ...1...> a écrit :
>>>>> Hi!
>>>>>
>>>>> I need pie chart in my application, and I have old vb6 code that does
>>>>> what I need, but it is based on floodfill.
>>>>> Do Gambas have any equivalent function? Or alternatively, method to
>>>>> draw filled sectors?
>>>>> I'm using Gambas3.
>>>>> Thanks!
>>>>>
>>>>>
>>>>> Jussi
>>>>>
>>>>
>>>> I think that Draw.Ellipse() will draw what you need by using its last two
>>>> optional arguments.
>>>>
>>>> Regards,
>>>>
>>>> --
>>>> Benoît
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> _______________________________________________
>>>> Gambas-user mailing list
>>>> Gambas-user at lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>>>
>>>
>>> ------------------------------------------------------------------------------
>>> _______________________________________________
>>> Gambas-user mailing list
>>> Gambas-user at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>




More information about the User mailing list