Microsoft Small Basic

Program Listing: NRV926
' NaochanON's shapes editor version 5 // use Litdev extension // by NaochanON 2018/3/21
' IDNo:
' Usage ....
' 1) add default shapes ; click Ellipse, Rectangle, Triangle, Line Shapes(they are Polygon) in the heading.
' 2) modify it ; click mouse on a shape, Listbox appears. Select below items ( click).
' Width zoom -0.5 ,Width zoom -0.1 ,Width zoom +0.1, Width zoom +0.5, Height zoom -0.5, Height zoom -0.1, Height zoom +0.1, Height zoom +0.5
' Rotate Left -45, Rotate Left -2, Rotate Right +2, Rotate Right +45, Penwidth Narrower -1, Penwidth Wider +1, Z_Index most Top, Z_Index most Bottom
' SetOpacity -5,-2 +2,+5 Change BrushColor( Text color), Change PenColor, Copy it , Remove it, Hide Listbox , Add text ,
' Click "EditPolygon" ;you can edit points of the polygon// Click "ResetPolygon ; add the edited polygon
' Click "AddPolygon" ; Click points to add a polygon shape // Click "SetPolygon" ; a polygon shape will be added
' 3) Add an image and a text ( Flicker Image, Web image , Text ) // image and text can be copied.
' 4) Add an image which is in your PC
' 5) Load a SBfile (get shape[N] data and add its shapes. )
' 6) save to a SBfile ; click [Save To SBfile] button .
' 7) Clear All Shapes ; click [All_Clear] button.
' 8) Capture GraphicsWindow (working area) ; click [Capture]
' 9) Click [ReView]; Save shapes data to Temp.sb , clear graphics and then reload shapes.
' If you want to add Init.sb , it is available from IDNo : STD116
'
LDShapes.ShapeEvent=onshapeclick
LDControls.ListBoxItemChanged = OnListBoxItemChanged
Controls.ButtonClicked=Onbtnclick
GraphicsWindow.MouseDown=Onmousedown
GraphicsWindow.MouseMove=Onmousemove
GraphicsWindow.MouseUp=Onup
GUI()


Sub add_Points ' Prp["Points"] --> Points[i][1],Points[i][2]
minx=1000
miny=1000
points=""
_pt= LDText.Split(Prp["Points"]," ") ' _pt= 10,30 20,25 40,50
For j=1 To Array.GetItemCount(_pt)
points[j]= LDText.Split(_pt[j],",")
minx=math.Min(minx,points[j][1])
miny=math.Min(miny,points[j][2])
EndFor
For i=1 to Array.GetItemCount(points)
points[i][1]= Math.Round(points[i][1]-minx)
points[i][2]= Math.Round(points[i][2]-miny)
EndFor
EndSub

Sub addshape ' add base shapes .... Ellipse Rectangle Triangle Line and Text
points=""
If _nmb=1 Then ' Ellipse (Polygon)
DR=_dt["1R"]
NN=_dt["1N"]
For i=1 To NN
points[i][1]=math.Round(DR*(1+Math.Sin((i-1)/NN*math.pi*2))*10)/10
points[i][2]=math.Round(DR*(1+Math.cos((i-1)/NN*math.pi*2))*10)/10
EndFor
shp=LDShapes.AddPolygon(points)
ElseIf 1<_nmb and _nmb<5 Then ' Rectangle Triangle Line (Polygon )
Prp["Points"]= dt[_nmb]
add_Points()
shp=LDShapes.Addpolygon(points)
ElseIf _nmb=5 Then ' Text
GraphicsWindow.FontSize=20
shp=Shapes.AddText(" ")
EndIf
Shapes.Move(shp,180+(_nmb-1)*50+10*math.GetRandomNumber(5),100+_nmb*50+15*math.GetRandomNumber(5))
LDShapes.BrushColour(shp,"#BED3CA" )
LDShapes.PenColour(shp,"#1E50A2")
LDShapes.PenWidth(shp,_pwstart)
initial_anglezoom()
serialdata()
EndSub

