https://linen.dev logo
Join Discord
Powered by
# ceramic
  • a

    ambitious-knife-25690

    01/21/2023, 2:46 PM
    what's the distinction between the two?
  • a

    ambitious-knife-25690

    01/21/2023, 3:07 PM
    does ceramic come with a way to measure the width/dimensions of text?
  • a

    ambitious-knife-25690

    01/21/2023, 3:08 PM
    lineheight/width on
    Text
    seems to remain static regardless of the pointSize selected
  • a

    ambitious-knife-25690

    01/21/2023, 3:14 PM
    ohh... weird ceramic/compilation isn't picking up changes on library classes
  • a

    ambitious-knife-25690

    01/21/2023, 3:17 PM
    oh it seems like
    Text.width/height
    does change 🤔
  • a

    ambitious-knife-25690

    01/21/2023, 3:18 PM
    compile cache throwing me off i guess 😄
  • f

    faint-toothbrush-51643

    01/21/2023, 3:48 PM
    Copy code
    hx
        public static function resizeTo(tex:Text, maxWidth:Float, maxHeight:Float) {
            tex.pointSize = maxHeight;
            tex.computeContent();
            if (tex.width > maxWidth) {
                tex.pointSize = maxHeight * maxWidth / tex.width;
            }
        }
  • f

    faint-toothbrush-51643

    01/21/2023, 3:48 PM
    it only updates the width after doing
    computeContent
  • f

    faint-toothbrush-51643

    01/21/2023, 3:49 PM
    which is done automatically during the update loop if you change anything, or can be called manually
  • b

    billowy-waiter-28954

    01/21/2023, 4:50 PM
    You don’t need to call computeContent() when you read text.width or height, it does it automatically if content is dirty
  • b

    billowy-waiter-28954

    01/21/2023, 4:51 PM
    Yes, only when project files change, or of you add ceramic_no_skip define (should add it in the defines docs)
  • b

    billowy-waiter-28954

    01/21/2023, 4:52 PM
    Yes, it means « font size, in points »
  • f

    faint-toothbrush-51643

    01/21/2023, 4:55 PM
    i'm calling it manually here because i need to get the width right after i set the size
  • f

    faint-toothbrush-51643

    01/21/2023, 4:56 PM
    the point of using a dirty flag is to make sure that if you change multiple different things in the same update loop, it doesn't pointlessly recompute every time
  • f

    faint-toothbrush-51643

    01/21/2023, 4:56 PM
    but here i specifically need it to recompute now so that i can get the actual width and determine if it needs to be shrunk down to fit within the desired area
  • a

    ambitious-knife-25690

    01/21/2023, 5:01 PM
    thanks! I did browse there but couldn't see the option 😄
  • b

    billowy-waiter-28954

    01/21/2023, 6:53 PM
    @ambitious-knife-25690 https://ceramic-engine.com/guides/defines/#ceramic-no-skip Here you go
  • a

    ambitious-knife-25690

    01/22/2023, 12:09 AM
    is there an event i can hook into that triggers when
    scenes.main
    changes?
  • b

    billowy-waiter-28954

    01/22/2023, 8:58 AM
    @ambitious-knife-25690 there is no event for that so you’ll have to track this down yourself (which should be ok as changing main scene is only happening because of your own code)
  • a

    ambitious-knife-25690

    01/22/2023, 10:50 AM
    ahh not if you're trying to track this from a library, but for now, that doesn't seem to be my issue so I'll continue without that for now
  • b

    billowy-waiter-28954

    01/22/2023, 12:22 PM
    I will consider making ˋmain` field observable, which will provide « onMainChange() » event
  • a

    ambitious-knife-25690

    01/22/2023, 6:19 PM
    thanks!
  • a

    ambitious-knife-25690

    01/22/2023, 6:20 PM
    @billowy-waiter-28954
    Copy code
    hx
     var mesh = new Mesh();
     mesh.pos(0, 0);
     mesh.vertices = [
      0,   0,
      200,   0,
      200, 200,
      0, 200
     ];
                    
    mesh.color = Color.WHITE;
    add(mesh);
  • a

    ambitious-knife-25690

    01/22/2023, 6:20 PM
    I would expect this to render a white box, but, I get nothing
  • a

    ambitious-knife-25690

    01/22/2023, 6:20 PM
    Am i doing something wrong? 🤔
  • a

    ambitious-knife-25690

    01/22/2023, 6:25 PM
    aaahhh i forgot indices! 😄
  • b

    billowy-waiter-28954

    01/22/2023, 6:44 PM
    Yes, indices 🙂
  • a

    ambitious-knife-25690

    01/22/2023, 10:41 PM
    @billowy-waiter-28954 Is there a way to load an image from bytes?
  • b

    billowy-waiter-28954

    01/22/2023, 10:44 PM
    Depends what are representing the bytes?
  • a

    ambitious-knife-25690

    01/22/2023, 10:45 PM
    standard
    haxe.io.Bytes
1...424344...124Latest