This function gives the active layer a outline layer style using the current foreground color.
Line thickness , transparency and etc can be manipulated by changing the number following “value=”.
Note that adding a layer style to a layer using this function will overwrite the original layer style.
from krita import *
def setLSLineFgColor():
app = Krita.instance()
win = app.activeWindow()
view = win.activeView()
fgColor = view.foregroundColor().toQString()
fg2 = fgColor.split(" ")
c1 = ' <node key="Rd " value="' + fg2[1] + '" type="Double"/>'
c2 = ' <node key="Grn " value="' + fg2[3] + '" type="Double"/>'
c3 = ' <node key="Bl " value="' + fg2[5] + '" type="Double"/>'
node = Krita.instance().activeDocument().activeNode()
style = ('<asl>'
' <node name="" classId="null" type="Descriptor">'
' <node unit="#Prc" key="Scl " value="100" type="UnitFloat"/>'
' <node key="masterFXSwitch" value="1" type="Boolean"/>'
' <node name="" key="FrFX" classId="FrFX" type="Descriptor">'
' <node key="enab" value="1" type="Boolean"/>'
' <node typeId="FStl" key="Styl" value="OutF" type="Enum"/>'### InsF/CtrF/OutF
' <node typeId="FrFl" key="PntT" value="SClr" type="Enum"/>'
' <node typeId="BlnM" key="Md " value="Nrml" type="Enum"/>'### blendMode
' <node unit="#Prc" key="Opct" value="100" type="UnitFloat"/>'### opacity
' <node unit="#Pxl" key="Sz " value="1" type="UnitFloat"/>'### size
' <node name="" key="Clr " classId="RGBC" type="Descriptor">'
+ c1
+ c2
+ c3
+ ' </node>'
' </node>'
' </node>'
' <node name="" classId="Styl" type="Descriptor">'
' <node name="" key="documentMode" classId="documentMode" type="Descriptor"/>'
' </node>'
'</asl>')
node.setLayerStyleFromAsl(style)
setLSLineFgColor()