Sub AllClear
_serial=Serial_nm
cp= Text.GetIndexOf(_Serial,",")
While cp>0
NN=NN+1
sname= Text.GetSubText(_serial,1,cp-1)
_serial=text.GetSubTextToEnd(_serial,cp+1)
Shapes.Remove(sname)
cp= Text.GetIndexOf(_Serial,",")
endwhile
angle=""
zoom=""
_msg=""
_path=""
_img=""
_sop=""
Serial_nm=""
shape=""
sname=""
points=""
EndSub

Sub get_Prp
Prp=LDShapes.GetProperties(sname) ' gets Ell&Rec=Width,Height, Tri=Points,
_type=text.GetSubText(Prp["Name"],1,3)
cx=Prp["ActualWidth"]/2
cy=Prp["ActualHeight"]/2
_pt=Prp["Points"]
_spt= LDText.Split(Prp["Points"]," ")
_pts=ldtext.Split(ldtext.Replace(_pt," ",","),",")
_XY="X="+(LDShapes.GetLeft(sname))+";Y="+(LDShapes.Gettop(sname))
edit="True"
_bc=Prp["Fill"]
_pc=Prp["Stroke"]
_pw=Prp["StrokeThickness"]
_sop=Prp["Opacity"]*100
GraphicsWindow.Title=LDShapes.LastEventShape+" : X= "+_XY["X"]+" , Y= "+_XY["Y"]+" , W= "+2*cx*zoom[sname]["w"]+" , H= "+2*cy*zoom[sname]["h"]+" ,"+_pts+" , angle= "+angle[sname]+" ,pw= "+_pw+" ,Zoom= "+zoom[sname]["h"]
EndSub

Sub GUI
CRLF= Text.GetCharacter(13)+Text.GetCharacter(10)
DQ=Text.GetCharacter(34)
Name="Pol=4;Tex=5;Ima=6;"
_backCLR="#FFFFFF"
GraphicsWindow.top=10
GraphicsWindow.Left=10
GraphicsWindow.Width=1100
GraphicsWindow.Height=650
GraphicsWindow.BrushColor="#98D98E"
GraphicsWindow.FillRectangle(0,0,1300,80)
GraphicsWindow.BrushColor="Navy"
_btn="1=Load SBfile,910,55;2=Save To SBfile,1000,55;3=Add WebImage/Text,480,55;4=Add PCImage,670,55;5=Text,1250,90;6=GetWebImg,1250,90;7=BackGrdColor,800,55;8=All_Clear,910,2;9=Capture,1000,2;10=ReView,1000,28;11=AddPolygon,280,25;"
For i=1 To Array.GetItemCount(_btn)
_arr=LDText.Split(_btn[i],",")
btn[i]= Controls.AddButton(_arr[1],_arr[2],_arr[3])
EndFor
tbox= Controls.AddTextBox(1200,90)
Controls.SetSize(tbox,280,25) '
smsg= Shapes.AddText("*Click a shape left side to add and move it where you want To set"+CRLF+"*Click an item in the list to change its width,height,angle,Z-index,.... etc"+CRLF+"*AddPolygon... Point number should be >=3. Last point should be near to first red point" )
Shapes.Move(smsg,370,10)
GraphicsWindow.FontSize=11
items = "0=Hide this ListBox;1=Width zoom -0.5;2=Width zoom -0.1;3=Width zoom +0.1;4=Width zoom +0.5;5=**** ;6=Height zoom -0.5;7=Height zoom -0.1;8=Height zoom +0.1;9=Height zoom +0.5;10=**** ;11=Rotate Left -45;"
items = items+ "12=Rotate Left -2;13=Rotate Right +2;14=Rotate Right +45;15=PW Narrower -1;16=PW Wider +1;17=Opacity -5;18=Opacity -2;19=Opacity +2;20=Opacity +5;21=Z_Index Top;22=Z_Index Bottom;23=Change BrushColor;"
items = items+ "24=Change PenColor;25=Copy it;26=**** ;27=Remove it;28=Edit_Polygon;29=Reset_Polygon;"
listBox = LDControls.AddListBox(items,150,550)
Shapes.Move(listBox,1500,80)
GraphicsWindow.FontSize=12
dt="1R=40;1N=24;2=0,0 85,0 85,50 0,50;3=0,65 65,65 35,0;4=0,0 0,35 0,70" ' Ellipse Rectangle Triangle Line
_dt=dt
GraphicsWindow.DrawResizedImage(ImageList.LoadImage(Program.Directory+"\Base_Shape.JPG"),5,5,265,70)
_pwstart=1
Serial_nm=""
_sall=LDShapes.GetAllShapes()
start= Array.GetItemCount(_sall) ' controls and shapes number added
_sz="1w=-0.5;1h=0;2w=-0.1;2h=0;3w=0.1;3h=0;4w=0.5;4h=0;6w=0;6h=-0.5;7w=0;7h=-0.1;8w=0;8h=0.1;9w=0;9h=0.5;11=-45;12=-2;13=2;14=45;15=-1;16=1;17=-5;18=-2;19=2;20=5;21=1;22=-1;" ' change size data
_op="17=-5;18=-2;19=2;20=5"
addppolygon="False"
EndSub

Sub initial_anglezoom
zoom[shp]["w"]=1 ' initial zoom width=1
zoom[shp]["h"]=1 ' initial zoom height=1
angle[shp]=0 ' initial angle=0
sop[shp]=100 ' set opacity
bc[shp]="#BED3CA" ' initial Brush color
pc[shp]="#1E50A2" ' initial Pen color
pw[shp]=1 ' initial Pen Width
fsz[shp]=20 ' initial Fontsize
EndSub

Sub Load_addshape
For i = 1 To Array.GetItemCount(shape)
If shape[i]["fn"] = "Tex" Then ' Text message shape
shp = Shapes.Addtext( shape[i]["msg"])
LDShapes.penColour(shp , shape[i]["bc"])
_msg[shp]=shape[i]["msg"]
ElseIf shape[i]["fn"] = "Img" Then ' Image shape
shp = Shapes.AddImage(Imagelist.LoadImage( shape[i]["Src"] ))
_path[shp]= Ldtext.Replace(shape[i]["Src"],"\","\\")
_img[shp]=Imagelist.LoadImage( shape[i]["Src"] )
elseIf shape[i]["fn"] = "Pol" Then ' Polygon shape
_pt= LDText.Split(shape[i]["pts"]," ")
points=""
For j=1 To Array.GetItemCount(_pt)
points[j]=LDText.Split(_pt[j],",")
EndFor
shp = Ldshapes.AddPolygon(points)
LDShapes.BrushColour(shp , shape[i]["bc"])
LDShapes.PenColour(shp , shape[i]["pc"])
LDShapes.Penwidth(shp , shape[i]["pw"])
EndIf
Shapes.Move(shp, shape[i]["x"], shape[i]["y"])
If Text.IsSubText("Tex:Img:",shape[i]["fn"]) Then
Shapes.Zoom(shp,shape[i]["zmw"],shape[i]["zmh"])
zoom[shp]["w"]=shape[i]["zmw"]
zoom[shp]["h"]=shape[i]["zmh"]
EndIf
Shapes.Rotate(shp, shape[i]["ang"]) ' rotation after zooming
Shapes.SetOpacity(shp,shape[i]["op"])
sop[shp]=shape[i]["op"]
angle[shp]=shape[i]["ang"]
serialdata()
EndFor
EndSub

Sub LoadSB
RD= Text.GetSubTextToEnd(RD,Text.GetIndexOf(RD,"shape[1]="))
RD= Text.GetSubText(RD,1,Text.GetIndexOf(RD,"EndSub")-1)
crp= Text.GetIndexOf(RD,CRLF)
NN=0
While crp>0
_this= Text.GetSubText(RD,1,crp-1)
_this= text.GetSubTextToEnd(_this,text.GetIndexOf(_this,"=")+1)
NN=NN+1
shape[NN]= ldText.Replace(_this,DQ,"") ' set shape parameter
RD= Text.GetSubTextToEnd(RD,crp+1)
crp= Text.GetIndexOf(RD,CRLF)
EndWhile
Load_addshape()
EndSub

Sub Onbtnclick
nm= Controls.GetButtonCaption(Controls.LastClickedButton)
If text.IsSubText(nm,"Save") Then ' save To SB shape[] array data
savetoSB()
path=LDDialogs.SaveFile("sb","C:\") ' or Program.Directory+"\Sample.sb"
' The following line could be harmful and has been automatically commented.
' File.WriteContents(path,conts)
ElseIf text.IsSubText(nm,"Load") Then ' Load SB file ( gets shape[] array )
' The following line could be harmful and has been automatically commented.
' RD=File.ReadContents(LDDialogs.OpenFile("sb","C:\"))
LoadSB()
ElseIf text.IsSubText(nm,"Clear") Then ' Clear all shapes
AllClear()
ElseIf text.IsSubText(nm,"Capture") Then ' capture graphics window // working area
img=LDGraphicsWindow.Capture("","False")
LDImage.Crop(img,0,80,1150,570)
path=LDDialogs.SaveFile("jpg","C:\") ' or Program.Directory+"\Sample.jpg"
LDImage.SaveAs(img,path)
ElseIf text.IsSubText(nm,"ReView") Then ' save tempfile then clear reload
Re_View()
ElseIf text.IsSubText(nm,"WebImage/Text") Then
Controls.Move(tbox,600,90) ' textbox
Controls.Move(btn[5],900,90) ' Text
Controls.Move(btn[6],490,90) ' GetWebImg
ElseIf text.IsSubText(nm,"PCImage") Then
ipath= Ldtext.Replace(LDDialogs.OpenFile("*.*","C:\"),"\","\\")
shp= shapes.AddImage(ImageList.LoadImage(ipath)) ' Image in your PC
_img[shp]=ImageList.LoadImage(ipath)
_path[shp]=ipath
shapeadd_btnhide()
ElseIf text.IsSubText(nm,"GetWebImg") Then
_txt=Controls.GetTextBoxText(tbox)
If Text.IsSubText(_txt,"http://") Then
ipath=_txt
shp= shapes.AddImage(imagelist.LoadImage(_txt))' Web Image
Else
ipath=Flickr.GetRandomPicture(_txt)
shp= shapes.AddImage(imagelist.LoadImage(ipath))' Flicker Image
EndIf
_img[shp]=ImageList.LoadImage(ipath)
_path[shp]=ipath
shapeadd_btnhide()
ElseIf text.IsSubText(nm,"Text") Then ' add Text shape
GraphicsWindow.BrushColor="Navy"
GraphicsWindow.FontSize=20
msg=Controls.GetTextBoxText(tbox)
shp= Shapes.AddText(msg)
_msg[shp]=msg
shapeadd_btnhide()
GraphicsWindow.BrushColor="#BED3CA"
ElseIf text.IsSubText(nm,"Back") Then ' change BackgroundColor
_backCLR= FCDialogs.AskForColor()
GraphicsWindow.BackgroundColor=_backCLR
Elseif text.IsSubText(nm,"AddPolygon") Then ' add a unique polygon
addppolygon="True"
points=""
cnt=0
ldr=1000
minx=1000
miny=1000
_cx=0
_cy=0
Controls.SetButtonCaption(btn[11],"SetPolygon")
Elseif addppolygon and text.IsSubText(nm,"SetPolygon") Then ' set the polygon
setresetpolygon()
shp= LDShapes.AddPolygon(points)
Shapes.Animate(shp,minx,miny,300)
LDShapes.BrushColour(shp,"#BED3CA")
LDShapes.PenWidth(shp,2)
addppolygon="False"
Controls.SetButtonCaption(btn[11],"AddPolygon")
serialdata()
EndIf
EndSub

Sub OnListBoxItemChanged
If sname<>"" Then
get_Prp()
_LNMB=LDControls.LastListBoxIndex
If (_LNMB = 0) Then
GraphicsWindow.Width=1100 ' narrowen GraphicsWindow.Width
Shapes.move(listBox,1500,80) ' Hide Listbox
ElseIf (0<_LNMB And _LNMB<15) Then
For k=1 to 14
PM[k]=0
endfor
PM[_LNMB]=1
_zmw=zoom[sname]["w"]+_sz[_LNMB+"w"]*PM[_LNMB]
_zmh=zoom[sname]["h"]+_sz[_LNMB+"h"]*PM[_LNMB]
zoom[sname]["w"]=math.Min(Math.Max(0.1,_zmw),20) ' get 0.1 To 20
zoom[sname]["h"]=math.Min(Math.Max(0.1,_zmh),20)
Shapes.Zoom(sname,zoom[sname]["w"],zoom[sname]["h"])
_pw=math.Max(0,math.Min(zoom[sname]["w"]*_pwstart*PM[_LNMB],_pw))
angle[sname]= angle[sname]+_sz[_LNMB]*PM[_LNMB] ' change angle
Shapes.Rotate(sname,angle[sname])
ElseIf (_LNMB = 15 or _LNMB=16) Then
_pw=Math.max(1,prp["StrokeThickness"]+_sz[_LNMB]) ' change penwidth
LDShapes.PenWidth (sname,_pw)
ElseIf (16<_LNMB and _LNMB<21) then ' Set Opacity = 0 --- 100
_sop=math.Min(Math.Max(0,Prp["Opacity"]*100+_op[_LNMB]),100)
shapes.SetOpacity(sname,_sop)
ElseIf (_LNMB = 21 or _LNMB=22) Then
LDShapes.ZIndex(sname,_sz[_LNMB]) ' change Z-index
If _LNMB = 21 Then ' To Top
Serial_nm=LDText.Replace(Serial_nm,sname+",","")+sname+","
ElseIf _LNMB = 22 Then ' To Bottom
Serial_nm=sname+","+LDText.Replace(Serial_nm,sname+",","")
EndIf
ElseIf (_LNMB=23) Then
_clr= Lddialogs.Colour() ' ********** if not stable , use FCdialogs.AskForColor() ********
If _type="Tex" Then
LDShapes.SetProperty(sname,"Foreground",_clr)
Else
LDShapes.BrushColour(sname,_clr) ' change brushcolor
EndIf
ElseIf (_LNMB=24) Then
_clr= Lddialogs.Colour() ' ********** if not stable , use FCdialogs.AskForColor() ********
LDShapes.PenColour(sname,_clr) ' change pencolor
ElseIf (_LNMB = 25) Then ' copy its shape
If text.IsSubText("Pol",_type) Then
_nmb=Name[_type]
_pt= LDText.Split(Prp["Points"]," ")
add_Points()
shp = Ldshapes.AddPolygon(points)
LDShapes.BrushColour(shp,_bc) ' Brushcolor
LDShapes.PenColour(shp,_pc) ' Pencolor
LDShapes.PenWidth(shp,_pw) ' Penwidth
shapes.Move(shp,500,250)
serialdata()
ElseIf _type="Tex" Then
_nmb=5
addshape()
Shapes.SetText(shp,Prp["Text"])
LDShapes.PenColour(shp,_pc) ' change pencolor
_msg[shp]=Prp["Text"]
ElseIf _type="Ima" Then
shp=Shapes.AddImage( LDImage.Copy(_img[sname]))
_path[shp]=_path[sname]
shapeadd_btnhide()
EndIf
sop[sname]=_sop ' opacity
set_data() ' zoom, angle,Opacity
ElseIf (_LNMB = 27) Then ' Remove a shape
If Text.IsSubText(Serial_nm,sname) then
removedata()
EndIf
ElseIf (_LNMB = 28) Then ' Edit Polygon
pell=""
cnt=Array.GetItemCount(_spt)
ddy=0.0000000001
drs=Math.GetRadians( angle[sname])
cx2=cx*zoom[sname]["w"]
cy2=cy*zoom[sname]["h"]
For j=1 to cnt
pell[j]=shapes.AddEllipse(10,10)
_XY2=LDText.Split(_spt[j],",")
_x=_XY2[1]*zoom[sname]["w"]
_y=_XY2[2]*zoom[sname]["h"]
r=math.SquareRoot((_x-cx2)*(_x-cx2)+(_y-cy2)*(_y-cy2)) ' Length from shapes center
If (_y-cy2)<0 then
s=math.ArcTan((_x-cx2)/(_y-cy2+ddy))
Else
s=math.ArcTan((_x-cx2)/(_y-cy2+ddy))-Math.pi
EndIf
_x2=_xy["X"]+cx-r*math.sin(s-drs)''
_y2=_xy["Y"]+cy-r*math.cos(s-drs)''
Shapes.Move(pell[j],_x2-5,_y2-5)
LDShapes.SetShapeEvent(pell[j])
endfor
_sname=sname
edit="True"
ElseIf edit and (_LNMB = 29) Then ' Reset Polygon (after Edit)
setresetpolygon()
shp= LDShapes.AddPolygon(points)
Shapes.Animate(shp,minx,miny,300)
serialdata()
sname=_sname
get_Prp()
LDShapes.BrushColour(shp,_bc) '<---- same color as before
LDShapes.PenColour(shp,_pc) ' <----
LDShapes.PenWidth(shp,_pw)
addppolygon="False"
edit="False"
points=""
EndIf
If (_LNMB < 27) Then
get_Prp()
endif
endif
GraphicsWindow.Title=LDShapes.LastEventShape+" : X= "+_XY["X"]+" , Y= "+_XY["Y"]+" , W= "+2*cx*zoom[sname]["w"]+" , H= "+2*cy*zoom[sname]["h"]+" ,"+_pts+" , angle= "+angle[sname]+" ,pw= "+_pw+" ,Zoom= "+zoom[sname]
EndSub


Sub Onmousedown
MX= GraphicsWindow.MouseX
MY= GraphicsWindow.MouseY
If 5 _nmb=Math.Floor((MX-5)/74.5)+1
dt=_dt
addshape() ' add default shapes
ElseIf MY>80 and addppolygon="False" Then
TF="True"
elseIf MY>80 and addppolygon Then ' add a polygon
GraphicsWindow.PenColor="Red" ' start point color
If cnt>0 then
GraphicsWindow.PenColor="Navy" ' other's color
EndIf
cnt=cnt+1
pell[cnt]=shapes.AddEllipse(8,8)
Shapes.Move(pell[cnt],MX-4,MY-4)
EndIf
EndSub

Sub Onmousemove
MVX= GraphicsWindow.MouseX
MVY= GraphicsWindow.MouseY
If Mouse.IsLeftButtonDown and TF Then
Shapes.Move(sname,MVX-cx,MVY-cy)
EndIf
If edit Then ' for polygon position editing
Shapes.Move(sname,MVX-CX,MVY-CY)
EndIf
EndSub

Sub onshapeclick
If LDShapes.LastEventType="MouseDown" then
sname=LDShapes.LastEventShape
get_Prp()
GraphicsWindow.Width=1225 ' widthen GraphicsWindow.Width to show Listbox
Shapes.Move(listbox,1100,80)
EndIf
EndSub

Sub onup
TF="False"
edit="False"
endSub

Sub removedata
Shapes.Remove(sname)
angle[sname]=""
zoom[sname]=""
Serial_nm=LDText.Replace(Serial_nm,sname+",","")
sname=""
EndSub

Sub Resize_polygon
_pt= LDText.Split(Prp["Points"]," ")
_newpt=""
For j=1 To Array.GetItemCount(_pt)
_XY=LDText.Split(_pt[j],",")
_X=_zmw*_xy[1]
_Y=_zmh*_xy[2]
_newpt=_newpt+" "+_X+","+_Y
EndFor
_newpt=Text.GetSubTextToEnd(_newpt,2) ' Resized new points
EndSub

Sub Re_View
savetoSB()
path=Program.Directory+"\Temp.sb"
' The following line could be harmful and has been automatically commented.
' File.WriteContents(path,conts)
AllClear()
' The following line could be harmful and has been automatically commented.
' RD=File.ReadContents(Program.Directory+"\Temp.sb")
LoadSB()
EndSub

Sub savetoSB
conts="GraphicsWindow.BackgroundColor ="+DQ+ _backCLR+DQ+CRLF
conts=conts+file.ReadContents(Program.Directory+"\Init.sb")+CRLF '<---- IDNo :STD116
conts=conts+CRLF+"Sub init"+CRLF
_serial=Serial_nm
NN=0
cp= Text.GetIndexOf(_Serial,",")
While cp>0
NN=NN+1
sname= Text.GetSubText(_serial,1,cp-1)
_serial=text.GetSubTextToEnd(_serial,cp+1)
get_Prp()
_zmw=zoom[sname]["w"] ' zoom["w"]
_zmh=zoom[sname]["h"] ' zoom["h"]
_xp=math.round(LDShapes.GetLeft(sname)+cx*(1-_zmw))' X
_yp=math.round(LDShapes.Gettop(sname)+cy*(1-_zmh)) ' Y
_bc=(text.GetSubTextToEnd(Prp["Fill"],4)) ' bc
_pc=(text.GetSubTextToEnd(Prp["Stroke"],4)) ' pc
_pw=(Prp["StrokeThickness"]*_zmh) ' pw
If _type="Pol" Then ' Polygon
Resize_polygon()
conts=conts+"shape["+(NN)+"]="+DQ+"fn=Pol;x="+_xp+";y="+_yp+";pts="+_newpt+";zmw=1;zmh=1;ang="+(angle[sname])+";op="+(Prp["Opacity"]*100)+";bc=#"+_bc+";pc=#"+_pc+";pw="+_pw+";"+DQ+CRLF
ElseIf _type="Tex" Then ' Text
conts=conts+"shape["+(NN)+"]="+DQ+"fn=Tex;x="+Math.round(LDShapes.GetLeft(sname))+";y="+ Math.round(LDShapes.Gettop(sname))+";op="+(Prp["Opacity"]*100)+ ";"
conts=conts+"zmw="+(_zmw)+";zmh="+(_zmh)+";fsz="+Prp["FontSize"]+";msg="+ _msg[sname]+";ang="+(angle[sname])+";bc=#"+(text.GetSubTextToEnd(Prp["Foreground"],4))+";pc=;pw=;"+DQ+CRLF
ElseIf _type="Ima" Then ' Image
conts=conts+"shape["+(NN)+"]="+DQ+"fn=Img;x="+Math.round(LDShapes.GetLeft(sname))+";y="+ Math.round(LDShapes.Gettop(sname))+";op="+(Prp["Opacity"]*100)+";"
conts=conts+"zmw="+(_zmw)+";zmh="+(_zmh)+";Src="+(_path[sname])+";ang="+(angle[sname])+";bc=;pc=;pw=;"+DQ+CRLF
EndIf
cp= Text.GetIndexOf(_Serial,",")
EndWhile
conts=conts+"EndSub"
EndSub

Sub serialdata
If zoom[shp]="" Then
zoom[shp]="w=1;h=1" ' zoom =W=1,H=1
EndIf
LDShapes.SetShapeEvent(shp)
angle[shp]=0
Serial_nm=Serial_nm+shp+"," ' serial name
EndSub

Sub set_data
zoom[shp]=zoom[sname]
Shapes.Zoom(shp,zoom[sname]["w"],zoom[sname]["h"])
angle[shp]=angle[sname]
Shapes.Rotate(shp,angle[shp]) ' change angle
sop[shp]=sop[sname]
EndSub

Sub setresetpolygon
minx=1000
miny=1000
points=""
For i=1 to cnt
minx=math.Min(minx,Shapes.GetLeft(pell[i]))
miny=math.Min(miny,Shapes.Gettop(pell[i]))
EndFor
For i=1 to cnt
points[i][1]= Math.Round(Shapes.GetLeft(pell[i])-minx)+4
points[i][2]= Math.Round(Shapes.Gettop(pell[i])-miny)+4
Shapes.Remove(pell[i])
EndFor
EndSub

Sub shapeadd_btnhide
shapes.Move(shp,500,250)
serialdata()
Controls.Move(tbox,1300,90)
Controls.Move(btn[5],1300,90)
Controls.Move(btn[6],1300,90)
EndSub