I need help to start drawing with Gambas

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

I need help to start drawing with Gambas

Fernando Cabral
Perhaps some of you have a little time available to point me the direction
for this littledelineate project of mine.

I like to play with sundials. Basically, it consists in calculating some
lines and angles and then drawing them on the ground, marble, concrete,
etc. Things are conceptually very easy. I have line lengths and angles. I
can use either or both to delineate the sundial face.

I would guess I will have to resort to cairo or chart, but I don't know
where to start from. I'd appreciate a few hints.

Thanks.

- fernando

--
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: [hidden email]
Facebook: [hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: I need help to start drawing with Gambas

Tobias Boege-2
On Sun, 30 Jul 2017, Fernando Cabral wrote:

> Perhaps some of you have a little time available to point me the direction
> for this littledelineate project of mine.
>
> I like to play with sundials. Basically, it consists in calculating some
> lines and angles and then drawing them on the ground, marble, concrete,
> etc. Things are conceptually very easy. I have line lengths and angles. I
> can use either or both to delineate the sundial face.
>
> I would guess I will have to resort to cairo or chart, but I don't know
> where to start from. I'd appreciate a few hints.
>

It doesn't have to be gb.cairo. You can use the Paint class of gb.qt4 if
you use gb.qt4 anyway. The interfaces of both drawing classes are very
similar either way. Use gb.cairo if you want to export your drawings to
PDF or Postscript and Paint for everything else (it allows you to draw
into windows of your Gambas process, to a printer, to svg or bitmap images).

Something that may be confusing when you first encounter it is the path-
based drawing that is used in Cairo and Paint. Most methods of the Paint
class don't paint anything but create and manipulate paths (it memorises
movements on the drawing surface). To create a drawing you have to call
Stroke() or Fill() on the path, to realise the memorised movement on the
paper, so to speak, e.g.

  Paint.Ellipse(0, 0, 10, 10)

will give you a circle of diameter 10 centered around the origin -- and by
that I mean a circle *path*. If you want a normal circle, you have to call
Stroke() afterwards. If you want a solid disc, call Fill() on the path.

To get you started, you can find the ancient AnalogWatch example on the
software farm, which draws an analog wall clock. If you're proficient
with trigonometry you can concentrate on the Paint bits of the source
code. There is also a chapter on Cairo in the German Gambas-Buch [1]
(with example projects) and many more in the Paint chapter [2].

And, as always, look into the source code of Gambas itself. Lots of
graphical controls written in Gambas (gb.form and gb.gui.base) draw
themselves with Paint. You can find examples of arbitrarily high
complexity (gb.form.terminal and the GridView from gb.gui.base come
to mind). There are also plenty of easier examples, like the Spinner
class in gb.form.

Regards,
Tobi

[1] https://gambas-buch.de/dw/doku.php?id=k25:k25.1:start
[2] https://gambas-buch.de/dw/doku.php?id=k23:k23.3:start

--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: I need help to start drawing with Gambas

Fernando Cabral
2017-07-30 17:51 GMT-03:00 Tobias Boege <[hidden email]>:

> On Sun, 30 Jul 2017, Fernando Cabral wrote:
> To get you started, you can find the ancient AnalogWatch example on the
> software farm, which draws an analog wall clock. If you're proficient
> with trigonometry you can concentrate on the Paint bits of the source
> code.
>

Yes, I think this analogwatch will do for simple sundials (regular,
horizontal sundials).
I will only have to tinker with the angles to adapt them to the latitude.

I'll leave more complex things for the future.
Thank you.

- fernando


>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
> ------------------------------------------------------------
> ------------------
> 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
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



--
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: [hidden email]
Facebook: [hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user