XZen
XZen

Reputation: 445

Android canvas, save/restore paint settings

I'm working with android canvas and sometimes the logic is like:

  1. we have some settings in Paint object and draw some graphic using canvas
  2. we should somehow save current Paint settings and draw another graphics
  3. we should restore Paint settings to initial values and continue drawing

the problem is that I didn't find any convinient way to save/restore Paint settings. I'm not sure that doing it manually is a good way. Could you please advise?

Upvotes: 4

Views: 762

Answers (1)

Tatarize
Tatarize

Reputation: 10806

You should make as many paint objects as you need to paint draw on the canvas. You don't want to go changing them on the fly, they are only being used in draw which means you need them already having the value they need to paint. You restore and save on the canvas because that's just popping matrix off the stack, but, paints should be pre-established.

Upvotes: 2

Related Questions