Re-using Paint objects?


Last Updated:

  1. safibaba

    safibaba Member This Topic's Starter

    Joined:
    May 3, 2010
    Messages:
    15
    Likes Received:
    0
    Will it really slow things down if I use one text paint to draw 3 different lines of text in a repeating draw routine in different colors like this...

    PHP:
    1. textPaint.setARGB(255,255,255,255);
    2. c.drawText("HELLO",0,0,textPaint);
    3. textPaint.setARGB(255,255,0,0);
    4. c.drawText("This is some more text",0,20,textPaint);
    5. textPaint.setARGB(255,0,255,0);
    6. c.drawText("More text",0,40,textPaint);
    Or should I create 3 different Paint objects in memory and use them separately?
     

    Advertisement
  2. fabiocberg

    fabiocberg Active Member

    Joined:
    Apr 7, 2010
    Messages:
    27
    Likes Received:
    1
    Hi safibaba,
    You are using the native font from Android and I really recommend it.
    So, you don't need to create 3 different Paint objects, because to change color, size or font face, is really fast.
    You can use only one Paint object.
     
  3. safibaba

    safibaba Member This Topic's Starter

    Joined:
    May 3, 2010
    Messages:
    15
    Likes Received:
    0
    Thanks fabio - will be much easier to use just one paint object. :)
     

Share This Page

Loading...