Quartz 2D Drawing, image transformation

Source: Internet
Author: User

iOS Quartz 2d drawing, drawing sometimes requires a graphical transformation.

Remember: Quartz 2D Transformation is the beginning of the CG, do not mix with the core animation, Core Animatin is the beginning of the CA.

iOS provides a set of API interfaces that can be used for image transformations, and general image transformations are divided into, pan, zoom, and rotate.

Translation

void CgcontextTranslateCTM (cgcontextref C, CGFloat tx, cgfloat ty);

Scaling

void Cgcontextscale CTM (cgcontextref C, CGFloat tx, cgfloat ty);

Rotating

void CgcontextRotateCTM (cgcontextref C, CGFloat tx, cgfloat ty);

This set of APIs has a keyword

1, Cgcontext

2, Translate/scale/rotate

3. CTM (current transformation matrix) transformation

So, the core of this API is matrix transformations.

To be more flexible with matrix transformations, iOS provides the actual matrix transformation functions,

Application transform

void Cgcontextconcatctm (Cgcontextref C, cgaffinetransform transform);

Get the transform of the context

Cgaffinetransform CGCONTEXTGETCTM (cgcontextref c);

The Matrix transformation API provided by iOS

Cgaffinetransform cgaffinetransfommaketranslation(cgfloat tx, cgfloat ty);

Cgaffinetransform cgaffinetransfommake scale (cgfloat TX, cgfloat ty);

Cgaffinetransform cgaffinetransfommakeRotation(cgfloat tx, cgfloat ty);

Cgaffinetransform Cgaffinetransformmake (CGFloat x, cgfloat y, cgfloat C, CGFloat D, CGFloat tx, cgfloat ty);

Cgaffinetransform cgaffinetransfomtranslation(Cgaffinttransform t, cgfloat tx, cgfloat ty);

Cgaffinetransform cgaffinetransfomScale (Cgaffinttransform t,cgfloat tx, cgfloat ty);

Cgaffinetransform cgaffinetransfomRotation(Cgaffinttransform t,cgfloat tx, cgfloat ty);

There is no difference between this set of APIs and the previous CGCONTEXTXXXCTM, and there is a lot of trouble, but there is no advantage in applying cgcontext here.

What is the advantage of this set of APIs???

Quartz 2D Drawing, image transformation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.