{"id":7251,"date":"2024-03-28T13:01:01","date_gmt":"2024-03-28T05:01:01","guid":{"rendered":""},"modified":"2024-03-28T13:01:01","modified_gmt":"2024-03-28T05:01:01","slug":"Rect\u7c7b","status":"publish","type":"post","link":"https:\/\/mushiming.com\/7251.html","title":{"rendered":"Rect\u7c7b"},"content":{"rendered":"
\u3000rect\u5bf9\u8c61\u7528\u6765\u5b58\u50a8\u4e00\u4e2a\u77e9\u5f62\u6846\u7684\u5de6\u4e0a\u89d2\u5750\u6807\u3001\u5bbd\u5ea6\u548c\u9ad8\u5ea6\u3002<\/span> <\/p>\n <\/span><\/p>\n \u63cf\u8ff0\u77e9\u5f62\u7684\u5bbd\u5ea6\u3001\u9ad8\u5ea6\u548c\u539f\u70b9\u3002<\/span><\/p>\n<\/p><\/div>\n<\/div>\n \n \u547d\u540d\u7a7a\u95f4\uff1a<\/span> \u3000\u3000class Rect<\/span> <\/p>\n \u3000\u3000<\/span> <\/p>\n \u3000\u3000rect\u7ed3\u6784\u5b9a\u4e49\u4e86\u4e00\u4e2a\u77e9\u5f62\u6846\u5de6\u4e0a\u89d2\u4ee5\u53ca\u53f3\u4e0b\u89d2\u7684\u5750\u6807<\/span> <\/p>\n \u3000\u3000typedef struct _RECT { \u3000\u3000LONG left;<\/span> <\/p>\n \u3000\u3000LONG top;<\/span> <\/p>\n \u3000\u3000LONG right;<\/span> <\/p>\n \u3000\u3000LONG bottom;<\/span> <\/p>\n \u3000\u3000} RECT, *PRECT;<\/span> <\/p>\n \u3000\u3000left \uff1a \u6307\u5b9a\u77e9\u5f62\u6846\u5de6\u4e0a\u89d2\u7684x\u5750\u6807<\/span> <\/p>\n \u3000\u3000top\uff1a \u6307\u5b9a\u77e9\u5f62\u6846\u5de6\u4e0a\u89d2\u7684y\u5750\u6807<\/span> <\/p>\n \u3000\u3000right\uff1a \u6307\u5b9a\u77e9\u5f62\u6846\u53f3\u4e0b\u89d2\u7684x\u5750\u6807<\/span> <\/p>\n \u3000\u3000bottom\uff1a\u6307\u5b9a\u77e9\u5f62\u6846\u53f3\u4e0b\u89d2\u7684y\u5750\u6807<\/span> <\/p>\n \u3000\u3000\u5907\u6ce8\uff1a<\/span> <\/p>\n \u3000\u3000\u5f53rect\u4f20\u9012\u7ed9fillrect\u51fd\u6570\u65f6\uff0c\u8be5\u77e9\u5f62\u6846\u5c06\u88ab\u586b\u5145\u6ee1\uff0c\u4f46\u4e0d\u5305\u62ec\u53f3\u680f\u548c\u5e95\u884c\u7684\u50cf\u7d20\u3002<\/span> <\/p>\n \u3000\u3000\u8be5\u7ed3\u6784\u4e0erectl\u7ed3\u6784\u662f\u540c\u4e00\u7ed3\u6784\u3002<\/span> <\/p>\n \u3000\u3000----RECT\u65e2\u662f\u4e2a\u7279\u522b\u7684<\/span> \u3000\u3000topleft:\u5de6\u4e0a\u89d2\u5750\u6807(Tpiont\u578b\u53d8\u91cf)\uff1b<\/span> <\/p>\n \u3000\u3000bottomright:\u53f3\u4e0b\u89d2\u5750\u6807(Tpiont\u578b\u53d8\u91cf)\uff1b<\/span> <\/p>\n \u3000\u3000topleft.x\u6216left:\u5de6\u4e0a\u89d2\u6a2a\u5750\u6807\uff1b<\/span> <\/p>\n \u3000\u3000topleft.y\u6216top:\u5de6\u4e0a\u89d2\u7eb5\u5750\u6807\uff1b<\/span> <\/p>\n \u3000\u3000bottomright.x\u6216right:\u53f3\u4e0b\u89d2\u6a2a\u5750\u6807\uff1b<\/span> <\/p>\n \u3000\u3000bottomright.y\u6216bottom:\u53f3\u4e0b\u89d2\u7eb5\u5750\u6807\u3002<\/span> <\/p>\n \u3000\u3000----\u4f8b\u5982\uff0c\u4e0b\u9762\u4e09\u79cd\u65b9\u6cd5\u5b9a\u4e49\u4e00\u4e2a\u76f8\u540c\u7684RECT\u53d8\u91cf:<\/span> <\/p>\n \u3000\u3000Rect(10,10,110,210);<\/span> <\/p>\n \u3000\u3000topleft:=Piont(10,10);<\/span> <\/p>\n \u3000\u3000bottomright:=Point(110,210);<\/span> <\/p>\n \u3000\u3000left:=10;top:=10;right:=110;Bottom:=210;<\/span> <\/p>\n \u3000\u3000----\u4e0b\u9762\u7684\u4ee3\u7801\u5728Form1<\/span> \u3000\u3000var<\/span> <\/p>\n \u3000\u3000NewRect: TRect;<\/span> <\/p>\n \u3000\u3000begin<\/span> <\/p>\n \u3000\u3000NewRect := Rect(20, 30, 50, 90);<\/span> <\/p>\n \u3000\u3000Form1.Canvas.Brush.Color := clRed;<\/span> <\/p>\n \u3000\u3000Form1.Canvas.FillRect(NewRect);<\/span> <\/p>\n \u3000\u3000end;<\/span> <\/p>\n \u3000\u3000----\u4ece\u4e0a\u9762\u80fd\u770b\u51fa,RECT\u53ea\u662f\u4e2a\u901a\u7528\u53d8\u91cf,\u4ed6\u5e76\u4e0d\u5c5e\u4e8e\u6240\u6709\u63a7\u4ef6\u672c\u8eab,\u5b9a\u4e49\u4e4b\u540e\u53ef\u7531\u6240\u6709\u5177\u6709CANVAS\u5c5e\u6027\u7684\u63a7\u4ef6\u4f7f\u7528,\u4ee5\u6307\u660e\u67d0\u63a7\u4ef6\u8868\u9762\u7684\u4e00\u4e2a\u77e9\u5f62\u533a\u57df,\u5e76\u4e14\u7a0b\u5f0f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u53ef\u968f\u610f\u4fee\u6539\u5c3a\u5bf8\u548c\u4f4d\u7f6e\u3002<\/span> <\/p>\n \u3000\u3000Rect(x1,y1,x2,y2):\u5b9a\u4e49Rect\u533a\u57df\u8303\u56f4\u3002<\/span> <\/p>\n \u3000\u3000FillRect(rect:Trect):\u7528\u586b\u5145\u8272\u586b\u5145Rect\u533a\u57df\u3002<\/span> <\/p>\n \u3000\u3000FloodFill:\u7528\u586b\u5145\u8272\u586b\u5145Rect\u4e4b\u5916\u533a\u57df\u3002<\/span> <\/p>\n \u3000\u3000textrect(Rect:TRect;X,Y:Integer;constText:string):\u5728Rect\u5bf9\u8c61\u4e2d\u663e\u793a\u6587\u672c,\u5176\u4e2d\u7684X\u3001Y\u4e3a\u663e\u793a\u6587\u672c\u7684\u5750\u6807\u503c,\u662f\u76f8\u5bf9\u4e8e\u753b\u5e03\u7684\u5750\u6807\u800c\u4e0d\u662f\u76f8\u5bf9\u4e8eRECT\u7684\u5750\u6807\uff1bconst\u4e3a\u663e\u793a\u7684\u5b57\u7b26\u4e2a\u6570\uff1bstring\u4e3a\u5f85\u663e\u793a\u7684\u5b57\u7b26\u4e32\uff0c\u53ea\u6709\u5728RECT\u5185\u7684\u5b57\u7b26\u624d\u80fd\u663e\u793a\u51fa\u6765,\u8d85\u51fa\u90e8\u5206\u4e0d\u663e\u793a\u3002<\/span> <\/p>\n \u3000\u3000stretchdraw(constRect:TRect;Graphic:TGraphic):\u628a\u56fe\u50cf\u6587\u4ef6\u586b\u5145\u5230Rect\u4e4b\u4e2d,\u5e76\u4e14\u56fe\u50cf\u6309RECT\u7684\u5c3a\u5bf8\u81ea\u52a8\u4f38\u7f29,\u5176\u4e2d\u7684Graphic\u53ef\u4e3aBMP\u6216ICO\u7b49\u56fe\u50cf\u8d44\u6e90\u3002<\/span> <\/p>\n \u3000\u3000font.size:\u5b9a\u4e49\u753b\u5e03\u4e0a\u663e\u793a\u6587\u5b57\u7684\u5c3a\u5bf8\u3002<\/span> <\/p>\n \u3000\u3000font.color:\u5b9a\u4e49\u753b\u5e03\u4e0a\u663e\u793a\u6587\u5b57\u7684\u989c\u8272\u3002<\/span> <\/p>\n \u3000\u3000textwidth:\u8fd4\u56de\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u3002<\/span> <\/p>\n \u3000\u3000textheight:\u8fd4\u56de\u5b57\u7b26\u4e32\u7684\u9ad8\u5ea6\u3002<\/span> <\/p>\n \u3000\u3000Brush.Color:\u5b9a\u4e49\u753b\u5e03\u7684\u586b\u5145\u989c\u8272\u3002<\/span> <\/p>\n \u3000\u3000Copyrect(Dest:TRect;Canvas:Tcanvas;Source:TRect):\u628a\u56fe\u50cf\u4ece\u4e00\u4e2a\u77e9\u5f62\u4e2d\u62f7\u5230\u53e6\u4e00\u4e2a\u77e9\u5f62\u4e4b\u4e2d,\u5e76\u4e14\u6309\u76ee\u6807\u77e9\u5f62\u5c3a\u5bf8\u81ea\u52a8\u4f38\u7f29,\u5176\u4e2d\uff0cDest\u4e3a\u76ee\u6807\u753b\u5e03\u77e9\u5f62,Canvas\u4e3a\u6e90\u753b\u5e03,Source\u4e3a\u6e90\u77e9\u5f62\u3002<\/span> <\/p>\n \u3000\u3000----\u7531\u4e8e\u4e0a\u8ff0\u547d\u4ee4\u5747\u662f\u57fa\u4e8e\u753b\u5e03\u672c\u8eab\u4f7f\u7528\u7684,\u6240\u4ee5\u5177\u4f53\u4f7f\u7528\u65f6\u5fc5\u987b\u52a0\u4e0a\u63a7\u4ef6\u53ca\u753b\u9762\u5c5e\u6027,\u4f8b\u5982\u4e0b\u9762\u7684\u4ee3\u7801:<\/span> <\/p>\n \u3000\u3000var<\/span> <\/p>\n \u3000\u3000TheRect: TRect;<\/span> <\/p>\n \u3000\u3000begin<\/span> <\/p>\n \u3000\u3000TheRect.Top := 10;<\/span> <\/p>\n \u3000\u3000TheRect.Left := 10;<\/span> <\/p>\n \u3000\u3000TheRect.Bottom := 100;<\/span> <\/p>\n \u3000\u3000TheRect.Right := 100;<\/span> <\/p>\n \u3000\u3000Form1.Canvas.TextRect(TheRect,0,0,\u2019\u2019Hello,<\/span> <\/p>\n \u3000\u3000world!\u2019\u2019);<\/span> <\/p>\n \u3000\u3000end;<\/span>
\n <\/span>
\nSystem.Windows
\n
\n\u7a0b\u5e8f\u96c6\uff1a<\/span>
\n <\/span>
\nSystem.Windows<\/span>
\n\uff08\u5728 System.Windows.dll \u4e2d\uff09<\/span>
\n <\/p>\n \u53e5\u6cd5<\/span><\/h4>\n
\u6210\u5458\u8868<\/span><\/h4>\n
\n\n
\n \u6784\u9020\u51fd\u6570<\/td>\n \u63cf\u8ff0<\/td>\n<\/tr>\n \n Rect::Rect()<\/td>\n \u521b\u5efa\u4e00\u4e2a\u77e9\u5f62\u5bf9\u8c61\uff0c\u77e9\u5f62\u5de6\u4e0a\u89d2\u7684\u6a2a\u5750\u6807\u3001\u7eb5\u5750\u6807\u4ee5\u53ca\u77e9\u5f62\u7684\u5bbd\u5ea6\u3001\u9ad8\u5ea6\u5747\u4e3a\u96f6\u3002\u8fd9\u662f\u9ed8\u8ba4\u7684\u6784\u9020\u51fd\u6570<\/td>\n<\/tr>\n \n Rect::Rect(point&,size&)<\/td>\n \u521b\u5efa\u4e00\u4e2a\u77e9\u5f62\u5bf9\u8c61\uff0c\u7528Point\u5bf9\u8c61\u6765\u521d\u59cb\u5316\u77e9\u5f62\u5de6\u4e0a\u89d2\u7684\u6a2a\u5750\u6807\u548c\u7eb5\u5750\u6807\uff0c\u7528size\u5bf9\u8c61\u6765\u521d\u59cb\u5316\u77e9\u5f62\u7684\u9ad8\u5ea6\u548c\u5bbd\u5ea6<\/td>\n<\/tr>\n \n Rect::Rect(INT,INT,INT,INT)<\/td>\n \u521b\u5efa\u4e00\u4e2a\u77e9\u5f62\u5bf9\u8c61\uff0c\u901a\u8fc7\u4f7f\u7528\u56db\u4e2a\u6574\u6570\u6765\u521d\u59cb\u5316\u77e9\u5f62\u5de6\u4e0a\u89d2\u7684\u6a2a\u5750\u6807\u3001\u7eb5\u5750\u6807\u4ee5\u53ca\u77e9\u5f62\u7684\u9ad8\u5ea6\u3001\u5bbd\u5ea6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \n\n
\n \u7c7b\u6210\u5458\u51fd\u6570<\/td>\n \u63cf\u8ff0<\/td>\n<\/tr>\n \n Rect::Clone<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u521b\u5efa\u4e00\u4e2a\u4e0e\u5f53\u524d\u77e9\u5f62\u5bf9\u8c61\u76f8\u540c\u7684\u77e9\u5f62\u5bf9\u8c61<\/td>\n<\/tr>\n \n Rect::contains(point&)<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u51b3\u5b9a\u8be5\u70b9\u662f\u5426\u5728\u6b64\u77e9\u5f62\u6846\u5185<\/td>\n<\/tr>\n \n Rect::contains(rect&)<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u51b3\u5b9a\u53e6\u4e00\u4e2a\u77e9\u5f62\u6846\u662f\u5426\u5728\u8fd9\u4e2a\u77e9\u5f62\u6846\u5185<\/td>\n<\/tr>\n \n Rect::contains(INT,INT)<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u51b3\u5b9a\u70b9(x,y)\u662f\u5426\u5728\u6b64\u77e9\u5f62\u6846\u5185<\/td>\n<\/tr>\n \n Rect::equals<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u5224\u5b9a\u91cf\u77e9\u5f62\u5bf9\u8c61\u662f\u5426\u76f8\u7b49<\/td>\n<\/tr>\n \n Rect::getbottom<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u83b7\u53d6\u77e9\u5f62\u6846\u5e95\u90e8\u8fb9\u7f18\u7684y\u503c<\/td>\n<\/tr>\n \n Rect::getbounds<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u4e3a\u8fd9\u4e2a\u77e9\u5f62\u6846\u521b\u5efa\u4e00\u4e2a\u526f\u672c<\/td>\n<\/tr>\n \n Rect::getleft<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u83b7\u53d6\u77e9\u5f62\u6846\u5de6\u8fb9\u7f18\u7684x\u503c<\/td>\n<\/tr>\n \n Rect::getlocation<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u83b7\u53d6\u77e9\u5f62\u6846\u5de6\u4e0a\u89d2\u7684\u5750\u6807<\/td>\n<\/tr>\n \n Rect::getright<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u83b7\u53d6\u77e9\u5f62\u6846\u53f3\u8fb9\u7f18\u7684x\u503c<\/td>\n<\/tr>\n \n Rect::getsize<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u83b7\u53d6\u77e9\u5f62\u6846\u7684\u5bbd\u5ea6\u548c\u9ad8\u5ea6<\/td>\n<\/tr>\n \n Rect::gettop<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u83b7\u53d6\u77e9\u5f62\u6846\u5de6\u8fb9\u7f18\u7684y\u503c<\/td>\n<\/tr>\n \n Rect::inflate(INT,INT)<\/td>\n \u8be5\u51fd\u6570\u901a\u8fc7dx\u5728\u5de6\u53f3\u8fb9\u6846\u4e0a\u6269\u5927\u8be5\u77e9\u5f62\u6846\uff0c\u901a\u8fc7dy\u5728\u4e0a\u4e0b\u8fb9\u6846\u4e0a\u6269\u5927\u8be5\u77e9\u5f62\u6846<\/td>\n<\/tr>\n \n Rect::inflate(point&)<\/td>\n \u8be5\u51fd\u6570\u901a\u8fc7point.x\u7684\u503c\u5728\u5de6\u53f3\u8fb9\u6846\u4e0a\u6765\u6269\u5927\u8be5\u77e9\u5f62\u6846\uff0c\u901a\u8fc7point.y\u7684\u503c\u5728\u4e0a\u4e0b\u8fb9\u6846\u4e0a\u6765\u6269\u5927\u8be5\u77e9\u5f62\u6846<\/td>\n<\/tr>\n \n Rect::intsect(rects&;rects&;rects&)<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u786e\u5b9a\u4e24\u4e2a\u77e9\u5f62\u6846\u7684\u4ea4\u96c6\uff0c\u5e76\u5c06\u8fd9\u4e00\u7ed3\u679c\u50a8\u5b58\u5728\u4e00\u4e2arect\u5bf9\u8c61\u4e2d<\/td>\n<\/tr>\n \n Rect::intsect(rects&)<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u5c06\u6b64\u77e9\u5f62\u6846\u4e0e\u53e6\u4e00\u77e9\u5f62\u6846\u7684\u4ea4\u96c6\u6765\u66ff\u6362\u8fd9\u4e00\u77e9\u5f62\u6846<\/td>\n<\/tr>\n \n Rect::intersectwith<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u5224\u65ad\u8be5\u77e9\u5f62\u6846\u662f\u5426\u4e0e\u53e6\u4e00\u4e2a\u77e9\u5f62\u6846\u76f8\u4ea4<\/td>\n<\/tr>\n \n Rect::isemptyarea<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u8be5\u77e9\u5f62\u6846\u662f\u5426\u4e3a\u7a7a<\/td>\n<\/tr>\n \n Rect::offset(INT,INT)<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u79fb\u52a8\u6b64\u77e9\u5f62\u6846\uff0c\u901a\u8fc7\u6c34\u5e73\u7684\u79fb\u52a8dx\u8ddd\u79bb\uff0c\u4ee5\u53ca\u5782\u76f4\u79fb\u52a8dy\u8ddd\u79bb<\/td>\n<\/tr>\n \n Rect::offset(point&)<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u6c34\u5e73\u5730\u79fb\u52a8\u8be5\u77e9\u5f62\u6846point.x\u8ddd\u79bb\uff0c\u4ee5\u53ca\u5782\u76f4\u5730\u79fb\u52a8\u8be5\u77e9\u5f62\u6846point.y\u8ddd\u79bb<\/td>\n<\/tr>\n \n Rect::union<\/td>\n \u8be5\u51fd\u6570\u7528\u6765\u51b3\u5b9a\u4e24\u4e2a\u77e9\u5f62\u7684\u5408\u5e76\uff0c\u5e76\u5c06\u7ed3\u679c\u4fdd\u5b58\u5728\u4e00\u4e2arect\u5bf9\u8c61\u4e2d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u7f16\u8f91\u672c\u6bb5<\/span>RECT<\/span><\/h3>\n
\n <\/span> <\/p>\n \u6210\u5458<\/span><\/h4>\n
\u7f16\u8f91\u672c\u6bb5<\/span>RECT\u7684\u7279\u70b9\u4e0e\u64cd\u4f5c\u547d\u4ee4<\/span><\/h3>\n
RECT\u7684\u7279\u70b9<\/span><\/h4>\n
\n\u6570\u636e\u7ed3\u6784
\n\uff0c\u53c8\u662f\u4e2a\u51fd\u6570,\u4ed6\u7684\u4f5c\u7528\u5c31\u662f\u5b9a\u4e49\u4e00\u4e2a\u77e9\u5f62\u533a\u57df\u5bf9\u8c61,\u800c\u4f5c\u4e3a\u51fd\u6570\u4f7f\u7528\u65f6\u4ed6\u80fd\u7528\u4e24\u4e2a\u5c5e\u6027(Tpiont\u578b)\u6307\u660e\u533a\u57df\u8303\u56f4,\u540c\u65f6\u4e5f\u53ef\u5206\u89e3\u6210\u56db\u4e2a\u5355\u4e00\u7684\u53d8\u91cf\u7c7b\u578b(Integer\u578b),\u5373:<\/span> <\/p>\n
\n\u7a97\u4f53
\n\u4e0a\u5b9a\u4e49\u4e00\u4e2aRECT\u77e9\u5f62\u5e76\u7528\u7ea2\u8272\u586b\u5145:<\/span> <\/p>\n RECT\u64cd\u4f5c\u547d\u4ee4<\/span><\/h4>\n
\n <\/p>\n