Page 1 of 1

The benefits of using vector graphics

Posted: Sunday 25th April 2021 8:22am
by Doctor Watson
This isn’t about posting a new problem, but why and how to use a solved one.
The problem was ‘Vector graphics support’ as you may find in the Component section.
Thanks to the solution provided by Bruce we now can easily ‘stretch’ a graphic to the size we want. And I say ‘graphic’ because ‘picture’ and ‘image’ mean different things in Gambas.
So, why using vector graphics. Simply because they are the thing to use when you want the quality of the background or content of any control that accepts graphics to stay the same, whatever size you apply to it.
In the following example I’ll be using ‘Union-Jack.svg’. You can download the original here:
https://www.freepik.com/free-vector/ill ... 807791.htm.
After unpacking there will be a file 18166.eps. Edit it with a programme like Inkscape and save the result as Union-Jack.svg.
No, I‘m not a subject of her Majesty, but the Union Jack has something in abundance that makes ‘stretching’ (‘resizing’, ‘scaling’, …) other types of graphics hell: oblique lines.
You will see the difference when replacing ‘Union-Jack.svg’ with any other format of Union Jack (.bmp, .jpg, …).
Take a new Form and put on it PictureBox1 and Button1.
Make Button1 small - Width 60 , Height 30
Enter these few lines of code in it’s class.
' Gambas class file
Private MyGraphic As Picture

Public Sub Form_Open()

  MyGraphic = Picture.Load(Application.path & "/Union-Jack.svg")
  
  PictureBox1.Picture = MyGraphic.Image.Stretch(PictureBox1.W, PictureBox1.H).Picture
  Button1.Picture = MyGraphic.Image.Stretch(Button1.W, Button1.H).Picture
  Me.width = Screen.W
  Me.height = Screen.H
  Me.Picture = MyGraphic.Image.Stretch(Me.W, Me.H).Picture
  
End
Have a nice weekend

Re: The benefits of using vector graphics

Posted: Sunday 25th April 2021 8:58am
by cogier
Which file are you renaming? There is no .svg file there?

Re: The benefits of using vector graphics

Posted: Sunday 25th April 2021 11:18am
by Doctor Watson
Well, I mean the one you download at https://www.freepik.com/free-vector/ill ... 807791.htm. After unpacking and opening 18166.eps you can edit and save it as Union-Jack.svg. Meanwhile I have modified this post. I hope it will be clearer now.
It would be a lot easier if I could just attach my Union-Jack.svg to the post, but as I found out before, this forum doesn’t seem to allow that. Why that is, I have no clue.

Re: The benefits of using vector graphics

Posted: Sunday 25th April 2021 12:28pm
by BruceSteers
Doctor Watson wrote: Sunday 25th April 2021 11:18am Well, I mean the one you download at https://www.freepik.com/free-vector/ill ... 807791.htm. After unpacking and opening 18166.eps you can edit and save it as Union-Jack.svg. Meanwhile I have modified this post. I hope it will be clearer now.
It would be a lot easier if I could just attach my Union-Jack.svg to the post, but as I found out before, this forum doesn’t seem to allow that. Why that is, I have no clue.
Just archive it , attachments can be zip tar etc :)

Re: The benefits of using vector graphics

Posted: Sunday 25th April 2021 2:44pm
by cogier
It would be a lot easier if I could just attach my Union-Jack.svg to the post, but as I found out before, this forum doesn’t seem to allow that. Why that is, I have no clue.
As Bruce said just compress the file then you can upload it. I converted it to .svg online, so it got well compressed.
Union-Jack.svg.tar.gz
(1.3 KiB) Downloaded 227 times
You may also be interested in the PictureBox Mode commands. Have a look here.

Re: The benefits of using vector graphics

Posted: Monday 26th April 2021 4:46am
by Doctor Watson
Hi Bruce and Cogier.
Thanks for the assistance.
Wouldn’t it be better to delete this post and I would post a new one where visitors will just read what this is realy about?
Cogier : PictureBox mode commands may indeed come in handy
Cheers

Re: The benefits of using vector graphics

Posted: Monday 26th April 2021 8:05am
by BruceSteers
Doctor Watson wrote: Monday 26th April 2021 4:46am Hi Bruce and Cogier.
Thanks for the assistance.
Wouldn’t it be better to delete this post and I would post a new one where visitors will just read what this is realy about?
Cogier : PictureBox mode commands may indeed come in handy
Cheers
but then people might not see how to upload svg files.
;)

Re: The benefits of using vector graphics

Posted: Monday 26th April 2021 11:39am
by Doctor Watson
Hi Bruce

It would indeed be usefull to let users know how to upload certain file types.
Just put it in a post fore the Beginners (like self :?: )
Meanwhile I’m working on a small project to make the svg issue more clear for everyone.

Re: The benefits of using vector graphics

Posted: Friday 30th April 2021 7:35am
by Doctor Watson
Hi Cogier
I’ve just finished a new version of this this topic, including a nice ( 8-) ) project to demonstrate the .svg issue. I suppose that as a site admin you can delete this topic, so I can post it’s replacement. It could be confuzing to visitors if both versions stay online.