The benefits of using vector graphics

Post your Gambas programming questions here.
Post Reply
Doctor Watson
Posts: 84
Joined: Wednesday 22nd August 2018 7:55am

The benefits of using vector graphics

Post 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
Last edited by Doctor Watson on Sunday 25th April 2021 11:25am, edited 1 time in total.
Old african saying:
You eat an elephant one small bite at a time.
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: The benefits of using vector graphics

Post by cogier »

Which file are you renaming? There is no .svg file there?
Doctor Watson
Posts: 84
Joined: Wednesday 22nd August 2018 7:55am

Re: The benefits of using vector graphics

Post 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.
Old african saying:
You eat an elephant one small bite at a time.
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: The benefits of using vector graphics

Post 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 :)
If at first you don't succeed , try doing something differently.
BruceS
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: The benefits of using vector graphics

Post 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 226 times
You may also be interested in the PictureBox Mode commands. Have a look here.
Doctor Watson
Posts: 84
Joined: Wednesday 22nd August 2018 7:55am

Re: The benefits of using vector graphics

Post 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
Old african saying:
You eat an elephant one small bite at a time.
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: The benefits of using vector graphics

Post 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.
;)
If at first you don't succeed , try doing something differently.
BruceS
Doctor Watson
Posts: 84
Joined: Wednesday 22nd August 2018 7:55am

Re: The benefits of using vector graphics

Post 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.
Old african saying:
You eat an elephant one small bite at a time.
Doctor Watson
Posts: 84
Joined: Wednesday 22nd August 2018 7:55am

Re: The benefits of using vector graphics

Post 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.
Old african saying:
You eat an elephant one small bite at a time.
Post Reply