问题描述
左图是我的起始情况:红色是区域,黑色是XLD矩形。
正确的是我想达到的目标。我需要在区域接触矩形的任何地方,该区域被X像素拉伸。我的方法是绘制一个宽度为“ X”的矩形区域,然后将其合并为“ union2()”,但是我遇到了困难找出矩形的Y坐标。更好的是,我可以找到交点,但是我不知道如何找出它是交点的“开始”还是“结束”,因此是矩形的顶部还是底部。认为第一个总是起点,然后交替出现,但实际上,相交会在同一像素处返回两个值。
解决方法
这里有一个演示代码
dev_close_window ()
dev_open_window (0,512,'black',WindowHandle)
* Creation of a Region
gen_circle (Circle1,150,200,100.5)
gen_circle (Circle2,250,50.5)
gen_circle (Circle3,350,100.5)
union2 (Circle1,Circle2,RegionUnion1)
union2 (Circle3,RegionUnion1,Region)
* Creation of a xld
gen_rectangle2_contour_xld (Rectangle_xld,210,100.5,205.5)
* Convert xld to region
gen_region_contour_xld (Rectangle_xld,Rectangle_region,'margin')
* intersection
intersection (Region,RegionIntersection)
* stretch RegionIntersection
Stretch := 30
area_center (RegionIntersection,AreaRegionIntersection,RowRegionIntersection,ColumnRegionIntersection)
hom_mat2d_identity (HomMat2DIdentity)
hom_mat2d_scale (HomMat2DIdentity,1,-Stretch,ColumnRegionIntersection,HomMat2DScale)
affine_trans_region (RegionIntersection,RegionIntersectionStretched,HomMat2DScale,'nearest_neighbor')
union2 (Region,FinalRegion)
输入
输出