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.


    Size of layer image

    Pythonista
    2
    3
    2205
    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.
    • jugisto135
      jugisto135 last edited by

      Is there a way to set the size of a layer's image in the scene module? I have something like this.

      self.layer.image = render_text('foo')[0]
      

      This will stretch the given text out of proportions, depending on the size of the layer. But I have fixed size layers that should have centered texts. How can I achieve this?

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

        One possible solution:<br>
        Create your fixed size layer and add a sublayer to it that is rightsized to your image...

        (imageName, imageSize) = render_text('foo')
        innerLayer = Layer(Rect(0, 0, imageSize.w, imageSize.h))
        #innerLayer = Layer(Rect(0, 0, *imageSize)  # would also work
        innerLayer.image = imageName
        self.layer.add_layer(innerLayer)
        innerLayer.center(self.layer.center())
        
        1 Reply Last reply Reply Quote 0
        • jugisto135
          jugisto135 last edited by

          Thanks, ccc.

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