Code Monkey home page Code Monkey logo

zrfloodfilldemo's Introduction

ZRFloodFillDemo

  本Demo实现涂色App的涂色功能。

采用泛洪算法计算图片同颜色区域,并填充新颜色。

泛洪算法通常有3种实现,四邻域,八邻域和基于扫描线。本Demo是采用的基于扫描线的实现方式,相比其他两种来说,基于扫描线的实现绘制速度更快一些。

了解更多泛洪算法可以查看下列链接:

https://en.wikipedia.org/wiki/Flood_fill

https://lodev.org/cgtutor/floodfill.html

使用:

导入头文件UIImage+FloodFill.h

调用- (UIImage *)floodFillImageFromStartPoint: (CGPoint) startPoint newColor: (UIColor *)newColor tolerance: (CGFloat)tolerance useAntialias: (BOOL)antialias;

startPoint: 相对于图片的起点

newColor: 填充的颜色

tolerance: 判断相邻颜色相同的容差值

antialias: 是否抗锯齿化

LinkedListQueue

使用NSMutableData实现的性能更高的栈结构

效果图:

image

image

zrfloodfilldemo's People

Contributors

lzrun avatar

Watchers

James Cloos avatar  avatar

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.