Code Monkey home page Code Monkey logo

iosmosaiimagepen's Introduction

iOS 马赛克画笔一种实现思路

先看下效果:

GIF

功能:

  • 能实现马赛克画笔功能,并提供多种马赛克图案层叠测试
  • 实现了重做,撤销功能
  • 实现了对原图做处理功能,并不是失真保存图案
  • 优化了处理时 CPU 占用太高问题

关于项目

  • 本项目只是作为一个 DEMO 演示,并不是一个控件封装。简单说下思路:使用 CAShapeLayermask 实现实时马赛克预览, 使用 core graphic 实现每一笔画完之后生成马赛克图。下面提供了思路具体实现文章,有兴趣同学可以自己封装一个控件使用。
  • 另外,因为只是作演示做法,项目中的 撤销重做 功能,使用的是内存缓存。最好的做法其实就是每画完一笔,生成的原图马赛克,做沙盒储存,减少内存消耗!!

思路可参考下面文章👇 :

马赛克画笔思路传送门

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.