omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Display vectors as spritenode?

    Pythonista
    vector spritenode scene
    4
    8
    4622
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Drizzel
      Drizzel last edited by

      Hey all,
      Does anyone know how I can display a vector as a normal spritenode?
      Thanks in advance :)

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        what would "displaying a vector" look like to you? Printing the numbers? Drawing an arrow?

        cvp Drizzel 2 Replies Last reply Reply Quote 0
        • cvp
          cvp @JonB last edited by

          @JonB Perhaps vector graphics instead of bitmap?

          1 Reply Last reply Reply Quote 0
          • ellie_ff1493
            ellie_ff1493 last edited by

            look at ShapeNode its a subclass of spritenode and it draws vectors

            1 Reply Last reply Reply Quote 0
            • Drizzel
              Drizzel @JonB last edited by

              @JonB preferably I would like to display vector graphics that I designed myself

              1 Reply Last reply Reply Quote 0
              • JonB
                JonB last edited by

                Reslly, you need to add a few more words so people can help you...

                ... are you trying to display SVGs?
                PDF vector graphics?
                Fonts?
                Draw your own using ui.Path (line_to, move_to,stroke/fill and the like)?

                Drizzel 1 Reply Last reply Reply Quote 0
                • Drizzel
                  Drizzel @JonB last edited by

                  @JonB sorry if i wasn't precise enough, I thought it would be enough information. I'm trying to display .svg graphics, as they take up less storage than high resolution images

                  1 Reply Last reply Reply Quote 0
                  • JonB
                    JonB last edited by

                    got it. ios really has no native support for svg.
                    PNG, JPG or PDF are what you will want to use.

                    For single color, one option is to use a font creation tool (there are many) that let you convert your svg to a svg font, then use svg2ttf to convert to a ttf font, which can be installed systemwide, or can be loaded temporarily in app. Then, you can create images from the glyphs. Not really worth it in my opinion...

                    Another option which looks promising but i have not explored yet:
                    https://github.com/Kozea/CairoSVG can parse svg to produce a tree object, which then uses
                    https://github.com/Kozea/cairocffi/ to convert to png. cairocffi might work without modification, or a small few, since it relies on ffi in a similar way that objc_util does, and i think the ios cairo is similar if not identical to the mac version. If not, you might also be able to use that tree to write your own output to ui.Path commands in an ui.ImageContext, and get_image provides the ui.Image.

                    A final option -- convert svg to vector PDF. I believe ui.Image.from_file can read pdf. I don't know hw they compare size wise.. some programs might add a lot of garbage to a pdf, ImageMagick probably would do it well.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Powered by NodeBB Forums | Contributors