c# - Breaking cumulative transformations -
i using drawingcontext
object draw series of rectangles. requirement this:
- first rectangle want place at(100, 100)
- second rectangle want place at(200, 200)
- third rectangle want place at(0, 0)
i using transformation matrix achieve follows:
to position first rectangle @ (100, 100) use following:
drawingcontext.pushtransform(new translatetransform(100, 100)); drawingcontext.drawrectangle(brushes.blue, null, new rect(0, 0, 100, 100));
to position second rectangle @ (200, 200) use following: drawingcontext.pushtransform(new translatetransform(100, 100)); drawingcontext.drawrectangle(brushes.blue, null, new rect(0, 0, 100, 100));
to position third rectangle @ (0, 0) can use (-200, -200). curious there way can replace cumulative chain , overwrite entire matrix new position like: drawingcontext.pushtransform(new translatetransform(0, 0));
this possible on winforms graphics setting transform property follows:
g.transform = new matrix();
is there way in can break cumulative chain in wpf
you this:
drawingcontext.pushtransform(new translatetransform(100, 100)); drawingcontext.drawrectangle(brushes.blue, null, new rect(0, 0, 100, 100)); drawingcontext.pop();
the pop() method resets transform state before call pushtransform()
.
Comments
Post a Comment