diff --git a/plugins/extensions/pykrita/plugin/plugins/palette_docker/palette_docker.py b/plugins/extensions/pykrita/plugin/plugins/palette_docker/palette_docker.py index a0aa516235..d3e6b52ed2 100644 --- a/plugins/extensions/pykrita/plugin/plugins/palette_docker/palette_docker.py +++ b/plugins/extensions/pykrita/plugin/plugins/palette_docker/palette_docker.py @@ -1,200 +1,213 @@ # Description: A Python based docker that allows you to edit KPL color palettes. # By Wolthera # Importing the relevant dependancies: import sys from PyQt5.QtGui import * from PyQt5.QtWidgets import * from PyQt5.Qt import * import math from krita import * #import the exporters -#from palette_exporter_gimppalette import * -#from palette_exporter_inkscapeSVG import * +from . import palette_exporter_gimppalette, palette_exporter_inkscapeSVG class Palette_Docker(DockWidget): #Init the docker def __init__(self): super().__init__() # make base-widget and layout widget = QWidget() layout = QVBoxLayout() buttonLayout = QHBoxLayout() widget.setLayout(layout) self.setWindowTitle("Python Palette Docker") #Make a combobox and add palettes self.cmb_palettes = QComboBox() allPalettes = Application.resources("palette") for palette_name in allPalettes: self.cmb_palettes.addItem(palette_name) self.currentPalette = Palette(allPalettes[list(allPalettes.keys())[0]]) self.cmb_palettes.currentTextChanged.connect(self.slot_paletteChanged) layout.addWidget(self.cmb_palettes) # add combobox to the layout self.paletteView = PaletteView() self.paletteView.setPalette(self.currentPalette) layout.addWidget(self.paletteView) self.paletteView.entrySelectedForeGround.connect(self.slot_swatchSelected) self.colorComboBox = QComboBox() self.colorList = list() buttonLayout.addWidget(self.colorComboBox) self.addEntry = QPushButton() self.addEntry.setText("A") self.addEntry.setToolTip("Add Entry") self.addEntry.clicked.connect(self.slot_add_entry) buttonLayout.addWidget(self.addEntry) self.addGroup = QPushButton() self.addGroup.clicked.connect(self.slot_add_group) self.addGroup.setText("G") self.addGroup.setToolTip("Add Group") buttonLayout.addWidget(self.addGroup) self.removeEntry = QPushButton() self.removeEntry.setText("R") self.removeEntry.setToolTip("Remove Entry") self.removeEntry.clicked.connect(self.slot_remove_entry) buttonLayout.addWidget(self.removeEntry) #QActions self.extra = QToolButton() self.editPaletteData = QAction() self.editPaletteData.setText("Edit Palette Settings") self.editPaletteData.triggered.connect(self.slot_edit_palette_data) self.extra.setDefaultAction(self.editPaletteData) buttonLayout.addWidget(self.extra) self.actionMenu = QMenu() + self.exportToGimp = QAction() + self.exportToGimp.setText("Export as GIMP palette file.") + self.exportToGimp.triggered.connect(self.slot_export_to_gimp_palette) + self.exportToInkscape = QAction() + self.exportToInkscape.setText("Export as Inkscape SVG with swatches.") + self.exportToInkscape.triggered.connect(self.slot_export_to_inkscape_svg) self.actionMenu.addAction(self.editPaletteData) + self.actionMenu.addAction(self.exportToGimp) + self.actionMenu.addAction(self.exportToInkscape) self.extra.setMenu(self.actionMenu) layout.addLayout(buttonLayout) self.slot_fill_combobox() self.setWidget(widget) # add widget to the docker def slot_paletteChanged(self, name): self.currentPalette = Palette(Application.resources("palette")[name]) self.paletteView.setPalette(self.currentPalette) self.slot_fill_combobox() @pyqtSlot('KoColorSetEntry') def slot_swatchSelected(self, entry): print("entry "+entry.name) if (self.canvas()) is not None: if (self.canvas().view()) is not None: name = entry.name if len(entry.id)>0: name = entry.id+" - "+entry.name if len(name)>0: if name in self.colorList: self.colorComboBox.setCurrentIndex(self.colorList.index(name)) color = self.currentPalette.colorForEntry(entry) self.canvas().view().setForeGroundColor(color) ''' A function for making a combobox with the available colors. We use QCompleter on the colorComboBox so that people can type in the name of a color to select it. This is useful for people with carefully made palettes where the colors are named properly, which makes it easier for them to find colors. ''' def slot_fill_combobox(self): if self.currentPalette is None: pass palette = self.currentPalette self.colorComboBox.clear() self.colorList.clear() for i in range(palette.colorsCountTotal()): entry = palette.colorSetEntryByIndex(i) color = palette.colorForEntry(entry).colorForCanvas(self.canvas()) colorSquare = QPixmap(12, 12) if entry.spotColor is True: img = colorSquare.toImage() circlePainter = QPainter() img.fill(self.colorComboBox.palette().color(QPalette.Base)) circlePainter.begin(img) brush = QBrush(Qt.SolidPattern) brush.setColor(color) circlePainter.setBrush(brush) circlePainter.drawEllipse(0, 0, 11, 11) circlePainter.end() colorSquare = QPixmap.fromImage(img) else: colorSquare.fill(color) name = entry.name if len(entry.id)>0: name = entry.id+" - "+entry.name self.colorList.append(name) self.colorComboBox.addItem(QIcon(colorSquare), name) self.colorComboBox.setEditable(True) self.colorComboBox.setInsertPolicy(QComboBox.NoInsert) self.colorComboBox.completer().setCompletionMode(QCompleter.PopupCompletion) self.colorComboBox.completer().setCaseSensitivity(False) self.colorComboBox.completer().setFilterMode(Qt.MatchContains) self.colorComboBox.currentIndexChanged.connect(self.slot_get_color_from_combobox) def slot_get_color_from_combobox(self): if self.currentPalette is not None: entry = self.currentPalette.colorSetEntryByIndex(self.colorComboBox.currentIndex()) self.slot_swatchSelected(entry) def slot_add_entry(self): if (self.canvas()) is not None: if (self.canvas().view()) is not None: color = self.canvas().view().foreGroundColor() succes = self.paletteView.addEntryWithDialog(color) if succes is True: self.slot_fill_combobox() def slot_add_group(self): succes = self.paletteView.addGroupWithDialog() if succes is True: self.slot_fill_combobox() def slot_remove_entry(self): succes = self.paletteView.removeSelectedEntryWithDialog() if succes is True: self.slot_fill_combobox() ''' A function for giving a gui to edit palette metadata... I also want this to be the way to edit the settings of the palette docker. ''' def slot_edit_palette_data(self): dialog = QDialog(self) tabWidget = QTabWidget() dialog.setWindowTitle("Edit Palette Data") dialog.setLayout(QVBoxLayout()) dialog.layout().addWidget(tabWidget) paletteWidget = QWidget() paletteWidget.setLayout(QVBoxLayout()) tabWidget.addTab(paletteWidget, "Palette Data") paletteName = QLineEdit() paletteName.setText(self.cmb_palettes.currentText()) paletteWidget.layout().addWidget(paletteName) paletteColumns = QSpinBox() paletteColumns.setValue(self.currentPalette.columnCount()) paletteWidget.layout().addWidget(paletteColumns) paletteComment = QPlainTextEdit() paletteComment.appendPlainText(self.currentPalette.comment()) paletteWidget.layout().addWidget(paletteComment) buttons = QDialogButtonBox(QDialogButtonBox.Ok) dialog.layout().addWidget(buttons) buttons.accepted.connect(dialog.accept) #buttons.rejected.connect(dialog.reject()) if dialog.exec_()==QDialog.Accepted: Resource = Application.resources("palette")[self.cmb_palettes.currentText()] Resource.setName(paletteName.text()); self.currentPalette = Palette(Resource) print(paletteColumns.value()) self.currentPalette.setColumnCount(paletteColumns.value()) self.paletteView.setPalette(self.currentPalette) self.slot_fill_combobox() self.currentPalette.setComment(paletteComment.toPlainText()) + + def slot_export_to_gimp_palette(self): + palette_exporter_gimppalette.gimpPaletteExporter(self.cmb_palettes.currentText()) + + def slot_export_to_inkscape_svg(self): + palette_exporter_inkscapeSVG.inkscapeSVGExporter(self.cmb_palettes.currentText()) def canvasChanged(self, canvas): pass #Add docker to the application :) Application.addDockWidgetFactory(DockWidgetFactory("palette_docker", DockWidgetFactoryBase.DockRight, Palette_Docker)) diff --git a/plugins/extensions/pykrita/plugin/plugins/palette_docker/palette_exporter_gimppalette.py b/plugins/extensions/pykrita/plugin/plugins/palette_docker/palette_exporter_gimppalette.py index 6c921f2be2..2b616d79ef 100644 --- a/plugins/extensions/pykrita/plugin/plugins/palette_docker/palette_exporter_gimppalette.py +++ b/plugins/extensions/pykrita/plugin/plugins/palette_docker/palette_exporter_gimppalette.py @@ -1,57 +1,60 @@ ''' -A script that converts the palette named "Default" to a Gimp palette. -This ideally needs some gui and the like to select the palette to export.. +A script that converts the palette with the given name to a gimp palette at the location asked for. By Wolthera. ''' # Importing the relevant dependancies: import sys from PyQt5.QtGui import * from PyQt5.QtWidgets import * import math from krita import * class gimpPaletteExporter: - def __init__(self): + def __init__(self, name): #We want people to select a palette and a location to save to... - self.fileName = "" + self.fileName = QFileDialog.getExistingDirectory() allPalettes = Application.resources("palette") - paletteName = list(allPalettes.keys())[0] - self.currentPalette = Palette(allPalettes["paletteName"]) + self.paletteName = name + self.currentPalette = Palette(allPalettes[self.paletteName]) self.export() + done = QMessageBox() + done.setWindowTitle("Export succesful") + done.setText(self.paletteName+" has been exported to "+self.fileName+"!") + done.exec_() pass def export(self): # open the appropriate file... - gplFile = open(self.fileName+self.paletteName+".gpl", "w") + gplFile = open(self.fileName+"/"+self.paletteName+".gpl", "w") gplFile.write("GIMP Palette\n") gplFile.write("Name: "+self.paletteName+"\n") gplFile.write("Columns: "+str(self.currentPalette.columnCount())+"\n") gplFile.write("#"+self.currentPalette.comment()+"\n") colorCount = self.currentPalette.colorsCountGroup("") for i in range(colorCount): entry = self.currentPalette.colorSetEntryFromGroup(i, "") color = self.currentPalette.colorForEntry(entry) #convert to sRGB color.setColorSpace("RGBA", "U8", "sRGB built-in") red = max(min(int(color.componentsOrdered()[0]*255), 255), 0) green = max(min(int(color.componentsOrdered()[1]*255), 255), 0) blue = max(min(int(color.componentsOrdered()[2]*255), 255), 0) gplFile.write(str(red)+" "+str(green)+" "+str(blue)+" "+entry.id+"-"+entry.name+"\n") groupNames = self.currentPalette.groupNames() for groupName in groupNames: colorCount = self.currentPalette.colorsCountGroup(groupName) for i in range(colorCount): entry = self.currentPalette.colorSetEntryFromGroup(i, groupName) color = self.currentPalette.colorForEntry(entry) #convert to sRGB color.setColorSpace("RGBA", "U8", "sRGB built-in") red = max(min(int(color.componentsOrdered()[0]*255), 255), 0) green = max(min(int(color.componentsOrdered()[1]*255), 255), 0) blue = max(min(int(color.componentsOrdered()[2]*255), 255), 0) gplFile.write(str(red)+" "+str(green)+" "+str(blue)+" "+entry.id+"-"+entry.name+"\n") gplFile.close() diff --git a/plugins/extensions/pykrita/plugin/plugins/palette_docker/palette_exporter_inkscapeSVG.py b/plugins/extensions/pykrita/plugin/plugins/palette_docker/palette_exporter_inkscapeSVG.py index 8d07f74c97..b9141bb130 100644 --- a/plugins/extensions/pykrita/plugin/plugins/palette_docker/palette_exporter_inkscapeSVG.py +++ b/plugins/extensions/pykrita/plugin/plugins/palette_docker/palette_exporter_inkscapeSVG.py @@ -1,124 +1,174 @@ ''' A script that converts the palette named "Default" to a SVG so that Inkscape may use the colors -This ideally needs some gui and the like to select the palette to export.. also, the icc-color stuff doesn't work right -ecause we'd need the ability to get the url of the colorprofile somehow, and then we can make @colorprofile things in the definitions. +The icc-color stuff doesn't work right, because we'd need the ability to get the url of the colorprofile somehow, and then we can make color-profile things in the definitions. By Wolthera. ''' # Importing the relevant dependancies: import sys from PyQt5.QtGui import * from PyQt5.QtXml import * from PyQt5.QtWidgets import * import math from krita import * -allPalettes = Application.resources("palette") -paletteName = "Default" -self.currentPalette = Palette(allPalettes[paletteName]) -# open the appropriate file... -svgFile = open(paletteName+".svg", "w") -svgDoc = QDomDocument() -svgBaseElement = svgDoc.createElement("svg") -svgBaseElement.setAttribute("xmlns:osb", "http://www.openswatchbook.org/uri/2009/osb") -svgBaseElement.setAttribute("xmlns:svg", "http://www.w3.org/2000/svg") -svgDefs = svgDoc.createElement("defs") -svgSwatches = svgDoc.createElement("g") -svgSwatches.setAttribute("id", "Swatches") -Row = 0 -Column = 0 +class inkscapeSVGExporter: + + def __init__(self, name): + #We want people to select a palette and a location to save to... + self.fileName = QFileDialog.getExistingDirectory() + allPalettes = Application.resources("palette") + self.paletteName = name + self.currentPalette = Palette(allPalettes[self.paletteName]) + self.export() + done = QMessageBox() + done.setWindowTitle("Export succesful") + done.setText(self.paletteName+" has been exported to "+self.fileName+"!") + done.exec_() + pass -colorCount = self.currentPalette.colorsCountGroup("") + def export(self): + # open the appropriate file... + svgFile = open(self.fileName+"/"+self.paletteName+".svg", "w") + svgDoc = QDomDocument() + svgBaseElement = svgDoc.createElement("svg") + svgBaseElement.setAttribute("xmlns:osb", "http://www.openswatchbook.org/uri/2009/osb") + svgBaseElement.setAttribute("xmlns:svg", "http://www.w3.org/2000/svg") + svgBaseElement.setAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/") + svgBaseElement.setAttribute("xmlns:cc", "http://creativecommons.org/ns#" ) + svgBaseElement.setAttribute("xmlns:rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ) + svgDefs = svgDoc.createElement("defs") + svgSwatches = svgDoc.createElement("g") + svgSwatches.setAttribute("id", "Swatches") -for i in range(colorCount): - entry = self.currentPalette.colorSetEntryFromGroup(i, "") - color = self.currentPalette.colorForEntry(entry) - - iccColor = "icc-color("+color.colorProfile() - for c in range(len(color.componentsOrdered())-1): - iccColor = iccColor+","+str(color.componentsOrdered()[c]) - iccColor = iccColor+")" - #convert to sRGB - color.setColorSpace("RGBA", "U8", "sRGB built-in") - red = max(min(int(color.componentsOrdered()[0]*255), 255), 0) - green = max(min(int(color.componentsOrdered()[1]*255), 255), 0) - blue = max(min(int(color.componentsOrdered()[2]*255), 255), 0) - hexcode = "#"+str(format(red, '02x'))+str(format(green, '02x'))+str(format(blue, '02x')) - swatchName = str(i)+"-"+entry.name - swatchName = swatchName.replace(" ", "-") - swatchMain = svgDoc.createElement("linearGradient") - swatchMain.setAttribute("osb:paint", "solid") - swatchMain.setAttribute("id", swatchName) - swatchSub = svgDoc.createElement("stop") - swatchSub.setAttribute("style", "stop-color: "+hexcode+" "+iccColor+";stop-opacity:1;") - swatchMain.appendChild(swatchSub) - svgDefs.appendChild(swatchMain) - svgSingleSwatch = svgDoc.createElement("rect") - svgSingleSwatch.setAttribute("x", str(int(Column*20))) - svgSingleSwatch.setAttribute("y", str(int(Row*20))) - svgSingleSwatch.setAttribute("width", str(int(20))) - svgSingleSwatch.setAttribute("height", str(int(20))) - svgSingleSwatch.setAttribute("fill", "url(#"+swatchName+")") - svgSingleSwatch.setAttribute("id", "swatch"+swatchName) - svgSwatches.appendChild(svgSingleSwatch) - Column += 1 - if (Column >= self.currentPalette.columnCount()): + svgMeta = svgDoc.createElement("metadata") + svgBaseElement.appendChild(svgMeta) + rdf = svgDoc.createElement("rdf:RDF") + ccwork = svgDoc.createElement("cc:Work") + dctitle = svgDoc.createElement("dc:title") + dcdescription = svgDoc.createElement("dc:description") + dctitle.appendChild(svgDoc.createTextNode(self.paletteName)) + dcdescription.appendChild(svgDoc.createTextNode(self.currentPalette.comment())) + ccwork.appendChild(dctitle) + ccwork.appendChild(dcdescription) + rdf.appendChild(ccwork) + svgMeta.appendChild(rdf) + Row = 0 Column = 0 - Row +=1 - -groupNames = self.currentPalette.groupNames() -for groupName in groupNames: - Column=0 - Row+=1 - groupTitle = svgDoc.createElement("text") - groupTitle.setAttribute("x", str(int(Column*20))) - groupTitle.setAttribute("y", str(int(Row*20)+15)) - groupTitle.appendChild(svgDoc.createTextNode(groupName)) - svgSwatches.appendChild(groupTitle) - Row+=1 - colorCount = self.currentPalette.colorsCountGroup(groupName) - for i in range(colorCount): - entry = self.currentPalette.colorSetEntryFromGroup(i, groupName) - color = self.currentPalette.colorForEntry(entry) - iccColor = "icc-color("+color.colorProfile() - for c in range(len(color.componentsOrdered())-1): - iccColor = iccColor+","+str(color.componentsOrdered()[c]) - iccColor = iccColor+")" - #convert to sRGB - color.setColorSpace("RGBA", "U8", "sRGB built-in") - red = max(min(int(color.componentsOrdered()[0]*255), 255), 0) - green = max(min(int(color.componentsOrdered()[1]*255), 255), 0) - blue = max(min(int(color.componentsOrdered()[2]*255), 255), 0) - hexcode = "#"+str(format(red, '02x'))+str(format(green, '02x'))+str(format(blue, '02x')) - - swatchName = groupName+str(i)+"-"+entry.name - swatchName = swatchName.replace(" ", "-") - swatchMain = svgDoc.createElement("linearGradient") - swatchMain.setAttribute("osb:paint", "solid") - swatchMain.setAttribute("id", swatchName) - swatchSub = svgDoc.createElement("stop") - swatchSub.setAttribute("style", "stop-color: "+hexcode+" "+iccColor+";stop-opacity:1;") - swatchMain.appendChild(swatchSub) - svgDefs.appendChild(swatchMain) - svgSingleSwatch = svgDoc.createElement("rect") - svgSingleSwatch.setAttribute("x", str(int(Column*20))) - svgSingleSwatch.setAttribute("y", str(int(Row*20))) - svgSingleSwatch.setAttribute("width", str(int(20))) - svgSingleSwatch.setAttribute("height", str(int(20))) - svgSingleSwatch.setAttribute("fill", "url(#"+swatchName+")") - svgSingleSwatch.setAttribute("id", "swatch"+swatchName) - svgSwatches.appendChild(svgSingleSwatch) - Column += 1 - if (Column >= self.currentPalette.columnCount()): - Column = 0 - Row +=1 + iccProfileList = [] -svgBaseElement.appendChild(svgDefs) -svgBaseElement.appendChild(svgSwatches) -svgBaseElement.setAttribute("viewBox", "0 0 "+str(self.currentPalette.columnCount()*20)+" "+str(int(Row*20))) -svgDoc.appendChild(svgBaseElement) -svgFile.write(svgDoc.toString()) -svgFile.close() + colorCount = self.currentPalette.colorsCountGroup("") + + for i in range(colorCount): + entry = self.currentPalette.colorSetEntryFromGroup(i, "") + color = self.currentPalette.colorForEntry(entry) + iccColor = "icc-color("+color.colorProfile() + for c in range(len(color.componentsOrdered())-1): + iccColor = iccColor+","+str(color.componentsOrdered()[c]) + iccColor = iccColor+")" + if color.colorProfile() not in iccProfileList: + iccProfileList.append(color.colorProfile()) + + #convert to sRGB + color.setColorSpace("RGBA", "U8", "sRGB built-in") + red = max(min(int(color.componentsOrdered()[0]*255), 255), 0) + green = max(min(int(color.componentsOrdered()[1]*255), 255), 0) + blue = max(min(int(color.componentsOrdered()[2]*255), 255), 0) + hexcode = "#"+str(format(red, '02x'))+str(format(green, '02x'))+str(format(blue, '02x')) + swatchName = str(i)+"-"+entry.name + swatchName = swatchName.replace(" ", "-") + swatchName = swatchName.replace("(", "-") + swatchName = swatchName.replace(")", "-") + swatchMain = svgDoc.createElement("linearGradient") + swatchMain.setAttribute("osb:paint", "solid") + swatchMain.setAttribute("id", swatchName) + swatchSub = svgDoc.createElement("stop") + swatchSub.setAttribute("style", "stop-color: "+hexcode+" "+iccColor+";stop-opacity:1;") + swatchMain.appendChild(swatchSub) + svgDefs.appendChild(swatchMain) + svgSingleSwatch = svgDoc.createElement("rect") + svgSingleSwatch.setAttribute("x", str(int(Column*20))) + svgSingleSwatch.setAttribute("y", str(int(Row*20))) + svgSingleSwatch.setAttribute("width", str(int(20))) + svgSingleSwatch.setAttribute("height", str(int(20))) + svgSingleSwatch.setAttribute("fill", "url(#"+swatchName+")") + svgSingleSwatch.setAttribute("id", "swatch"+swatchName) + if entry.spotColor is True: + svgSingleSwatch.setAttribute("rx", str(10)) + svgSingleSwatch.setAttribute("ry", str(10)) + svgSwatches.appendChild(svgSingleSwatch) + Column += 1 + if (Column >= self.currentPalette.columnCount()): + Column = 0 + Row +=1 + + groupNames = self.currentPalette.groupNames() + for groupName in groupNames: + Column=0 + Row+=1 + groupTitle = svgDoc.createElement("text") + groupTitle.setAttribute("x", str(int(Column*20))) + groupTitle.setAttribute("y", str(int(Row*20)+15)) + groupTitle.appendChild(svgDoc.createTextNode(groupName)) + svgSwatches.appendChild(groupTitle) + Row+=1 + colorCount = self.currentPalette.colorsCountGroup(groupName) + for i in range(colorCount): + entry = self.currentPalette.colorSetEntryFromGroup(i, groupName) + color = self.currentPalette.colorForEntry(entry) + iccColor = "icc-color("+color.colorProfile() + for c in range(len(color.componentsOrdered())-1): + iccColor = iccColor+","+str(color.componentsOrdered()[c]) + iccColor = iccColor+")" + if color.colorProfile() not in iccProfileList: + iccProfileList.append(color.colorProfile()) + #convert to sRGB + color.setColorSpace("RGBA", "U8", "sRGB built-in") + red = max(min(int(color.componentsOrdered()[0]*255), 255), 0) + green = max(min(int(color.componentsOrdered()[1]*255), 255), 0) + blue = max(min(int(color.componentsOrdered()[2]*255), 255), 0) + hexcode = "#"+str(format(red, '02x'))+str(format(green, '02x'))+str(format(blue, '02x')) + + swatchName = groupName+str(i)+"-"+entry.name + swatchName = swatchName.replace(" ", "-") + swatchName = swatchName.replace("(", "-") + swatchName = swatchName.replace(")", "-") + swatchMain = svgDoc.createElement("linearGradient") + swatchMain.setAttribute("osb:paint", "solid") + swatchMain.setAttribute("id", swatchName) + swatchSub = svgDoc.createElement("stop") + swatchSub.setAttribute("style", "stop-color: "+hexcode+" "+iccColor+";stop-opacity:1;") + swatchMain.appendChild(swatchSub) + svgDefs.appendChild(swatchMain) + svgSingleSwatch = svgDoc.createElement("rect") + svgSingleSwatch.setAttribute("x", str(int(Column*20))) + svgSingleSwatch.setAttribute("y", str(int(Row*20))) + svgSingleSwatch.setAttribute("width", str(int(20))) + svgSingleSwatch.setAttribute("height", str(int(20))) + svgSingleSwatch.setAttribute("fill", "url(#"+swatchName+")") + svgSingleSwatch.setAttribute("id", "swatch "+swatchName) + if entry.spotColor is True: + svgSingleSwatch.setAttribute("rx", str(10)) + svgSingleSwatch.setAttribute("ry", str(10)) + svgSwatches.appendChild(svgSingleSwatch) + Column += 1 + if (Column >= self.currentPalette.columnCount()): + Column = 0 + Row +=1 + for profile in iccProfileList: + svgProfileDesc = svgDoc.createElement("color-profile") + svgProfileDesc.setAttribute("name", profile) + #This is incomplete because python api doesn't have any way to ask for this data yet. + #svgProfileDesc.setAttribute("local", "sRGB") + #svgProfileDesc.setAttribute("xlink:href", colorprofileurl) + svgProfileDesc.setAttribute("rendering-intent", "perceptual") + svgDefs.appendChild(svgProfileDesc) + svgBaseElement.appendChild(svgDefs) + svgBaseElement.appendChild(svgSwatches) + svgBaseElement.setAttribute("viewBox", "0 0 "+str(self.currentPalette.columnCount()*20)+" "+str(int((Row+1)*20))) + svgDoc.appendChild(svgBaseElement) + svgFile.write(svgDoc.toString()) + svgFile.close()