Vector graphics support ?

Ask about the individual Gambas components here.
User avatar
PJBlack
Posts: 184
Joined: Tuesday 9th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: Vector graphics support ?

Post by PJBlack »

have had the same problem with picturebox ... picture inverse und form black on black ... problem was solved by creating a new form ...
Doctor Watson
Posts: 84
Joined: Wednesday 22nd August 2018 7:55am

Re: Vector graphics support ?

Post by Doctor Watson »

Hi PJBlack
I already tried that and even a whole new project.
Same - negative - result.

To all : I'll be away for a couple of days. :D
Old african saying:
You eat an elephant one small bite at a time.
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Vector graphics support ?

Post by BruceSteers »

I also have issues using Image but not using Picture

' Gambas class file
Private MyGraphic As Picture
 
Public Sub Form_Open()

  MyGraphic = Picture.Load(Application.path & "/GB_FLAG.svg") 'or take any other graphic

  PictureBox1.Picture = MyGraphic.Image.Stretch(PictureBox1.W, PictureBox1.H).Picture
  Button1.Picture = MyGraphic.Image.Stretch(Button1.W, Button1.H).Picture

End

If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Vector graphics support ?

Post by BruceSteers »

There's a big difference between an Image and a Picture that is hard to explain.

I see it like if I have a Picture and I look at it then i have an "Image" of that "Picture" in my head
But the "picture" is the real thing while the "image" is not

Or maybe I can get an "Image" of something in my head and make a "Picture" from it. but the "Image" is not real only the "Picture" is once drawn.

hmm , like i say , it's hard to explain.

Suffice to say , Use the "Picture" property/class for final image rendering and the "Image" property to manipulate (colour/stretch/etc)
If at first you don't succeed , try doing something differently.
BruceS
Doctor Watson
Posts: 84
Joined: Wednesday 22nd August 2018 7:55am

Re: Vector graphics support ?

Post by Doctor Watson »

Congratulations Bruce! That one needed some thinking over indeed.
There is unfortunately almost nothing to be found on how to use ‘stretch’ in the Gambas documentation, certainly no example code.
Now that the right way of using the ‘stretch’ property has been found, I’d like to explain why I wanted to be able to use vector graphics. I’ll put it in a post in the General section, so perhaps others may benefit.

P.S. I just came across what looks to me like the best Gambas manual till now. It’s in German, but the authors are working on an English translation. Certainly well worth it to pay a visit.
https://gambas-buch.de/dwen/doku.php?id=start. It has some examples on ‘stretch’.

Have a nice weekend.
Old african saying:
You eat an elephant one small bite at a time.
User avatar
Askjerry
Posts: 64
Joined: Saturday 18th August 2018 9:06pm
Location: Kyle, Texas, USA
Contact:

Re: Vector graphics support ?

Post by Askjerry »

I was playing with SVG in Gambas and the images look stunning. I can create nice gradients and such that always look nice.

Code: Select all

 Gambas class file
Public Sub Form_Open()
  Dim pic As Picture
  pic = Image.Load("./pg.svg").Stretch(PictureBox1.w, PictureBox1.h).Picture
    PictureBox1.Picture = pic
End
Public Sub PictureBox1_MouseDown()
  Me.Close()
End
In this example (sent to me) the file pg.svg is loaded and stretched to the size of the picturebox automatically. This works out very well for stationary SVG... but playing around in HTML a long time ago I discovered that if I named something like "pointer" in the drawing... I could then assign it an angular rotation or movement and do all sorts of things with it. I'm wondering now if once an image is loaded... can I somehow manipulate the object? If so... I can make some incredible gauges and displays.

Check these out... steal the code... see what you can do with it... but if you get something to work in Gambas... please share!

http://askjerry.info/SVG/

Jerry
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Vector graphics support ?

Post by cogier »

Try the code below, then resize the form. I think the PictureBox.Mode command is quite powerful and under used. I wrote the help for it here.
PictureBox1 As PictureBox

Public Sub Form_Open()

  With Me
    .Height = 400
    .Width = 500
    .Padding = 5
    .Arrangement = Arrange.Vertical
    .Center
  End With

  With PictureBox1 = New PictureBox(Me) As "PictureBox1"
    .Expand = True
    .Alignment = Align.Center
    .Mode = PictureBox.Contain
    .Picture = Picture["./pg.svg"]
  End With

End

Public Sub PictureBox1_MouseDown()

  Me.Close()

End
Regarding a 'gauge' have a look at the code here.

Tip: - When adding Gambas code on this site use the gb button for results similar to the above.

Image
Post Reply