From 99d311bf1f4d612dd41ce9a3cc00b92365a74c24 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Thu, 18 Jun 2020 18:30:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=98=E9=87=8F=E5=90=8D?= =?UTF-8?q?=E4=BB=A5=E6=9B=B4=E5=A5=BD=E9=98=85=E8=AF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DistanceFieldGenerater.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/DistanceFieldGenerater.cpp b/DistanceFieldGenerater.cpp index aa3496f..aaa1403 100644 --- a/DistanceFieldGenerater.cpp +++ b/DistanceFieldGenerater.cpp @@ -7,15 +7,15 @@ namespace df { struct Point { - uint32 col,row; + uint32 x_offset,y_offset; public: - const uint DistSq()const{return col*col+row*row;} + const uint DistSq()const{return x_offset*x_offset+y_offset*y_offset;} };//struct Point; static Point inside_point{0,0}; - static Point empty_point{9999,9999}; + static Point outside_point{9999,9999}; class Grid { @@ -46,7 +46,7 @@ namespace df { if(col<0||col>=width ||row<0||row>=height) - return empty_point; + return outside_point; return data[col+row*width]; } @@ -65,8 +65,8 @@ namespace df { Point other=Get(col+offset_col,row+offset_row); - other.col+=offset_col; - other.row+=offset_row; + other.x_offset+=offset_col; + other.y_offset+=offset_row; if(other.DistSq() grid1=new df::Grid(img.width(),img.height()); AutoDelete grid2=new df::Grid(img.width(),img.height()); - df::empty_point.col=img.width(); - df::empty_point.row=img.height(); + df::outside_point.x_offset=img.width(); + df::outside_point.y_offset=img.height(); for(int row=0;rowPut(col,row,df::inside_point); - grid2->Put(col,row,df::empty_point); + grid2->Put(col,row,df::outside_point); } else { grid2->Put(col,row,df::inside_point); - grid1->Put(col,row,df::empty_point); + grid1->Put(col,row,df::outside_point); } ++op;