We already used some canvas transformations on our custom view before, but let's revisit the Canvas operations we can use. First of all, let's see how we can concatenate these transformations. Once we've used a transformation, any other transformation we use will be concatenated or applied on top of our previous operations. To avoid this behavior, we've to call the save() and restore() methods we also used before. To see how transformations build on top of each other, let's create a simple example.
First, let's create a paint object on our constructor:
public PrimitiveDrawer(Context context, AttributeSet attributeSet) { super(context, attributeSet); paint = new Paint(); paint.setStyle(Paint.Style.STROKE); ...