| 1 |
import sys |
|---|
| 2 |
from math import * |
|---|
| 3 |
from alg import * |
|---|
| 4 |
|
|---|
| 5 |
def CreateSplitImage(imagelist, start_at_y=True): |
|---|
| 6 |
result=imagelist[0].Copy(False) |
|---|
| 7 |
result.CenterSpatialOrigin() |
|---|
| 8 |
extent=imagelist[0].GetExtent() |
|---|
| 9 |
if start_at_y: |
|---|
| 10 |
startpoint=Vec2(0.0,-extent.GetSize()[0]) |
|---|
| 11 |
else: |
|---|
| 12 |
startpoint=Vec2(extent.GetSize()[0],0.0) |
|---|
| 13 |
angle=2*pi/len(imagelist) |
|---|
| 14 |
count=0 |
|---|
| 15 |
for image in imagelist: |
|---|
| 16 |
image.CenterSpatialOrigin() |
|---|
| 17 |
start_angle=angle*count |
|---|
| 18 |
end_angle=angle*(count+1) |
|---|
| 19 |
pol=Polygon2() |
|---|
| 20 |
pol.AddNode(Vec2(0,0)) |
|---|
| 21 |
pol.AddNode(Rotate(startpoint,start_angle)) |
|---|
| 22 |
if(start_angle<pi/4.0 and end_angle>pi/4.0): |
|---|
| 23 |
pol.AddNode(Rotate(startpoint,pi/4.0)) |
|---|
| 24 |
if(start_angle<3.0*pi/4.0 and end_angle>3.0*pi/4.0): |
|---|
| 25 |
pol.AddNode(Rotate(startpoint,3.0*pi/4.0)) |
|---|
| 26 |
if(start_angle<5.0*pi/4.0 and end_angle>5.0*pi/4.0): |
|---|
| 27 |
pol.AddNode(Rotate(startpoint,5.0*pi/4.0)) |
|---|
| 28 |
if(start_angle<7.0*pi/4.0 and end_angle>7.0*pi/4.0): |
|---|
| 29 |
pol.AddNode(Rotate(startpoint,7.0*pi/4.0)) |
|---|
| 30 |
pol.AddNode(Rotate(startpoint,end_angle)) |
|---|
| 31 |
m=Mask(pol) |
|---|
| 32 |
result+=image.Apply(MaskImage(m)) |
|---|
| 33 |
count+=1 |
|---|
| 34 |
return result |
|---|
| 35 |
|
|---|
| 36 |
imagelist=LoadImageList(sys.argv[1:-1]) |
|---|
| 37 |
result=CreateSplitImage(imagelist) |
|---|
| 38 |
SaveImage(result,sys.argv[-1]) |
|---|
| 39 |
|
|---|