def SetRectangle(): "Add a rectangle around text" hdText=SelectText() if hdText!=None: csm=ktDraft.CurrentSubpictureManager() csm.Set(hdText) rect=kcs_draft.element_extent_get(hdText) rect.Corner1.X-=1 rect.Corner1.Y-=1 rect.Corner2.X+=1 rect.Corner2.Y+=1 kcs_draft.rectangle_new(rect) csm.Back()
def SetUnderline(): "add underline for text" hdText=SelectText() if hdText!=None: csm=ktDraft.CurrentSubpictureManager() rect=kcs_draft.element_extent_get(hdText) #begin to draw underline x1=min(rect.Corner1.X,rect.Corner2.X) x2=max(rect.Corner1.X,rect.Corner2.X) y=min(rect.Corner1.Y,rect.Corner2.Y)-1 csm.Set(hdText) line=Rline2D(Point2D(x1,y),Point2D(x2,y)) kcs_draft.line_new(line) csm.Back()
def AlignBottom(): "Align texts to the left." hds=SelectTexts() tList=[] for hd in hds[1:]: t=Text() kcs_draft.text_properties_get(hd,t) tList.append((hd,t)) y=min([t[1].GetPosition().Y for t in tList]) csm=ktDraft.CurrentSubpictureManager() for hd,t in tList: csm.Set(hd) kcs_draft.element_delete(hd) t.Position.Y=y kcs_draft.text_new(t) csm.Back()
def AlignRight(): "Align texts to the left." hds=SelectTexts() tList=[] for hd in hds[1:]: t=Text() kcs_draft.text_properties_get(hd,t) tList.append((hd,t)) x=max([t[1].GetPosition().X for t in tList]) csm=ktDraft.CurrentSubpictureManager() for hd,t in tList: csm.Set(hd) rect=kcs_draft.element_extent_get(hd) width=abs(rect.Corner1.X-rect.Corner2.X) kcs_draft.element_delete(hd) t.Position.X=x-width kcs_draft.text_new(t) csm.Back()
def Amplifier(step): "set the text bigger or smaller by given step" while True: hdText=SelectText() if hdText!=None: csm=ktDraft.CurrentSubpictureManager() t = Text() kcs_draft.text_properties_get(hdText, t) if t.GetHeight()<2: print 'can not be smaller' return else: csm.Set(hdText) kcs_draft.element_delete(hdText) t.SetHeight(t.GetHeight()+step) kcs_draft.text_new(t) csm.Back() else: break
def SetUndeeline(): "add undee(wave) line for text" hdText=SelectText() if hdText!=None: csm=ktDraft.CurrentSubpictureManager() rect=kcs_draft.element_extent_get(hdText) #begin to draw underline x1=min(rect.Corner1.X,rect.Corner2.X) x2=max(rect.Corner1.X,rect.Corner2.X) y=min(rect.Corner1.Y,rect.Corner2.Y)-1 pt=Point2D(x1,y) poly=Polygon2D(pt) dy=0.55 while pt.X<x2: pt.X+=1 pt.Y+=dy dy=-dy poly.AddPoint(pt) csm.Set(hdText) kcs_draft.spline_new(poly) csm.Back()