上面的代码对比了Paint的三种样式效果 Paint.Style.FILL   用颜色填充图形 Paint.Style.FILL_AND_STROKE     即绘制边框 同时也填充内部 Paint.Style.STROKE  个人理解为只绘制边框 Shader类的派生类可以创建允许使用多种固体颜色填充绘图对象的Paint。

需求:有一个类似地板的 画布 , 用户可以选择自己喜欢的颜色或者花纹 用手涂到画布上去看效果 , 可以撤销, 涂抹的过程中是随着用户的手指宽度 移动最终将整个画布填充完全

Flood Fill

Flood fill colors an entire area in an enclosed figure through interconnected pixels using a single color. It is an easy way to fill color in the graphics. One just takes the shape and starts flood fill. The algorithm works in a manner so as to give all the pixels inside the boundary the same color leaving the boundary and the pixels outside. Flood Fill is also sometimes referred to as Seed Fill as you plant a seed and more and more seeds are planted by the algorithm. Each seed takes the responsibility of giving the same color to the pixel at which it is positioned. There are many variations of Flood Fill algorithm that are used depending upon requirements.

Boundary Fill

Boundary Fill is another algorithm used for the purpose of coloring figures in computer graphics. It is so similar to Flood Fill that many are confused as to whether it is another variation of it. Here area gets colored with pixels of a chosen color as boundary this giving the technique its name. One can see the difference in the conditions that are there for planting the seeds. Boundary fill fills the chosen area with a color until the given colored boundary is found. This algorithm is also recursive in nature as the function returns when the pixel to be colored is the boundary color or is already the fill color.

In brief:

• Flood Fill and Boundary Fill are algorithms used for coloring a given figure with a chosen color

• Flood Fill is one in which all connected pixels of a selected color get replaced by a fill color.

• Boundary Fill is very similar with the difference being the program stopping when a given color boundary is found.

Read more: http://www.differencebetween.com/difference-between-boundary-fill-and-vs-flood-fill/#ixzz2oWYNWWMA

Thjere are two ways to do this:
1. Four-connected fill where we propagate : left right up down

Procedure Four_Fill (x, y, fill_col, bound_col: integer);
var
     curr_color: integer;
begin
     curr_color := inquire_color(x, y)
     if (curr_color <> bound color) and (curr_color <> fill_col) then
     begin
         set_pixel(x, y, fill_col)
         Four_Fill (x+1, y, fill_col, bound_col);
         Four_Fill (x-1, y, fill_col, bound_col);
         Four_Fill (x, y+1, fill_col, bound_col);
         Four_Fill( x, y-1, fill_col, bound_col);
end;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

生活在西班牙

自己动手丰衣足食

BlueAsteroid

Just another WordPress.com site

Jing's Blog

Just another WordPress.com site

Start from here......

我的心情魔方

天才遠私廚

希望能做一個分享各種資訊的好地方

语义噪声

西瓜大丸子汤的博客

笑对人生,傲立寰宇

Just another WordPress.com site

Where On Earth Is Waldo?

A Project By Melanie Coles

the Serious Computer Vision Blog

A blog about computer vision and serious stuff

Cauthy's Blog

paper review...

Cornell Computer Vision Seminar Blog

Blog for CS 7670 - Special Topics in Computer Vision

datarazzi

Life through nerd-colored glasses

Luciana Haill

Brainwaves Augmenting Consciousness

槑烎

1,2,∞

Dr Paul Tennent

and the university of nottingham

turn off the lights, please

A bunch of random, thinned and stateless thoughts around the Web

%d bloggers like this: