2017-08-02 6:40 GMT-03:00 Fabien Bodard <gambas...@gmail.com>: > Ok Fernando ... your code is no so bad :-) > > I know. Some explanations bellow.
> > First never call the resizing of the caneva in the drawing event as it > call itself the drawing event ... (normally if I rememember well it > have been disabled) > So you must resize in another place. > > then I don't really understand why you are resizing the drawingarea > and not the windows... but you must have your idea. > This was only a test (as other lines). I am trying to figure out how the code works. I got the original code from the software farm (analogic clock) and then I' ve been pruning it what I need. But this assignement, besides doing nothing, is not the reason for the loop. I know so because I can delete it and the behaviour is the same. > > You need to call DrawingArea.Refresh Function to force the refresh so > the _Draw event calling. Or resising the form, or anything else that > force the need to refresh the area. > You mean, for the resizing to take place? > > > For example if you want to make a clock you do : > > 'Where timer delay is 1000 for example > Public sub MyTimer_Timer() > > $dCurTime = GetCurTime() > dwgClock.Refresh > > End > > > Yep! That's the functionality the original code had. Nevertheless, the only thing I want (and I am trying to learn how to do) is to draw some lines at certain angles inside a square or a rectangle. (the angles you see in the for loop is only for testing the concept. Real angles will be a different). The "Print "executing" & Now' is also only for testing purpose. I suspected the code was in loop but could figure out why. So I placed this printing thing there to confirm. And, yes, it prints continuously changing the time. > > ==> the code revised > > ' Gambas class file > > Private Const W As Integer = 2048 > Private Const H As Integer = 2048 > > Public Sub _new() > > dwgArea.width = 800 ' does nothing > dwgArea.Height = 1000 ' does nothing Print dwgArea.width; dwgArea.Height > dwgArea.Refresh > End > > > > Public Sub DwgArea_Draw() > > Dim angle As Float > Dim eScale As Float > Dim i As Integer > > Print "Executing" & Now > > Paint.Translate(dwgArea.W / 2, dwgArea.H / 2) > Paint.Brush = Paint.Color(Color.SetAlpha(Color.Red, 128)) > Paint.LineWidth = 1 > > For i = -15 To 195 Step 15 > > angle = Rad(CFloat(i)) > Paint.MoveTo(0, 0) > Paint.LineTo(Cos(angle) * W / 2, Sin(angle) * H / 2) > Print Cos(angle) * w / 2 > Paint.Stroke > 'Paint.Fill > Next > > End > > > Best Regards, > > Fabien Bodard > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > -- Fernando Cabral Blogue: http://fernandocabral.org Twitter: http://twitter.com/fjcabral e-mail: fernandojosecab...@gmail.com Facebook: f...@fcabral.com.br Telegram: +55 (37) 99988-8868 Wickr ID: fernandocabral WhatsApp: +55 (37) 99988-8868 Skype: fernandojosecabral Telefone fixo: +55 (37) 3521-2183 Telefone celular: +55 (37) 99988-8868 Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos, nenhum político ou cientista poderá se gabar de nada. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user