Best Python code snippet using prospector_python
ekrita.py
Source:ekrita.py
1#-----------------------------------------------------------------------------2# PyKritaToolKit3# Copyright (C) 2019-2021 - Grum9994#5# A toolkit to make pykrita plugin coding easier :-)6# -----------------------------------------------------------------------------7# This program is free software: you can redistribute it and/or modify8# it under the terms of the GNU General Public License as published by9# the Free Software Foundation, either version 3 of the License, or10# (at your option) any later version.11#12# This program is distributed in the hope that it will be useful,13# but WITHOUT ANY WARRANTY; without even the implied warranty of14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.15# See the GNU General Public License for more details.16#17# You should have received a copy of the GNU General Public License18# along with this program.19# If not, see https://www.gnu.org/licenses/20# -----------------------------------------------------------------------------21# -----------------------------------------------------------------------------22from enum import Enum23import re24from ..pktk import *25from krita import (26 Document,27 Node,28 Resource29 )30from PyQt5.QtCore import (31 QByteArray,32 QEventLoop,33 QMimeData,34 QPoint,35 QRect,36 QTimer,37 QUuid,38 )39from PyQt5.QtGui import (40 QGuiApplication,41 QKeySequence,42 QImage,43 QPixmap,44 qRgb45 )46from PyQt5.QtWidgets import (47 QWidget,48 QToolButton,49 QListView50 )51from PyQt5.Qt import (QObject, QMdiArea, QAbstractScrollArea)52# -----------------------------------------------------------------------------53class EKritaWindow:54 @staticmethod55 def scrollbars(window=None):56 """Return scrollbar instances of window57 If `window` is None, use active window58 Return a tuple (horizontalScrollBar, verticalScrollBar)59 If there's no active window, return None60 """61 window=Krita.instance().activeWindow()62 if window is None:63 return None64 qtWindow = Krita.instance().activeWindow().qwindow()65 mdiArea = qtWindow.centralWidget().findChild(QMdiArea)66 subWindow = mdiArea.activeSubWindow()67 scrollArea = subWindow.findChild(QAbstractScrollArea)68 return (scrollArea.horizontalScrollBar(), scrollArea.verticalScrollBar())69class EKritaBrushPreset:70 """Allows 'secured' access to brushes preset71 The main cases:72 - Default brush preset used is not availables73 - Brush preset saved (in a plugin) is not available anymore74 In both case, we need to be able to manage properly acces to resources75 The EKritaBrushPreset class provides static methods to acces to brushes in 'secure' way76 There's a third case we won't manage (not a normal case, hope this will be fixed)77 https://krita-artists.org/t/second-beta-for-krita-5-0-help-in-testing-krita/30262/19?u=grum99978 """79 # define some brushes preset we can consider to be used as default80 __DEFAUL_BRUSH_NAMES=['b) Basic-5 Size',81 'b) Basic-1',82 'c) Pencil-2',83 'd) Ink-2 Fineliner',84 'd) Ink-3 Gpen'85 ]86 __brushes=None87 __presetChooserWidget=None88 @staticmethod89 def initialise():90 """Initialise brushes names"""91 EKritaBrushPreset.__brushes=Krita.instance().resources("preset")92 @staticmethod93 def getName(name=None):94 """Return preset name from name95 Given `name` can be a <str> or a <Resource> (preset)96 If brush preset is found, return brush preset name97 Otherwise if can't be found in presets, return the default brush name98 """99 if EKritaBrushPreset.__brushes is None:100 EKritaBrushPreset.initialise()101 if isinstance(name, Resource):102 name=name.name()103 if name in EKritaBrushPreset.__brushes:104 # asked brush found, return it105 return name106 else:107 # asked brush not found, search for a default brush108 for brushName in EKritaBrushPreset.__DEFAUL_BRUSH_NAMES:109 if brushName in EKritaBrushPreset.__brushes:110 # default brush found, return it111 return brushName112 # default brush not found :-/113 # return current brush from view114 if Krita.instance().activeWindow() and Krita.instance().activeWindow().activeView():115 brushName=Krita.instance().activeWindow().activeView().currentBrushPreset().name()116 else:117 brushName=None118 if brushName in EKritaBrushPreset.__brushes:119 # asked brush found, return it120 return brushName121 # weird..122 #Â but can happen!123 # https://krita-artists.org/t/second-beta-for-krita-5-0-help-in-testing-krita/30262/19?u=grum999124 if len(EKritaBrushPreset.__brushes)>0:125 # return the first one...126 return EKritaBrushPreset.__brushes[list(EKritaBrushPreset.__brushes.keys())[0]].name()127 # this case should never occurs I hope!!128 raise EInvalidStatus('Something weird happened!\n- Given brush name "'+name+'" was not found\n- Current brush "'+brushName+'" returned bu Krita doesn\'t exist\n- Brush preset list returned by Krita is empty\n\nCan\'t do anything...')129 @staticmethod130 def getPreset(name=None):131 """Return preset for given name132 Given `name` can be a <str> or a <Resource> (preset)133 If brush preset is found, return brush preset134 Otherwise if can't be found in presets, return the default brush preset135 """136 if EKritaBrushPreset.__brushes is None:137 EKritaBrushPreset.initialise()138 return EKritaBrushPreset.__brushes[EKritaBrushPreset.getName(name)]139 @staticmethod140 def found(name):141 """Return if brush preset (from name) exists and can be used"""142 return EKritaBrushPreset.getName(name)==name143 @staticmethod144 def presetChooserWidget():145 """Return preset chooser on which 'currentResourceChanged' signal can be146 connected147 EKritaBrushPreset.presetChooserWidget().currentResourceChanged.connect(myFunction)148 Solution provided by @KnowZero on KA149 https://krita-artists.org/t/it-is-sane-for-a-plugin-to-capture-krita-internal-signal/32475/6150 """151 if EKritaBrushPreset.__presetChooserWidget is None:152 window=Krita.instance().activeWindow().qwindow()153 widget=window.findChild(QWidget, 'ResourceChooser')154 EKritaBrushPreset.__presetChooserWidget=widget.findChild(QListView,'ResourceItemview')155 return EKritaBrushPreset.__presetChooserWidget156class EKritaShortcuts:157 """Manage shortcuts"""158 @staticmethod159 def checkIfExists(keySequence):160 """Check if given `keySequence` is already used by a Krita action161 Return a list of action using the sequence162 """163 returned=[]164 actions=Krita.instance().actions()165 for action in actions:166 shortcuts=action.shortcuts()167 for shortcut in shortcuts:168 if keySequence.matches(shortcut)==QKeySequence.ExactMatch:169 returned.append(action)170 break171 return returned172class EKritaPaintToolsId:173 """Paint tools Id"""174 TOOL_BRUSH= 'KritaShape/KisToolBrush'175 TOOL_LINE= 'KritaShape/KisToolLine'176 TOOL_RECTANGLE= 'KritaShape/KisToolRectangle'177 TOOL_ELLIPSE= 'KritaShape/KisToolEllipse'178 TOOL_POLYGON= 'KisToolPolygon'179 TOOL_POLYLINE= 'KisToolPolyline'180 TOOL_PATH= 'KritaShape/KisToolPath'181 TOOL_PENCIL= 'KisToolPencil'182 TOOL_DYNAMIC_BRUSH= 'KritaShape/KisToolDyna'183 TOOL_MULTI_BRUSH= 'KritaShape/KisToolMultiBrush'184class EKritaPaintTools:185 """Quick access to paint tools"""186 __TOOLS={187 EKritaPaintToolsId.TOOL_BRUSH: i18n("Freehand Brush Tool"),188 EKritaPaintToolsId.TOOL_LINE: i18n("Line Tool"),189 EKritaPaintToolsId.TOOL_RECTANGLE: i18n("Rectangle Tool"),190 EKritaPaintToolsId.TOOL_ELLIPSE: i18n("Ellipse Tool"),191 EKritaPaintToolsId.TOOL_POLYGON: i18n("Polygon Tool: Shift-mouseclick ends the polygon."),192 EKritaPaintToolsId.TOOL_POLYLINE: i18n("Polyline Tool: Shift-mouseclick ends the polyline."),193 EKritaPaintToolsId.TOOL_PATH: i18n("Bezier Curve Tool: Shift-mouseclick ends the curve."),194 EKritaPaintToolsId.TOOL_PENCIL: i18n("Freehand Path Tool"),195 EKritaPaintToolsId.TOOL_DYNAMIC_BRUSH: i18n("Dynamic Brush Tool"),196 EKritaPaintToolsId.TOOL_MULTI_BRUSH: i18n("Multibrush Tool")197 }198 @staticmethod199 def idList():200 """Return list of tools identifiers"""201 return list(EKritaPaintTools.__TOOLS)202 @staticmethod203 def name(id):204 """Return (translated) name for paint tools205 None value return 'None' string206 Otherwise Raise an error is tools is not found207 """208 if id is None:209 return i18n('None')210 elif id in EKritaPaintTools.__TOOLS:211 return re.sub('\s*:.*', '', EKritaPaintTools.__TOOLS[id])212 else:213 raise EInvalidValue("Given `id` is not valid")214 @staticmethod215 def current():216 """return id of current paint tool, if any active217 Otherwise return None218 """219 window=Krita.instance().activeWindow()220 if window:221 for id in EKritaPaintTools.__TOOLS:222 toolButton=window.qwindow().findChild(QToolButton, id)223 if toolButton and toolButton.isChecked():224 return id225 return None226class EKritaBlendingModesId:227 """Blending modes Id"""228 # list from:229 # https://invent.kde.org/graphics/krita/-/blob/master/libs/pigment/KoCompositeOpRegistry.h230 COMPOSITE_OVER= "normal"231 COMPOSITE_ERASE= "erase"232 COMPOSITE_IN= "in"233 COMPOSITE_OUT= "out"234 COMPOSITE_ALPHA_DARKEN= "alphadarken"235 COMPOSITE_DESTINATION_IN= "destination-in"236 COMPOSITE_DESTINATION_ATOP= "destination-atop"237 COMPOSITE_XOR= "xor"238 COMPOSITE_OR= "or"239 COMPOSITE_AND= "and"240 COMPOSITE_NAND= "nand"241 COMPOSITE_NOR= "nor"242 COMPOSITE_XNOR= "xnor"243 COMPOSITE_IMPLICATION= "implication"244 COMPOSITE_NOT_IMPLICATION= "not_implication"245 COMPOSITE_CONVERSE= "converse"246 COMPOSITE_NOT_CONVERSE= "not_converse"247 COMPOSITE_PLUS= "plus"248 COMPOSITE_MINUS= "minus"249 COMPOSITE_ADD= "add"250 COMPOSITE_SUBTRACT= "subtract"251 COMPOSITE_INVERSE_SUBTRACT= "inverse_subtract"252 COMPOSITE_DIFF= "diff"253 COMPOSITE_MULT= "multiply"254 COMPOSITE_DIVIDE= "divide"255 COMPOSITE_ARC_TANGENT= "arc_tangent"256 COMPOSITE_GEOMETRIC_MEAN= "geometric_mean"257 COMPOSITE_ADDITIVE_SUBTRACTIVE= "additive_subtractive"258 COMPOSITE_NEGATION= "negation"259 COMPOSITE_MOD= "modulo"260 COMPOSITE_MOD_CON= "modulo_continuous"261 COMPOSITE_DIVISIVE_MOD= "divisive_modulo"262 COMPOSITE_DIVISIVE_MOD_CON= "divisive_modulo_continuous"263 COMPOSITE_MODULO_SHIFT= "modulo_shift"264 COMPOSITE_MODULO_SHIFT_CON= "modulo_shift_continuous"265 COMPOSITE_EQUIVALENCE= "equivalence"266 COMPOSITE_ALLANON= "allanon"267 COMPOSITE_PARALLEL= "parallel"268 COMPOSITE_GRAIN_MERGE= "grain_merge"269 COMPOSITE_GRAIN_EXTRACT= "grain_extract"270 COMPOSITE_EXCLUSION= "exclusion"271 COMPOSITE_HARD_MIX= "hard mix"272 COMPOSITE_HARD_MIX_PHOTOSHOP= "hard_mix_photoshop"273 COMPOSITE_HARD_MIX_SOFTER_PHOTOSHOP= "hard_mix_softer_photoshop"274 COMPOSITE_OVERLAY= "overlay"275 COMPOSITE_BEHIND= "behind"276 COMPOSITE_GREATER= "greater"277 COMPOSITE_HARD_OVERLAY= "hard overlay"278 COMPOSITE_INTERPOLATION= "interpolation"279 COMPOSITE_INTERPOLATIONB= "interpolation 2x"280 COMPOSITE_PENUMBRAA= "penumbra a"281 COMPOSITE_PENUMBRAB= "penumbra b"282 COMPOSITE_PENUMBRAC= "penumbra c"283 COMPOSITE_PENUMBRAD= "penumbra d"284 COMPOSITE_DARKEN= "darken"285 COMPOSITE_BURN= "burn" #color burn286 COMPOSITE_LINEAR_BURN= "linear_burn"287 COMPOSITE_GAMMA_DARK= "gamma_dark"288 COMPOSITE_SHADE_IFS_ILLUSIONS= "shade_ifs_illusions"289 COMPOSITE_FOG_DARKEN_IFS_ILLUSIONS= "fog_darken_ifs_illusions"290 COMPOSITE_EASY_BURN= "easy burn"291 COMPOSITE_LIGHTEN= "lighten"292 COMPOSITE_DODGE= "dodge"293 COMPOSITE_LINEAR_DODGE= "linear_dodge"294 COMPOSITE_SCREEN= "screen"295 COMPOSITE_HARD_LIGHT= "hard_light"296 COMPOSITE_SOFT_LIGHT_IFS_ILLUSIONS= "soft_light_ifs_illusions"297 COMPOSITE_SOFT_LIGHT_PEGTOP_DELPHI= "soft_light_pegtop_delphi"298 COMPOSITE_SOFT_LIGHT_PHOTOSHOP= "soft_light"299 COMPOSITE_SOFT_LIGHT_SVG= "soft_light_svg"300 COMPOSITE_GAMMA_LIGHT= "gamma_light"301 COMPOSITE_GAMMA_ILLUMINATION= "gamma_illumination"302 COMPOSITE_VIVID_LIGHT= "vivid_light"303 COMPOSITE_FLAT_LIGHT= "flat_light"304 COMPOSITE_LINEAR_LIGHT= "linear light"305 COMPOSITE_PIN_LIGHT= "pin_light"306 COMPOSITE_PNORM_A= "pnorm_a"307 COMPOSITE_PNORM_B= "pnorm_b"308 COMPOSITE_SUPER_LIGHT= "super_light"309 COMPOSITE_TINT_IFS_ILLUSIONS= "tint_ifs_illusions"310 COMPOSITE_FOG_LIGHTEN_IFS_ILLUSIONS= "fog_lighten_ifs_illusions"311 COMPOSITE_EASY_DODGE= "easy dodge"312 COMPOSITE_LUMINOSITY_SAI= "luminosity_sai"313 COMPOSITE_HUE= "hue"314 COMPOSITE_COLOR= "color"315 COMPOSITE_SATURATION= "saturation"316 COMPOSITE_INC_SATURATION= "inc_saturation"317 COMPOSITE_DEC_SATURATION= "dec_saturation"318 COMPOSITE_LUMINIZE= "luminize"319 COMPOSITE_INC_LUMINOSITY= "inc_luminosity"320 COMPOSITE_DEC_LUMINOSITY= "dec_luminosity"321 COMPOSITE_HUE_HSV= "hue_hsv"322 COMPOSITE_COLOR_HSV= "color_hsv"323 COMPOSITE_SATURATION_HSV= "saturation_hsv"324 COMPOSITE_INC_SATURATION_HSV= "inc_saturation_hsv"325 COMPOSITE_DEC_SATURATION_HSV= "dec_saturation_hsv"326 COMPOSITE_VALUE= "value"327 COMPOSITE_INC_VALUE= "inc_value"328 COMPOSITE_DEC_VALUE= "dec_value"329 COMPOSITE_HUE_HSL= "hue_hsl"330 COMPOSITE_COLOR_HSL= "color_hsl"331 COMPOSITE_SATURATION_HSL= "saturation_hsl"332 COMPOSITE_INC_SATURATION_HSL= "inc_saturation_hsl"333 COMPOSITE_DEC_SATURATION_HSL= "dec_saturation_hsl"334 COMPOSITE_LIGHTNESS= "lightness"335 COMPOSITE_INC_LIGHTNESS= "inc_lightness"336 COMPOSITE_DEC_LIGHTNESS= "dec_lightness"337 COMPOSITE_HUE_HSI= "hue_hsi"338 COMPOSITE_COLOR_HSI= "color_hsi"339 COMPOSITE_SATURATION_HSI= "saturation_hsi"340 COMPOSITE_INC_SATURATION_HSI= "inc_saturation_hsi"341 COMPOSITE_DEC_SATURATION_HSI= "dec_saturation_hsi"342 COMPOSITE_INTENSITY= "intensity"343 COMPOSITE_INC_INTENSITY= "inc_intensity"344 COMPOSITE_DEC_INTENSITY= "dec_intensity"345 COMPOSITE_COPY= "copy"346 COMPOSITE_COPY_RED= "copy_red"347 COMPOSITE_COPY_GREEN= "copy_green"348 COMPOSITE_COPY_BLUE= "copy_blue"349 COMPOSITE_TANGENT_NORMALMAP= "tangent_normalmap"350 COMPOSITE_COLORIZE= "colorize"351 COMPOSITE_BUMPMAP= "bumpmap"352 COMPOSITE_COMBINE_NORMAL= "combine_normal"353 COMPOSITE_CLEAR= "clear"354 COMPOSITE_DISSOLVE= "dissolve"355 COMPOSITE_DISPLACE= "displace"356 COMPOSITE_NO= "nocomposition"357 COMPOSITE_PASS_THROUGH= "pass through" # XXX: not implemented anywhere yet?358 COMPOSITE_DARKER_COLOR= "darker color"359 COMPOSITE_LIGHTER_COLOR= "lighter color"360 #COMPOSITE_UNDEF= "undefined"361 COMPOSITE_REFLECT= "reflect"362 COMPOSITE_GLOW= "glow"363 COMPOSITE_FREEZE= "freeze"364 COMPOSITE_HEAT= "heat"365 COMPOSITE_GLEAT= "glow_heat"366 COMPOSITE_HELOW= "heat_glow"367 COMPOSITE_REEZE= "reflect_freeze"368 COMPOSITE_FRECT= "freeze_reflect"369 COMPOSITE_FHYRD= "heat_glow_freeze_reflect_hybrid"370 CATEGORY_ARITHMETIC= "arithmetic"371 CATEGORY_BINARY= "binary"372 CATEGORY_DARK= "dark"373 CATEGORY_LIGHT= "light"374 CATEGORY_MODULO= "modulo"375 CATEGORY_NEGATIVE= "negative"376 CATEGORY_MIX= "mix"377 CATEGORY_MISC= "misc"378 CATEGORY_HSY= "hsy"379 CATEGORY_HSI= "hsi"380 CATEGORY_HSL= "hsl"381 CATEGORY_HSV= "hsv"382 CATEGORY_QUADRATIC= "quadratic"383class EKritaBlendingModes:384 """Blending modes"""385 # tables & translations from386 # https://invent.kde.org/graphics/krita/-/blob/master/libs/pigment/KoCompositeOpRegistry.cpp387 __CATEGORIES={388 EKritaBlendingModesId.CATEGORY_ARITHMETIC: i18nc("Blending mode - category Arithmetic", "Arithmetic"),389 EKritaBlendingModesId.CATEGORY_BINARY: i18nc("Blending mode - category Binary", "Binary"),390 EKritaBlendingModesId.CATEGORY_DARK: i18nc("Blending mode - category Darken", "Darken"),391 EKritaBlendingModesId.CATEGORY_LIGHT: i18nc("Blending mode - category Lighten", "Lighten"),392 EKritaBlendingModesId.CATEGORY_MODULO: i18nc("Blending mode - category Modulo", "Modulo"),393 EKritaBlendingModesId.CATEGORY_NEGATIVE: i18nc("Blending mode - category Negative", "Negative"),394 EKritaBlendingModesId.CATEGORY_MIX: i18nc("Blending mode - category Mix", "Mix"),395 EKritaBlendingModesId.CATEGORY_MISC: i18nc("Blending mode - category Misc", "Misc"),396 EKritaBlendingModesId.CATEGORY_HSY: i18nc("Blending mode - category HSY", "HSY"),397 EKritaBlendingModesId.CATEGORY_HSI: i18nc("Blending mode - category HSI", "HSI"),398 EKritaBlendingModesId.CATEGORY_HSL: i18nc("Blending mode - category HSL", "HSL"),399 EKritaBlendingModesId.CATEGORY_HSV: i18nc("Blending mode - category HSV", "HSV"),400 EKritaBlendingModesId.CATEGORY_QUADRATIC: i18nc("Blending mode - category Quadratic", "Quadratic")401 }402 __CATEGORIES_BLENDING_MODES={403 EKritaBlendingModesId.CATEGORY_ARITHMETIC: [404 EKritaBlendingModesId.COMPOSITE_ADD,405 EKritaBlendingModesId.COMPOSITE_SUBTRACT,406 EKritaBlendingModesId.COMPOSITE_MULT,407 EKritaBlendingModesId.COMPOSITE_DIVIDE,408 EKritaBlendingModesId.COMPOSITE_INVERSE_SUBTRACT409 ],410 EKritaBlendingModesId.CATEGORY_BINARY: [411 EKritaBlendingModesId.COMPOSITE_XOR,412 EKritaBlendingModesId.COMPOSITE_OR,413 EKritaBlendingModesId.COMPOSITE_AND,414 EKritaBlendingModesId.COMPOSITE_NAND,415 EKritaBlendingModesId.COMPOSITE_NOR,416 EKritaBlendingModesId.COMPOSITE_XNOR,417 EKritaBlendingModesId.COMPOSITE_IMPLICATION,418 EKritaBlendingModesId.COMPOSITE_NOT_IMPLICATION,419 EKritaBlendingModesId.COMPOSITE_CONVERSE,420 EKritaBlendingModesId.COMPOSITE_NOT_CONVERSE421 ],422 EKritaBlendingModesId.CATEGORY_DARK: [423 EKritaBlendingModesId.COMPOSITE_BURN,424 EKritaBlendingModesId.COMPOSITE_LINEAR_BURN,425 EKritaBlendingModesId.COMPOSITE_DARKEN,426 EKritaBlendingModesId.COMPOSITE_GAMMA_DARK,427 EKritaBlendingModesId.COMPOSITE_DARKER_COLOR,428 EKritaBlendingModesId.COMPOSITE_SHADE_IFS_ILLUSIONS,429 EKritaBlendingModesId.COMPOSITE_FOG_DARKEN_IFS_ILLUSIONS,430 EKritaBlendingModesId.COMPOSITE_EASY_BURN431 ],432 EKritaBlendingModesId.CATEGORY_LIGHT: [433 EKritaBlendingModesId.COMPOSITE_DODGE,434 EKritaBlendingModesId.COMPOSITE_LINEAR_DODGE,435 EKritaBlendingModesId.COMPOSITE_LIGHTEN,436 EKritaBlendingModesId.COMPOSITE_LINEAR_LIGHT,437 EKritaBlendingModesId.COMPOSITE_SCREEN,438 EKritaBlendingModesId.COMPOSITE_PIN_LIGHT,439 EKritaBlendingModesId.COMPOSITE_VIVID_LIGHT,440 EKritaBlendingModesId.COMPOSITE_FLAT_LIGHT,441 EKritaBlendingModesId.COMPOSITE_HARD_LIGHT,442 EKritaBlendingModesId.COMPOSITE_SOFT_LIGHT_IFS_ILLUSIONS,443 EKritaBlendingModesId.COMPOSITE_SOFT_LIGHT_PEGTOP_DELPHI,444 EKritaBlendingModesId.COMPOSITE_SOFT_LIGHT_PHOTOSHOP,445 EKritaBlendingModesId.COMPOSITE_SOFT_LIGHT_SVG,446 EKritaBlendingModesId.COMPOSITE_GAMMA_LIGHT,447 EKritaBlendingModesId.COMPOSITE_GAMMA_ILLUMINATION,448 EKritaBlendingModesId.COMPOSITE_LIGHTER_COLOR,449 EKritaBlendingModesId.COMPOSITE_PNORM_A,450 EKritaBlendingModesId.COMPOSITE_PNORM_B,451 EKritaBlendingModesId.COMPOSITE_SUPER_LIGHT,452 EKritaBlendingModesId.COMPOSITE_TINT_IFS_ILLUSIONS,453 EKritaBlendingModesId.COMPOSITE_FOG_LIGHTEN_IFS_ILLUSIONS,454 EKritaBlendingModesId.COMPOSITE_EASY_DODGE,455 EKritaBlendingModesId.COMPOSITE_LUMINOSITY_SAI456 ],457 EKritaBlendingModesId.CATEGORY_MODULO: [458 EKritaBlendingModesId.COMPOSITE_MOD,459 EKritaBlendingModesId.COMPOSITE_MOD_CON,460 EKritaBlendingModesId.COMPOSITE_DIVISIVE_MOD,461 EKritaBlendingModesId.COMPOSITE_DIVISIVE_MOD_CON,462 EKritaBlendingModesId.COMPOSITE_MODULO_SHIFT,463 EKritaBlendingModesId.COMPOSITE_MODULO_SHIFT_CON464 ],465 EKritaBlendingModesId.CATEGORY_NEGATIVE: [466 EKritaBlendingModesId.COMPOSITE_DIFF,467 EKritaBlendingModesId.COMPOSITE_EQUIVALENCE,468 EKritaBlendingModesId.COMPOSITE_ADDITIVE_SUBTRACTIVE,469 EKritaBlendingModesId.COMPOSITE_EXCLUSION,470 EKritaBlendingModesId.COMPOSITE_ARC_TANGENT,471 EKritaBlendingModesId.COMPOSITE_NEGATION472 ],473 EKritaBlendingModesId.CATEGORY_MIX: [474 EKritaBlendingModesId.COMPOSITE_OVER,475 EKritaBlendingModesId.COMPOSITE_BEHIND,476 EKritaBlendingModesId.COMPOSITE_GREATER,477 EKritaBlendingModesId.COMPOSITE_OVERLAY,478 EKritaBlendingModesId.COMPOSITE_ERASE,479 EKritaBlendingModesId.COMPOSITE_ALPHA_DARKEN,480 EKritaBlendingModesId.COMPOSITE_HARD_MIX,481 EKritaBlendingModesId.COMPOSITE_HARD_MIX_PHOTOSHOP,482 EKritaBlendingModesId.COMPOSITE_HARD_MIX_SOFTER_PHOTOSHOP,483 EKritaBlendingModesId.COMPOSITE_GRAIN_MERGE,484 EKritaBlendingModesId.COMPOSITE_GRAIN_EXTRACT,485 EKritaBlendingModesId.COMPOSITE_PARALLEL,486 EKritaBlendingModesId.COMPOSITE_ALLANON,487 EKritaBlendingModesId.COMPOSITE_GEOMETRIC_MEAN,488 EKritaBlendingModesId.COMPOSITE_DESTINATION_ATOP,489 EKritaBlendingModesId.COMPOSITE_DESTINATION_IN,490 EKritaBlendingModesId.COMPOSITE_HARD_OVERLAY,491 EKritaBlendingModesId.COMPOSITE_INTERPOLATION,492 EKritaBlendingModesId.COMPOSITE_INTERPOLATIONB,493 EKritaBlendingModesId.COMPOSITE_PENUMBRAA,494 EKritaBlendingModesId.COMPOSITE_PENUMBRAB,495 EKritaBlendingModesId.COMPOSITE_PENUMBRAC,496 EKritaBlendingModesId.COMPOSITE_PENUMBRAD497 ],498 EKritaBlendingModesId.CATEGORY_MISC: [499 EKritaBlendingModesId.COMPOSITE_BUMPMAP,500 EKritaBlendingModesId.COMPOSITE_COMBINE_NORMAL,501 EKritaBlendingModesId.COMPOSITE_DISSOLVE,502 EKritaBlendingModesId.COMPOSITE_COPY_RED,503 EKritaBlendingModesId.COMPOSITE_COPY_GREEN,504 EKritaBlendingModesId.COMPOSITE_COPY_BLUE,505 EKritaBlendingModesId.COMPOSITE_COPY,506 EKritaBlendingModesId.COMPOSITE_TANGENT_NORMALMAP507 ],508 EKritaBlendingModesId.CATEGORY_HSY: [509 EKritaBlendingModesId.COMPOSITE_COLOR,510 EKritaBlendingModesId.COMPOSITE_HUE,511 EKritaBlendingModesId.COMPOSITE_SATURATION,512 EKritaBlendingModesId.COMPOSITE_LUMINIZE,513 EKritaBlendingModesId.COMPOSITE_DEC_SATURATION,514 EKritaBlendingModesId.COMPOSITE_INC_SATURATION,515 EKritaBlendingModesId.COMPOSITE_DEC_LUMINOSITY,516 EKritaBlendingModesId.COMPOSITE_INC_LUMINOSITY517 ],518 EKritaBlendingModesId.CATEGORY_HSI: [519 EKritaBlendingModesId.COMPOSITE_COLOR_HSI,520 EKritaBlendingModesId.COMPOSITE_HUE_HSI,521 EKritaBlendingModesId.COMPOSITE_SATURATION_HSI,522 EKritaBlendingModesId.COMPOSITE_INTENSITY,523 EKritaBlendingModesId.COMPOSITE_DEC_SATURATION_HSI,524 EKritaBlendingModesId.COMPOSITE_INC_SATURATION_HSI,525 EKritaBlendingModesId.COMPOSITE_DEC_INTENSITY,526 EKritaBlendingModesId.COMPOSITE_INC_INTENSITY527 ],528 EKritaBlendingModesId.CATEGORY_HSL: [529 EKritaBlendingModesId.COMPOSITE_COLOR_HSL,530 EKritaBlendingModesId.COMPOSITE_HUE_HSL,531 EKritaBlendingModesId.COMPOSITE_SATURATION_HSL,532 EKritaBlendingModesId.COMPOSITE_LIGHTNESS,533 EKritaBlendingModesId.COMPOSITE_DEC_SATURATION_HSL,534 EKritaBlendingModesId.COMPOSITE_INC_SATURATION_HSL,535 EKritaBlendingModesId.COMPOSITE_DEC_LIGHTNESS,536 EKritaBlendingModesId.COMPOSITE_INC_LIGHTNESS537 ],538 EKritaBlendingModesId.CATEGORY_HSV: [539 EKritaBlendingModesId.COMPOSITE_COLOR_HSV,540 EKritaBlendingModesId.COMPOSITE_HUE_HSV,541 EKritaBlendingModesId.COMPOSITE_SATURATION_HSV,542 EKritaBlendingModesId.COMPOSITE_VALUE,543 EKritaBlendingModesId.COMPOSITE_DEC_SATURATION_HSV,544 EKritaBlendingModesId.COMPOSITE_INC_SATURATION_HSV,545 EKritaBlendingModesId.COMPOSITE_DEC_VALUE,546 EKritaBlendingModesId.COMPOSITE_INC_VALUE547 ],548 EKritaBlendingModesId.CATEGORY_QUADRATIC: [549 EKritaBlendingModesId.COMPOSITE_REFLECT,550 EKritaBlendingModesId.COMPOSITE_GLOW,551 EKritaBlendingModesId.COMPOSITE_FREEZE,552 EKritaBlendingModesId.COMPOSITE_HEAT,553 EKritaBlendingModesId.COMPOSITE_GLEAT,554 EKritaBlendingModesId.COMPOSITE_HELOW,555 EKritaBlendingModesId.COMPOSITE_REEZE,556 EKritaBlendingModesId.COMPOSITE_FRECT,557 EKritaBlendingModesId.COMPOSITE_FHYRD558 ]559 }560 __BLENDING_MODES={561 EKritaBlendingModesId.COMPOSITE_ADD: i18nc("Blending mode - Addition", "Addition"),562 EKritaBlendingModesId.COMPOSITE_SUBTRACT: i18nc("Blending mode - Subtract", "Subtract"),563 EKritaBlendingModesId.COMPOSITE_MULT: i18nc("Blending mode - Multiply", "Multiply"),564 EKritaBlendingModesId.COMPOSITE_DIVIDE: i18nc("Blending mode - Divide", "Divide"),565 EKritaBlendingModesId.COMPOSITE_INVERSE_SUBTRACT: i18nc("Blending mode - Inverse Subtract", "Inverse Subtract"),566 EKritaBlendingModesId.COMPOSITE_XOR: i18nc("Blending mode - XOR", "XOR"),567 EKritaBlendingModesId.COMPOSITE_OR: i18nc("Blending mode - OR", "OR"),568 EKritaBlendingModesId.COMPOSITE_AND: i18nc("Blending mode - AND", "AND"),569 EKritaBlendingModesId.COMPOSITE_NAND: i18nc("Blending mode - NAND", "NAND"),570 EKritaBlendingModesId.COMPOSITE_NOR: i18nc("Blending mode - NOR", "NOR"),571 EKritaBlendingModesId.COMPOSITE_XNOR: i18nc("Blending mode - XNOR", "XNOR"),572 EKritaBlendingModesId.COMPOSITE_IMPLICATION: i18nc("Blending mode - IMPLICATION", "IMPLICATION"),573 EKritaBlendingModesId.COMPOSITE_NOT_IMPLICATION: i18nc("Blending mode - NOT IMPLICATION", "NOT IMPLICATION"),574 EKritaBlendingModesId.COMPOSITE_CONVERSE: i18nc("Blending mode - CONVERSE", "CONVERSE"),575 EKritaBlendingModesId.COMPOSITE_NOT_CONVERSE: i18nc("Blending mode - NOT CONVERSE", "NOT CONVERSE"),576 EKritaBlendingModesId.COMPOSITE_BURN: i18nc("Blending mode - Burn", "Burn"),577 EKritaBlendingModesId.COMPOSITE_LINEAR_BURN: i18nc("Blending mode - Linear Burn", "Linear Burn"),578 EKritaBlendingModesId.COMPOSITE_DARKEN: i18nc("Blending mode - Darken", "Darken"),579 EKritaBlendingModesId.COMPOSITE_GAMMA_DARK: i18nc("Blending mode - Gamma Dark", "Gamma Dark"),580 EKritaBlendingModesId.COMPOSITE_DARKER_COLOR: i18nc("Blending mode - Darker Color", "Darker Color"),581 EKritaBlendingModesId.COMPOSITE_SHADE_IFS_ILLUSIONS: i18nc("Blending mode - Shade (IFS Illusions)", "Shade (IFS Illusions)"),582 EKritaBlendingModesId.COMPOSITE_FOG_DARKEN_IFS_ILLUSIONS: i18nc("Blending mode - Fog Darken (IFS Illusions)", "Fog Darken (IFS Illusions)"),583 EKritaBlendingModesId.COMPOSITE_EASY_BURN: i18nc("Blending mode - Easy Burn", "Easy Burn"),584 EKritaBlendingModesId.COMPOSITE_DODGE: i18nc("Blending mode - Color Dodge", "Color Dodge"),585 EKritaBlendingModesId.COMPOSITE_LINEAR_DODGE: i18nc("Blending mode - Linear Dodge", "Linear Dodge"),586 EKritaBlendingModesId.COMPOSITE_LIGHTEN: i18nc("Blending mode - Lighten", "Lighten"),587 EKritaBlendingModesId.COMPOSITE_LINEAR_LIGHT: i18nc("Blending mode - Linear Light", "Linear Light"),588 EKritaBlendingModesId.COMPOSITE_SCREEN: i18nc("Blending mode - Screen", "Screen"),589 EKritaBlendingModesId.COMPOSITE_PIN_LIGHT: i18nc("Blending mode - Pin Light", "Pin Light"),590 EKritaBlendingModesId.COMPOSITE_VIVID_LIGHT: i18nc("Blending mode - Vivid Light", "Vivid Light"),591 EKritaBlendingModesId.COMPOSITE_FLAT_LIGHT: i18nc("Blending mode - Flat Light", "Flat Light"),592 EKritaBlendingModesId.COMPOSITE_HARD_LIGHT: i18nc("Blending mode - Hard Light", "Hard Light"),593 EKritaBlendingModesId.COMPOSITE_SOFT_LIGHT_IFS_ILLUSIONS: i18nc("Blending mode - Soft Light (IFS Illusions)", "Soft Light (IFS Illusions)"),594 EKritaBlendingModesId.COMPOSITE_SOFT_LIGHT_PEGTOP_DELPHI: i18nc("Blending mode - Soft Light (Pegtop-Delphi)", "Soft Light (Pegtop-Delphi)"),595 EKritaBlendingModesId.COMPOSITE_SOFT_LIGHT_PHOTOSHOP: i18nc("Blending mode - Soft Light (Photoshop)", "Soft Light (Photoshop)"),596 EKritaBlendingModesId.COMPOSITE_SOFT_LIGHT_SVG: i18nc("Blending mode - Soft Light (SVG)", "Soft Light (SVG)"),597 EKritaBlendingModesId.COMPOSITE_GAMMA_LIGHT: i18nc("Blending mode - Gamma Light", "Gamma Light"),598 EKritaBlendingModesId.COMPOSITE_GAMMA_ILLUMINATION: i18nc("Blending mode - Gamma Illumination", "Gamma Illumination"),599 EKritaBlendingModesId.COMPOSITE_LIGHTER_COLOR: i18nc("Blending mode - Lighter Color", "Lighter Color"),600 EKritaBlendingModesId.COMPOSITE_PNORM_A: i18nc("Blending mode - P-Norm A", "P-Norm A"),601 EKritaBlendingModesId.COMPOSITE_PNORM_B: i18nc("Blending mode - P-Norm B", "P-Norm B"),602 EKritaBlendingModesId.COMPOSITE_SUPER_LIGHT: i18nc("Blending mode - Super Light", "Super Light"),603 EKritaBlendingModesId.COMPOSITE_TINT_IFS_ILLUSIONS: i18nc("Blending mode - Tint (IFS Illusions)", "Tint (IFS Illusions)"),604 EKritaBlendingModesId.COMPOSITE_FOG_LIGHTEN_IFS_ILLUSIONS: i18nc("Blending mode - Fog Lighten (IFS Illusions)", "Fog Lighten (IFS Illusions)"),605 EKritaBlendingModesId.COMPOSITE_EASY_DODGE: i18nc("Blending mode - Easy Dodge", "Easy Dodge"),606 EKritaBlendingModesId.COMPOSITE_LUMINOSITY_SAI: i18nc("Blending mode - Luminosity/Shine (SAI)", "Luminosity/Shine (SAI)"),607 EKritaBlendingModesId.COMPOSITE_MOD: i18nc("Blending mode - Modulo", "Modulo"),608 EKritaBlendingModesId.COMPOSITE_MOD_CON: i18nc("Blending mode - Modulo - Continuous", "Modulo - Continuous"),609 EKritaBlendingModesId.COMPOSITE_DIVISIVE_MOD: i18nc("Blending mode - Divisive Modulo", "Divisive Modulo"),610 EKritaBlendingModesId.COMPOSITE_DIVISIVE_MOD_CON: i18nc("Blending mode - Divisive Modulo - Continuous", "Divisive Modulo - Continuous"),611 EKritaBlendingModesId.COMPOSITE_MODULO_SHIFT: i18nc("Blending mode - Modulo Shift", "Modulo Shift"),612 EKritaBlendingModesId.COMPOSITE_MODULO_SHIFT_CON: i18nc("Blending mode - Modulo Shift - Continuous", "Modulo Shift - Continuous"),613 EKritaBlendingModesId.COMPOSITE_DIFF: i18nc("Blending mode - Difference", "Difference"),614 EKritaBlendingModesId.COMPOSITE_EQUIVALENCE: i18nc("Blending mode - Equivalence", "Equivalence"),615 EKritaBlendingModesId.COMPOSITE_ADDITIVE_SUBTRACTIVE: i18nc("Blending mode - Additive Subtractive", "Additive Subtractive"),616 EKritaBlendingModesId.COMPOSITE_EXCLUSION: i18nc("Blending mode - Exclusion", "Exclusion"),617 EKritaBlendingModesId.COMPOSITE_ARC_TANGENT: i18nc("Blending mode - Arcus Tangent", "Arcus Tangent"),618 EKritaBlendingModesId.COMPOSITE_NEGATION: i18nc("Blending mode - Negation", "Negation"),619 EKritaBlendingModesId.COMPOSITE_OVER: i18nc("Blending mode - Normal", "Normal"),620 EKritaBlendingModesId.COMPOSITE_BEHIND: i18nc("Blending mode - Behind", "Behind"),621 EKritaBlendingModesId.COMPOSITE_GREATER: i18nc("Blending mode - Greater", "Greater"),622 EKritaBlendingModesId.COMPOSITE_OVERLAY: i18nc("Blending mode - Overlay", "Overlay"),623 EKritaBlendingModesId.COMPOSITE_ERASE: i18nc("Blending mode - Erase", "Erase"),624 EKritaBlendingModesId.COMPOSITE_ALPHA_DARKEN: i18nc("Blending mode - Alpha Darken", "Alpha Darken"),625 EKritaBlendingModesId.COMPOSITE_HARD_MIX: i18nc("Blending mode - Hard Mix", "Hard Mix"),626 EKritaBlendingModesId.COMPOSITE_HARD_MIX_PHOTOSHOP: i18nc("Blending mode - Hard Mix (Photoshop)", "Hard Mix (Photoshop)"),627 EKritaBlendingModesId.COMPOSITE_HARD_MIX_SOFTER_PHOTOSHOP: i18nc("Blending mode - Hard Mix Softer (Photoshop)", "Hard Mix Softer (Photoshop)"),628 EKritaBlendingModesId.COMPOSITE_GRAIN_MERGE: i18nc("Blending mode - Grain Merge", "Grain Merge"),629 EKritaBlendingModesId.COMPOSITE_GRAIN_EXTRACT: i18nc("Blending mode - Grain Extract", "Grain Extract"),630 EKritaBlendingModesId.COMPOSITE_PARALLEL: i18nc("Blending mode - Parallel", "Parallel"),631 EKritaBlendingModesId.COMPOSITE_ALLANON: i18nc("Blending mode - Allanon", "Allanon"),632 EKritaBlendingModesId.COMPOSITE_GEOMETRIC_MEAN: i18nc("Blending mode - Geometric Mean", "Geometric Mean"),633 EKritaBlendingModesId.COMPOSITE_DESTINATION_ATOP: i18nc("Blending mode - Destination Atop", "Destination Atop"),634 EKritaBlendingModesId.COMPOSITE_DESTINATION_IN: i18nc("Blending mode - Destination In", "Destination In"),635 EKritaBlendingModesId.COMPOSITE_HARD_OVERLAY: i18nc("Blending mode - Hard Overlay", "Hard Overlay"),636 EKritaBlendingModesId.COMPOSITE_INTERPOLATION: i18nc("Blending mode - Interpolation", "Interpolation"),637 EKritaBlendingModesId.COMPOSITE_INTERPOLATIONB: i18nc("Blending mode - Interpolation - 2X", "Interpolation - 2X"),638 EKritaBlendingModesId.COMPOSITE_PENUMBRAA: i18nc("Blending mode - Penumbra A", "Penumbra A"),639 EKritaBlendingModesId.COMPOSITE_PENUMBRAB: i18nc("Blending mode - Penumbra B", "Penumbra B"),640 EKritaBlendingModesId.COMPOSITE_PENUMBRAC: i18nc("Blending mode - Penumbra C", "Penumbra C"),641 EKritaBlendingModesId.COMPOSITE_PENUMBRAD: i18nc("Blending mode - Penumbra D", "Penumbra D"),642 EKritaBlendingModesId.COMPOSITE_BUMPMAP: i18nc("Blending mode - Bumpmap", "Bumpmap"),643 EKritaBlendingModesId.COMPOSITE_COMBINE_NORMAL: i18nc("Blending mode - Combine Normal Map", "Combine Normal Map"),644 EKritaBlendingModesId.COMPOSITE_DISSOLVE: i18nc("Blending mode - Dissolve", "Dissolve"),645 EKritaBlendingModesId.COMPOSITE_COPY_RED: i18nc("Blending mode - Copy Red", "Copy Red"),646 EKritaBlendingModesId.COMPOSITE_COPY_GREEN: i18nc("Blending mode - Copy Green", "Copy Green"),647 EKritaBlendingModesId.COMPOSITE_COPY_BLUE: i18nc("Blending mode - Copy Blue", "Copy Blue"),648 EKritaBlendingModesId.COMPOSITE_COPY: i18nc("Blending mode - Copy", "Copy"),649 EKritaBlendingModesId.COMPOSITE_TANGENT_NORMALMAP: i18nc("Blending mode - Tangent Normalmap", "Tangent Normalmap"),650 EKritaBlendingModesId.COMPOSITE_COLOR: i18nc("Blending mode - Color HSY", "Color"),651 EKritaBlendingModesId.COMPOSITE_HUE: i18nc("Blending mode - Hue HSY", "Hue"),652 EKritaBlendingModesId.COMPOSITE_SATURATION: i18nc("Blending mode - Saturation HSY", "Saturation"),653 EKritaBlendingModesId.COMPOSITE_LUMINIZE: i18nc("Blending mode - Luminosity HSY", "Luminosity"),654 EKritaBlendingModesId.COMPOSITE_DEC_SATURATION: i18nc("Blending mode - Decrease Saturation HSY", "Decrease Saturation"),655 EKritaBlendingModesId.COMPOSITE_INC_SATURATION: i18nc("Blending mode - Increase Saturation HSY", "Increase Saturation"),656 EKritaBlendingModesId.COMPOSITE_DEC_LUMINOSITY: i18nc("Blending mode - Decrease Luminosity HSY", "Decrease Luminosity"),657 EKritaBlendingModesId.COMPOSITE_INC_LUMINOSITY: i18nc("Blending mode - Increase Luminosity HSY", "Increase Luminosity"),658 EKritaBlendingModesId.COMPOSITE_COLOR_HSI: i18nc("Blending mode - Color HSI", "Color HSI"),659 EKritaBlendingModesId.COMPOSITE_HUE_HSI: i18nc("Blending mode - Hue HSI", "Hue HSI"),660 EKritaBlendingModesId.COMPOSITE_SATURATION_HSI: i18nc("Blending mode - Saturation HSI", "Saturation HSI"),661 EKritaBlendingModesId.COMPOSITE_INTENSITY: i18nc("Blending mode - Intensity HSI", "Intensity"),662 EKritaBlendingModesId.COMPOSITE_DEC_SATURATION_HSI: i18nc("Blending mode - Decrease Saturation HSI", "Decrease Saturation HSI"),663 EKritaBlendingModesId.COMPOSITE_INC_SATURATION_HSI: i18nc("Blending mode - Increase Saturation HSI", "Increase Saturation HSI"),664 EKritaBlendingModesId.COMPOSITE_DEC_INTENSITY: i18nc("Blending mode - Decrease Intensity", "Decrease Intensity"),665 EKritaBlendingModesId.COMPOSITE_INC_INTENSITY: i18nc("Blending mode - Increase Intensity", "Increase Intensity"),666 EKritaBlendingModesId.COMPOSITE_COLOR_HSL: i18nc("Blending mode - Color HSL", "Color HSL"),667 EKritaBlendingModesId.COMPOSITE_HUE_HSL: i18nc("Blending mode - Hue HSL", "Hue HSL"),668 EKritaBlendingModesId.COMPOSITE_SATURATION_HSL: i18nc("Blending mode - Saturation HSL", "Saturation HSL"),669 EKritaBlendingModesId.COMPOSITE_LIGHTNESS: i18nc("Blending mode - Lightness HSI", "Lightness"),670 EKritaBlendingModesId.COMPOSITE_DEC_SATURATION_HSL: i18nc("Blending mode - Decrease Saturation HSL", "Decrease Saturation HSL"),671 EKritaBlendingModesId.COMPOSITE_INC_SATURATION_HSL: i18nc("Blending mode - Increase Saturation HSL", "Increase Saturation HSL"),672 EKritaBlendingModesId.COMPOSITE_DEC_LIGHTNESS: i18nc("Blending mode - Decrease Lightness", "Decrease Lightness"),673 EKritaBlendingModesId.COMPOSITE_INC_LIGHTNESS: i18nc("Blending mode - Increase Lightness", "Increase Lightness"),674 EKritaBlendingModesId.COMPOSITE_COLOR_HSV: i18nc("Blending mode - Color HSV", "Color HSV"),675 EKritaBlendingModesId.COMPOSITE_HUE_HSV: i18nc("Blending mode - Hue HSV", "Hue HSV"),676 EKritaBlendingModesId.COMPOSITE_SATURATION_HSV: i18nc("Blending mode - Saturation HSV", "Saturation HSV"),677 EKritaBlendingModesId.COMPOSITE_VALUE: i18nc("Blending mode - Value HSV", "Value"),678 EKritaBlendingModesId.COMPOSITE_DEC_SATURATION_HSV: i18nc("Blending mode - Decrease Saturation HSV", "Decrease Saturation HSV"),679 EKritaBlendingModesId.COMPOSITE_INC_SATURATION_HSV: i18nc("Blending mode - Increase Saturation HSV", "Increase Saturation HSV"),680 EKritaBlendingModesId.COMPOSITE_DEC_VALUE: i18nc("Blending mode - Decrease Value HSV", "Decrease Value"),681 EKritaBlendingModesId.COMPOSITE_INC_VALUE: i18nc("Blending mode - Increase Value HSV", "Increase Value"),682 EKritaBlendingModesId.COMPOSITE_REFLECT: i18nc("Blending mode - Reflect", "Reflect"),683 EKritaBlendingModesId.COMPOSITE_GLOW: i18nc("Blending mode - Glow", "Glow"),684 EKritaBlendingModesId.COMPOSITE_FREEZE: i18nc("Blending mode - Freeze", "Freeze"),685 EKritaBlendingModesId.COMPOSITE_HEAT: i18nc("Blending mode - Heat", "Heat"),686 EKritaBlendingModesId.COMPOSITE_GLEAT: i18nc("Blending mode - Glow-Heat", "Glow-Heat"),687 EKritaBlendingModesId.COMPOSITE_HELOW: i18nc("Blending mode - Heat-Glow", "Heat-Glow"),688 EKritaBlendingModesId.COMPOSITE_REEZE: i18nc("Blending mode - Reflect-Freeze", "Reflect-Freeze"),689 EKritaBlendingModesId.COMPOSITE_FRECT: i18nc("Blending mode - Freeze-Reflect", "Freeze-Reflect"),690 EKritaBlendingModesId.COMPOSITE_FHYRD: i18nc("Blending mode - Heat-Glow & Freeze-Reflect Hybrid", "Heat-Glow & Freeze-Reflect Hybrid")691 }692 @staticmethod693 def categoriesIdList():694 """Return list of available categories"""695 return list(EKritaBlendingModes.__CATEGORIES)696 @staticmethod697 def categoryName(id):698 """Return (translated) name for category"""699 if id is None:700 return i18n('None')701 elif id in EKritaBlendingModes.__CATEGORIES:702 return EKritaBlendingModes.__CATEGORIES[id]703 else:704 raise EInvalidValue("Given `id` is not valid")705 @staticmethod706 def categoryBlendingMode(id):707 """Return a list of blending mode Id for given category"""708 if id is None:709 return []710 elif id in EKritaBlendingModes.__CATEGORIES_BLENDING_MODES:711 return list(EKritaBlendingModes.__CATEGORIES_BLENDING_MODES[id])712 else:713 raise EInvalidValue("Given `id` is not valid")714 @staticmethod715 def blendingModeIdList():716 """Return list of available blending mode (without link to category)"""717 return list(EKritaBlendingModes.__BLENDING_MODES)718 @staticmethod719 def blendingModeName(id):720 """Return (translated) name for blending mode"""721 if id is None:722 return []723 elif id in EKritaBlendingModes.__BLENDING_MODES:724 return EKritaBlendingModes.__BLENDING_MODES[id]725 else:726 raise EInvalidValue("Given `id` is not valid")727class EKritaDocument:728 """Provides methods to manage Krita Documents"""729 @staticmethod730 def findLayerById(document, layerId):731 """Find a layer by ID in document732 because Document.nodeByUniqueID() returns a QObject instead of a Node object... :-/733 """734 def find(layerId, parentLayer):735 """sub function called recursively to search layer in document tree"""736 for layer in parentLayer.childNodes():737 if layerId == layer.uniqueId():738 return layer739 elif len(layer.childNodes()) > 0:740 returned = find(layerId, layer)741 if not returned is None:742 return returned743 return None744 if not isinstance(document, Document):745 raise EInvalidType("Given `document` must be a Krita <Document> type")746 elif not isinstance(layerId, QUuid):747 raise EInvalidType("Given `layerId` must be a valid <QUuid>")748 return find(layerId, document.rootNode())749 @staticmethod750 def findFirstLayerByName(searchFrom, layerName):751 """Find a layer by name in document752 If more than one layer is found in document layers tree, will return the first layer found753 If no layer is found, return None754 The `searchFrom` parameter can be:755 - A Krita Layer (in this case, search in made in sub-nodes)756 - A Krita Document (in this case, search is made from document root node)757 The `layerName` can be a regular expression; just provide layer name with the following form:758 - "re://my_regular_expression759 """760 def find(layerName, isRegex, parentLayer):761 """sub function called recursively to search layer in document tree"""762 for layer in reversed(parentLayer.childNodes()):763 if isRegex == False and layerName == layer.name():764 return layer765 elif isRegex == True and (reResult := re.match(layerName, layer.name())):766 return layer767 elif len(layer.childNodes()) > 0:768 returned = find(layerName, isRegex, layer)769 if not returned is None:770 return returned771 return None772 if not (isinstance(searchFrom, Document) or isinstance(searchFrom, Layer)):773 raise EInvalidType("Given `searchFrom` must be a Krita <Layer> or a Krita <Document> type")774 elif not isinstance(layerName, str):775 raise EInvalidType("Given `layerName` must be a valid <str>")776 parentLayer = searchFrom777 if isinstance(searchFrom, Document):778 # a document has been provided, use document root layer779 parentLayer = searchFrom.rootNode()780 if (reResult := re.match("^re://(.*)", layerName)):781 # retrieve given regular expression782 layerName = reResult.group(1)783 return find(layerName, True, parentLayer)784 else:785 return find(layerName, False, parentLayer)786 return None787 @staticmethod788 def findLayersByName(searchFrom, layerName):789 """Find layer(s) by name790 Return a list of all layers for which name is matching given layer name791 If no layer is found, return empty list792 The `searchFrom` parameter can be:793 - A Krita Layer (in this case, search in made in sub-nodes)794 - A Krita Document (in this case, search is made from document root node)795 The `layerName` can be a regular expression; just provide layer name with the following form:796 - "re://my_regular_expression797 """798 def find(layerName, isRegex, parentLayer):799 """sub function called recursively to search layer in document tree"""800 returned=[]801 for layer in reversed(parentLayer.childNodes()):802 if isRegex == False and layerName == layer.name():803 returned.append(layer)804 elif isRegex == True and (reResult := re.match(layerName, layer.name())):805 returned.append(layer)806 elif len(layer.childNodes()) > 0:807 found = find(layerName, isRegex, layer)808 if not found is None:809 returned+=found810 return returned811 if not (isinstance(searchFrom, Document) or isinstance(searchFrom, Layer)):812 raise EInvalidType("Given `searchFrom` must be a Krita <Layer> or a Krita <Document> type")813 elif not isinstance(layerName, str):814 raise EInvalidType("Given `layerName` must be a valid <str> (current: {0})".format(type(layerName)))815 parentLayer = searchFrom816 if isinstance(searchFrom, Document):817 # a document has been provided, use document root layer818 parentLayer = searchFrom.rootNode()819 if (reResult := re.match("^re://(.*)", layerName)):820 # retrieve given regular expression821 layerName = reResult.group(1)822 return find(layerName, True, parentLayer)823 else:824 return find(layerName, False, parentLayer)825 return []826 @staticmethod827 def getLayers(searchFrom, recursiveSubLayers=False):828 """Return a list of all layers829 The `searchFrom` parameter can be:830 - A Krita Layer (in this case, return all sub-nodes from given layer)831 - A Krita Document (in this case, return all sub-nodes from document root node)832 If `recursiveSubLayers` is True, also return all subLayers833 """834 def find(recursiveSubLayers, parentLayer):835 """sub function called recursively to search layer in document tree"""836 returned=[]837 for layer in reversed(parentLayer.childNodes()):838 returned.append(layer)839 if recursiveSubLayers and len(layer.childNodes()) > 0:840 found = find(recursiveSubLayers, layer)841 if not found is None:842 returned+=found843 return returned844 if not (isinstance(searchFrom, Document) or isinstance(searchFrom, Layer)):845 raise EInvalidType("Given `searchFrom` must be a Krita <Layer> or a Krita <Document> type")846 elif not isinstance(recursiveSubLayers, bool):847 raise EInvalidType("Given `recursiveSubLayers` must be a <bool>")848 parentLayer = searchFrom849 if isinstance(searchFrom, Document):850 # a document has been provided, use document root layer851 parentLayer = searchFrom.rootNode()852 return find(recursiveSubLayers, parentLayer)853 @staticmethod854 def getLayerFromPath(searchFrom, path):855 """Return a layer from given path856 If no layer is found, return None857 The `searchFrom` parameter can be:858 - A Krita Document (in this case, return all sub-nodes from document root node)859 """860 def find(pathNodes, level, parentLayer):861 """sub function called recursively to search layer in document tree"""862 for layer in reversed(parentLayer.childNodes()):863 if layer.name() == pathNodes[level]:864 if level == len(pathNodes) - 1:865 return layer866 elif len(layer.childNodes()) > 0:867 return find(pathNodes, level + 1, layer)868 return None869 if not isinstance(searchFrom, Document):870 raise EInvalidType("Given `searchFrom` must be a Krita <Document> type")871 elif not isinstance(path, str):872 raise EInvalidType("Given `path` must be a <str>")873 pathNodes = re.findall(r'(?:[^/"]|"(?:\\.|[^"])*")+', path)874 if not pathNodes is None:875 pathNodes = [re.sub(r'^"|"$', '', pathNode) for pathNode in pathNodes]876 return find(pathNodes, 0, searchFrom.rootNode())877class EKritaNode:878 """Provides methods to manage Krita Nodes"""879 class ProjectionMode(Enum):880 """Projection modes for toQImage(), toQPixmap()"""881 FALSE = 0882 TRUE = 1883 AUTO = 2884 __projectionMode = ProjectionMode.AUTO885 @staticmethod886 def __sleep(value):887 """Sleep for given number of milliseconds"""888 loop = QEventLoop()889 QTimer.singleShot(value, loop.quit)890 loop.exec()891 @staticmethod892 def path(layerNode):893 """Return `layerNode` path in tree894 Example895 =======896 rootnode897 +-- groupLayer1898 +-- groupLayer2899 +-- theNode900 +-- theNode with / character901 return '/groupLayer1/groupLayer2/theNode'902 return '/groupLayer1/groupLayer2/"theNode with / character"'903 """904 def parentPath(layerNode):905 if layerNode.parentNode() is None or layerNode.parentNode().parentNode() is None:906 return ''907 else:908 if '/' in layerNode.name():909 return f'{parentPath(layerNode.parentNode())}/"{layerNode.name()}"'910 else:911 return f'{parentPath(layerNode.parentNode())}/{layerNode.name()}'912 if not isinstance(layerNode, Node):913 raise EInvalidType("Given `layerNode` must be a valid Krita <Node> ")914 return parentPath(layerNode)915 @staticmethod916 def toQImage(layerNode, rect=None, projectionMode=None):917 """Return `layerNode` content as a QImage (as ARGB32)918 The `rect` value can be:919 - None, in this case will return all `layerNode` content920 - A QRect() object, in this case return `layerNode` content reduced to given rectangle bounds921 - A Krita document, in this case return `layerNode` content reduced to document bounds922 """923 if layerNode is None:924 raise EInvalidValue("Given `layerNode` can't be None")925 if type(layerNode)==QObject:926 #Â NOTE: layerNode can be a QObject...927 # that's weird, but document.nodeByUniqueID() return a QObject for a paintlayer (other Nodes seems to be Ok...)928 # it can sound strange but in this case the returned QObject is a QObject iwht Node properties929 # so, need to check if QObject have expected methods930 if hasattr(layerNode, 'type') and hasattr(layerNode, 'bounds') and hasattr(layerNode, 'childNodes') and hasattr(layerNode, 'colorModel') and hasattr(layerNode, 'colorDepth') and hasattr(layerNode, 'colorProfile') and hasattr(layerNode, 'setColorSpace') and hasattr(layerNode, 'setPixelData'):931 pass932 else:933 #Â consider that it's not a node934 raise EInvalidType("Given `layerNode` must be a valid Krita <Node> ")935 elif not isinstance(layerNode, Node):936 raise EInvalidType("Given `layerNode` must be a valid Krita <Node> ")937 if rect is None:938 rect = layerNode.bounds()939 elif isinstance(rect, Document):940 rect = rect.bounds()941 elif not isinstance(rect, QRect):942 raise EInvalidType("Given `rect` must be a valid Krita <Document>, a <QRect> or None")943 if projectionMode is None:944 projectionMode = EKritaNode.__projectionMode945 if projectionMode == EKritaNode.ProjectionMode.AUTO:946 childNodes=layerNode.childNodes()947 # childNodes can return be None!?948 if childNodes and len(childNodes) == 0:949 projectionMode = EKritaNode.ProjectionMode.FALSE950 else:951 projectionMode = EKritaNode.ProjectionMode.TRUE952 # Need to check what todo for:953 # - masks (8bit/pixels)954 # - other color space (need to convert to 8bits/rgba...?)955 if (layerNode.type() in ('transparencymask', 'filtermask', 'transformmask', 'selectionmask') or956 layerNode.colorModel() != 'RGBA' or957 layerNode.colorDepth() != 'U8'):958 # pixelData/projectionPixelData return a 8bits/pixel matrix959 # didn't find how to convert pixel data to QImlage then use thumbnail() function960 return layerNode.thumbnail(rect.width(), rect.height())961 else:962 if projectionMode == EKritaNode.ProjectionMode.TRUE:963 return QImage(layerNode.projectionPixelData(rect.left(), rect.top(), rect.width(), rect.height()), rect.width(), rect.height(), QImage.Format_ARGB32)964 else:965 return QImage(layerNode.pixelData(rect.left(), rect.top(), rect.width(), rect.height()), rect.width(), rect.height(), QImage.Format_ARGB32)966 @staticmethod967 def toQPixmap(layerNode, rect=None, projectionMode=None):968 """Return `layerNode` content as a QPixmap (as ARGB32)969 If the `projection` value is True, returned :970 The `rect` value can be:971 - None, in this case will return all `layerNode` content972 - A QRect() object, in this case return `layerNode` content reduced to given rectangle bounds973 - A Krita document, in this case return `layerNode` content reduced to document bounds974 """975 return QPixmap.fromImage(EKritaNode.toQImage(layerNode, rect, projectionMode))976 @staticmethod977 def fromQImage(layerNode, image, position=None):978 """Paste given `image` to `position` in '`layerNode`979 The `position` value can be:980 - None, in this case, pixmap will be pasted at position (0, 0)981 - A QPoint() object, pixmap will be pasted at defined position982 """983 #Â NOTE: layerNode can be a QObject...984 # that's weird, but document.nodeByUniqueID() return a QObject for a paintlayer (other Nodes seems to be Ok...)985 # it can sound strange but in this case the returned QObject is a QObject iwht Node properties986 # so, need to check if QObject have expected methods987 if type(layerNode)==QObject():988 if hasattr(layerNode, 'type') and hasattr(layerNode, 'colorModel') and hasattr(layerNode, 'colorDepth') and hasattr(layerNode, 'colorProfile') and hasattr(layerNode, 'setColorSpace') and hasattr(layerNode, 'setPixelData'):989 pass990 else:991 #Â consider that it's not a node992 raise EInvalidType("Given `layerNode` must be a valid Krita <Node> ")993 elif not isinstance(layerNode, Node):994 raise EInvalidType("Given `layerNode` must be a valid Krita <Node> ")995 if not isinstance(image, QImage):996 raise EInvalidType("Given `image` must be a valid <QImage> ")997 if position is None:998 position = QPoint(0, 0)999 if not isinstance(position, QPoint):1000 raise EInvalidType("Given `position` must be a valid <QPoint> ")1001 layerNeedBackConversion=False1002 layerColorModel=layerNode.colorModel()1003 layerColorDepth=layerNode.colorDepth()1004 layerColorProfile=layerNode.colorProfile()1005 if layerColorModel != "RGBA" or layerColorDepth != 'U8':1006 # we need to convert layer to RGBA/U81007 layerNode.setColorSpace("RGBA", "U8", "sRGB-elle-V2-srgbtrc.icc")1008 layerNeedBackConversion=True1009 ptr = image.bits()1010 ptr.setsize(image.byteCount())1011 layerNode.setPixelData(QByteArray(ptr.asstring()), position.x(), position.y(), image.width(), image.height())1012 if layerNeedBackConversion:1013 layerNode.setColorSpace(layerColorModel, layerColorDepth, layerColorProfile)1014 @staticmethod1015 def fromQPixmap(layerNode, pixmap, position=None):1016 """Paste given `pixmap` to `position` in '`layerNode`1017 The `position` value can be:1018 - None, in this case, pixmap will be pasted at position (0, 0)1019 - A QPoint() object, pixmap will be pasted at defined position1020 """1021 if not isinstance(pixmap, QPixmap):1022 raise EInvalidType("Given `pixmap` must be a valid <QPixmap> ")1023 if position is None:1024 position = QPoint(0, 0)1025 EKritaNode.fromQImage(layerNode, pixmap.toImage(), position)1026 @staticmethod1027 def fromSVG(layerNode, svgContent, document=None):1028 """Paste given `svgContent` to `position` in '`layerNode`1029 Given `layerNode` must be a 'vectorlayer'1030 The `position` value can be:1031 - None, in this case, pixmap will be pasted at position (0, 0)1032 - A QPoint() object, pixmap will be pasted at defined position1033 Note:1034 - If document is None, consider that active document contains layer1035 - If document is provided, it must contains layerNode1036 Method return a list of shapes (shape inserted into layer)1037 """1038 if isinstance(svgContent, str):1039 svgContent=svgContent.encode()1040 if not isinstance(svgContent, bytes):1041 raise EInvalidType("Given `svgContent` must be a valid <str> or <bytes> SVG document")1042 if not isinstance(layerNode, Node) or layerNode.type()!='vectorlayer':1043 raise EInvalidType("Given `layerNode` must be a valid <VectorLayer>")1044 if document is None:1045 document=Krita.instance().activeDocument()1046 if not isinstance(document, Document):1047 raise EInvalidType("Given `layerNode` must be a valid <Document>")1048 shapes=[shape for shape in layerNode.shapes()]1049 activeNode=document.activeNode()1050 document.setActiveNode(layerNode)1051 document.waitForDone()1052 # Note: following sleep() is here because waitForDone() doesn't seems to1053 # wait for active node changed...1054 # set an arbitrary sleep() delay allows to ensure that node is active1055 # at the end of method execution1056 # hope current delay is not too short (works for me... but can't put1057 # a too long delay)1058 #1059 # Problem occurs with krita 4.4.2 & and tested Krita plus/next tested [2020-01-05]1060 EKritaNode.__sleep(100)1061 mimeContent=QMimeData()1062 mimeContent.setData('image/svg', svgContent)1063 mimeContent.setData('BCIGNORE', b'')1064 QGuiApplication.clipboard().setMimeData(mimeContent)1065 Krita.instance().action('edit_paste').trigger()1066 newShapes=[shape for shape in layerNode.shapes() if not shape in shapes]1067 return newShapes1068 @staticmethod1069 def above(layerNode):1070 """Return node above given `layerNode`1071 If there's no node above given layer, return None"""1072 if layerNode is None:1073 return None1074 if not isinstance(layerNode, Node):1075 raise EInvalidType("Given `layerNode` must be a valid Krita <Node> ")1076 returnNext = False1077 for layer in layerNode.parentNode().childNodes():1078 if returnNext:1079 return layer1080 elif layer == layerNode:1081 returnNext = True1082 return None1083 @staticmethod1084 def below(layerNode):1085 """Return node below given `layerNode`1086 If there's no node below given layer, return None"""1087 if layerNode is None:1088 return None1089 if not isinstance(layerNode, Node):1090 raise EInvalidType("Given `layerNode` must be a valid Krita <Node> ")1091 prevNode = None1092 for layer in layerNode.parentNode().childNodes():1093 if layer == layerNode:1094 return prevNode1095 prevNode = layer...
layers_pb2.py
Source:layers_pb2.py
1# -*- coding: utf-8 -*-2# Generated by the protocol buffer compiler. DO NOT EDIT!3# source: layers.proto4"""Generated protocol buffer code."""5from google.protobuf import descriptor as _descriptor6from google.protobuf import descriptor_pool as _descriptor_pool7from google.protobuf import message as _message8from google.protobuf import reflection as _reflection9from google.protobuf import symbol_database as _symbol_database10# @@protoc_insertion_point(imports)11_sym_db = _symbol_database.Default()12import hotKey_pb2 as hotKey__pb213import effects_pb2 as effects__pb214import basicTypes_pb2 as basicTypes__pb215DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0clayers.proto\x12\x07rv.data\x1a\x0chotKey.proto\x1a\reffects.proto\x1a\x10\x62\x61sicTypes.proto\"\x9d\x13\n\x05Layer\x12\x1b\n\x04uuid\x18\x01 \x01(\x0b\x32\r.rv.data.UUID\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x1d\n\x05\x63olor\x18\x03 \x01(\x0b\x32\x0e.rv.data.Color\x12\r\n\x05muted\x18\x04 \x01(\x08\x12\x0e\n\x06hidden\x18\x05 \x01(\x08\x12,\n\nblend_mode\x18\x06 \x01(\x0e\x32\x18.rv.data.Layer.BlendMode\x12\x0f\n\x07opacity\x18\x07 \x01(\x01\x12/\n\x18selected_target_set_uuid\x18\x08 \x01(\x0b\x32\r.rv.data.UUID\x12*\n\x13\x65\x66\x66\x65\x63ts_preset_uuid\x18\t \x01(\x0b\x32\r.rv.data.UUID\x12\x1e\n\x16\x65\x66\x66\x65\x63ts_build_duration\x18\n \x01(\x01\x12(\n\x11layer_preset_uuid\x18\x0b \x01(\x0b\x32\r.rv.data.UUID\x12 \n\x07hot_key\x18\x0c \x01(\x0b\x32\x0f.rv.data.HotKey\x12\'\n\ntransition\x18\r \x01(\x0b\x32\x13.rv.data.Transition\x12 \n\x07\x65\x66\x66\x65\x63ts\x18\x0e \x03(\x0b\x32\x0f.rv.data.Effect\x12&\n\x05\x62lend\x18\x0f \x01(\x0b\x32\x17.rv.data.Layer.Blending\x1aR\n\x06Preset\x12\x1b\n\x04uuid\x18\x01 \x01(\x0b\x32\r.rv.data.UUID\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x1d\n\x05layer\x18\x03 \x01(\x0b\x32\x0e.rv.data.Layer\x1a\x94\t\n\x08\x42lending\x12\x34\n\x08standard\x18\x01 \x01(\x0b\x32 .rv.data.Layer.Blending.StandardH\x00\x12.\n\x05matte\x18\x02 \x01(\x0b\x32\x1d.rv.data.Layer.Blending.MatteH\x00\x1a\x9c\x06\n\x08Standard\x12\x38\n\x04mode\x18\x01 \x01(\x0e\x32*.rv.data.Layer.Blending.Standard.BlendMode\x12\x0f\n\x07opacity\x18\x02 \x01(\x01\"\xc4\x05\n\tBlendMode\x12\x15\n\x11\x42LEND_MODE_NORMAL\x10\x00\x12\x17\n\x13\x42LEND_MODE_DISSOLVE\x10\x01\x12\x15\n\x11\x42LEND_MODE_DARKEN\x10\x02\x12\x17\n\x13\x42LEND_MODE_MULTIPLY\x10\x03\x12\x19\n\x15\x42LEND_MODE_COLOR_BURN\x10\x04\x12\x1a\n\x16\x42LEND_MODE_LINEAR_BURN\x10\x05\x12\x1b\n\x17\x42LEND_MODE_DARKER_COLOR\x10\x06\x12\x16\n\x12\x42LEND_MODE_LIGHTEN\x10\x07\x12\x15\n\x11\x42LEND_MODE_SCREEN\x10\x08\x12\x1a\n\x16\x42LEND_MODE_COLOR_DODGE\x10\t\x12\x1b\n\x17\x42LEND_MODE_LINEAR_DODGE\x10\n\x12\x1c\n\x18\x42LEND_MODE_LIGHTER_COLOR\x10\x0b\x12\x16\n\x12\x42LEND_MODE_OVERLAY\x10\x0c\x12\x19\n\x15\x42LEND_MODE_SOFT_LIGHT\x10\r\x12\x19\n\x15\x42LEND_MODE_HARD_LIGHT\x10\x0e\x12\x1a\n\x16\x42LEND_MODE_VIVID_LIGHT\x10\x0f\x12\x1b\n\x17\x42LEND_MODE_LINEAR_LIGHT\x10\x10\x12\x18\n\x14\x42LEND_MODE_PIN_LIGHT\x10\x11\x12\x17\n\x13\x42LEND_MODE_HARD_MIX\x10\x12\x12\x19\n\x15\x42LEND_MODE_DIFFERENCE\x10\x13\x12\x18\n\x14\x42LEND_MODE_EXCLUSION\x10\x14\x12\x17\n\x13\x42LEND_MODE_SUBTRACT\x10\x15\x12\x15\n\x11\x42LEND_MODE_DIVIDE\x10\x16\x12\x12\n\x0e\x42LEND_MODE_HUE\x10\x17\x12\x19\n\x15\x42LEND_MODE_SATURATION\x10\x18\x12\x14\n\x10\x42LEND_MODE_COLOR\x10\x19\x12\x19\n\x15\x42LEND_MODE_LUMINOSITY\x10\x1a\x1a\xf2\x01\n\x05Matte\x12\x34\n\x05\x61lpha\x18\x01 \x01(\x0b\x32#.rv.data.Layer.Blending.Matte.AlphaH\x00\x12\x32\n\x04luma\x18\x02 \x01(\x0b\x32\".rv.data.Layer.Blending.Matte.LumaH\x00\x12\x34\n\x05white\x18\x04 \x01(\x0b\x32#.rv.data.Layer.Blending.Matte.WhiteH\x00\x1a\x19\n\x05\x41lpha\x12\x10\n\x08inverted\x18\x01 \x01(\x08\x1a\x18\n\x04Luma\x12\x10\n\x08inverted\x18\x01 \x01(\x08\x1a\x07\n\x05WhiteB\x0b\n\tMatteTypeB\x0e\n\x0c\x42lendingType\"\xc4\x05\n\tBlendMode\x12\x15\n\x11\x42LEND_MODE_NORMAL\x10\x00\x12\x17\n\x13\x42LEND_MODE_DISSOLVE\x10\x01\x12\x15\n\x11\x42LEND_MODE_DARKEN\x10\x02\x12\x17\n\x13\x42LEND_MODE_MULTIPLY\x10\x03\x12\x19\n\x15\x42LEND_MODE_COLOR_BURN\x10\x04\x12\x1a\n\x16\x42LEND_MODE_LINEAR_BURN\x10\x05\x12\x1b\n\x17\x42LEND_MODE_DARKER_COLOR\x10\x06\x12\x16\n\x12\x42LEND_MODE_LIGHTEN\x10\x07\x12\x15\n\x11\x42LEND_MODE_SCREEN\x10\x08\x12\x1a\n\x16\x42LEND_MODE_COLOR_DODGE\x10\t\x12\x1b\n\x17\x42LEND_MODE_LINEAR_DODGE\x10\n\x12\x1c\n\x18\x42LEND_MODE_LIGHTER_COLOR\x10\x0b\x12\x16\n\x12\x42LEND_MODE_OVERLAY\x10\x0c\x12\x19\n\x15\x42LEND_MODE_SOFT_LIGHT\x10\r\x12\x19\n\x15\x42LEND_MODE_HARD_LIGHT\x10\x0e\x12\x1a\n\x16\x42LEND_MODE_VIVID_LIGHT\x10\x0f\x12\x1b\n\x17\x42LEND_MODE_LINEAR_LIGHT\x10\x10\x12\x18\n\x14\x42LEND_MODE_PIN_LIGHT\x10\x11\x12\x17\n\x13\x42LEND_MODE_HARD_MIX\x10\x12\x12\x19\n\x15\x42LEND_MODE_DIFFERENCE\x10\x13\x12\x18\n\x14\x42LEND_MODE_EXCLUSION\x10\x14\x12\x17\n\x13\x42LEND_MODE_SUBTRACT\x10\x15\x12\x15\n\x11\x42LEND_MODE_DIVIDE\x10\x16\x12\x12\n\x0e\x42LEND_MODE_HUE\x10\x17\x12\x19\n\x15\x42LEND_MODE_SATURATION\x10\x18\x12\x14\n\x10\x42LEND_MODE_COLOR\x10\x19\x12\x19\n\x15\x42LEND_MODE_LUMINOSITY\x10\x1a\x62\x06proto3')16_LAYER = DESCRIPTOR.message_types_by_name['Layer']17_LAYER_PRESET = _LAYER.nested_types_by_name['Preset']18_LAYER_BLENDING = _LAYER.nested_types_by_name['Blending']19_LAYER_BLENDING_STANDARD = _LAYER_BLENDING.nested_types_by_name['Standard']20_LAYER_BLENDING_MATTE = _LAYER_BLENDING.nested_types_by_name['Matte']21_LAYER_BLENDING_MATTE_ALPHA = _LAYER_BLENDING_MATTE.nested_types_by_name['Alpha']22_LAYER_BLENDING_MATTE_LUMA = _LAYER_BLENDING_MATTE.nested_types_by_name['Luma']23_LAYER_BLENDING_MATTE_WHITE = _LAYER_BLENDING_MATTE.nested_types_by_name['White']24_LAYER_BLENDING_STANDARD_BLENDMODE = _LAYER_BLENDING_STANDARD.enum_types_by_name['BlendMode']25_LAYER_BLENDMODE = _LAYER.enum_types_by_name['BlendMode']26Layer = _reflection.GeneratedProtocolMessageType('Layer', (_message.Message,), {27 'Preset' : _reflection.GeneratedProtocolMessageType('Preset', (_message.Message,), {28 'DESCRIPTOR' : _LAYER_PRESET,29 '__module__' : 'layers_pb2'30 # @@protoc_insertion_point(class_scope:rv.data.Layer.Preset)31 })32 ,33 'Blending' : _reflection.GeneratedProtocolMessageType('Blending', (_message.Message,), {34 'Standard' : _reflection.GeneratedProtocolMessageType('Standard', (_message.Message,), {35 'DESCRIPTOR' : _LAYER_BLENDING_STANDARD,36 '__module__' : 'layers_pb2'37 # @@protoc_insertion_point(class_scope:rv.data.Layer.Blending.Standard)38 })39 ,40 'Matte' : _reflection.GeneratedProtocolMessageType('Matte', (_message.Message,), {41 'Alpha' : _reflection.GeneratedProtocolMessageType('Alpha', (_message.Message,), {42 'DESCRIPTOR' : _LAYER_BLENDING_MATTE_ALPHA,43 '__module__' : 'layers_pb2'44 # @@protoc_insertion_point(class_scope:rv.data.Layer.Blending.Matte.Alpha)45 })46 ,47 'Luma' : _reflection.GeneratedProtocolMessageType('Luma', (_message.Message,), {48 'DESCRIPTOR' : _LAYER_BLENDING_MATTE_LUMA,49 '__module__' : 'layers_pb2'50 # @@protoc_insertion_point(class_scope:rv.data.Layer.Blending.Matte.Luma)51 })52 ,53 'White' : _reflection.GeneratedProtocolMessageType('White', (_message.Message,), {54 'DESCRIPTOR' : _LAYER_BLENDING_MATTE_WHITE,55 '__module__' : 'layers_pb2'56 # @@protoc_insertion_point(class_scope:rv.data.Layer.Blending.Matte.White)57 })58 ,59 'DESCRIPTOR' : _LAYER_BLENDING_MATTE,60 '__module__' : 'layers_pb2'61 # @@protoc_insertion_point(class_scope:rv.data.Layer.Blending.Matte)62 })63 ,64 'DESCRIPTOR' : _LAYER_BLENDING,65 '__module__' : 'layers_pb2'66 # @@protoc_insertion_point(class_scope:rv.data.Layer.Blending)67 })68 ,69 'DESCRIPTOR' : _LAYER,70 '__module__' : 'layers_pb2'71 # @@protoc_insertion_point(class_scope:rv.data.Layer)72 })73_sym_db.RegisterMessage(Layer)74_sym_db.RegisterMessage(Layer.Preset)75_sym_db.RegisterMessage(Layer.Blending)76_sym_db.RegisterMessage(Layer.Blending.Standard)77_sym_db.RegisterMessage(Layer.Blending.Matte)78_sym_db.RegisterMessage(Layer.Blending.Matte.Alpha)79_sym_db.RegisterMessage(Layer.Blending.Matte.Luma)80_sym_db.RegisterMessage(Layer.Blending.Matte.White)81if _descriptor._USE_C_DESCRIPTORS == False:82 DESCRIPTOR._options = None83 _LAYER._serialized_start=7384 _LAYER._serialized_end=253485 _LAYER_PRESET._serialized_start=56686 _LAYER_PRESET._serialized_end=64887 _LAYER_BLENDING._serialized_start=65188 _LAYER_BLENDING._serialized_end=182389 _LAYER_BLENDING_STANDARD._serialized_start=76690 _LAYER_BLENDING_STANDARD._serialized_end=156291 _LAYER_BLENDING_STANDARD_BLENDMODE._serialized_start=85492 _LAYER_BLENDING_STANDARD_BLENDMODE._serialized_end=156293 _LAYER_BLENDING_MATTE._serialized_start=156594 _LAYER_BLENDING_MATTE._serialized_end=180795 _LAYER_BLENDING_MATTE_ALPHA._serialized_start=173496 _LAYER_BLENDING_MATTE_ALPHA._serialized_end=175997 _LAYER_BLENDING_MATTE_LUMA._serialized_start=176198 _LAYER_BLENDING_MATTE_LUMA._serialized_end=178599 _LAYER_BLENDING_MATTE_WHITE._serialized_start=1787100 _LAYER_BLENDING_MATTE_WHITE._serialized_end=1794101 _LAYER_BLENDMODE._serialized_start=854102 _LAYER_BLENDMODE._serialized_end=1562...
blendomatic.py
Source:blendomatic.py
1# Copyright 2013-2019 the openage authors. See copying.md for legal info.2"""3Conversion for the terrain blending masks.4Those originate from blendomatic.dat.5For more information, see doc/media/blendomatic.md6"""7from math import sqrt8from struct import Struct, unpack_from9from ..log import dbg10from .dataformat.exportable import Exportable11from .dataformat.data_definition import DataDefinition12from .dataformat.struct_definition import StructDefinition13class BlendingTile:14 """15 One blending mask tile.16 The blendomatic stores many of those.17 """18 # pylint: disable=too-few-public-methods19 def __init__(self, row_data, width, height):20 self.row_data = row_data21 self.width = width22 self.height = height23 def get_picture_data(self):24 """25 Return a numpy array of image data for a blending tile.26 """27 import numpy28 tile_rows = list()29 for picture_row in self.row_data:30 tile_row_data = list()31 for alpha_data in picture_row:32 if alpha_data == -1:33 # draw full transparency34 alpha = 035 val = 036 else:37 if alpha_data == 128:38 alpha = 25539 val = 040 else:41 # original data contains 7-bit values only42 alpha = 12843 val = (127 - (alpha_data & 0x7f)) * 244 tile_row_data.append((val, val, val, alpha))45 tile_rows.append(tile_row_data)46 return numpy.array(tile_rows)47class BlendingMode:48 """49 One blending mode, which contains tiles that make up50 for all the influence directions possible.51 One mode is for example "ice" or "grass", i.e. the transition shape.52 """53 # pylint: disable=too-few-public-methods54 def __init__(self, idx, data_file, tile_count, header):55 """56 initialize one blending mode,57 consisting of multiple frames for all blending directions58 the bitmasks were used to decide whether this pixel has59 to be used for calculations.60 the alphamask is used to determine the alpha amount for blending.61 """62 # should be 2353 -> number of pixels (single alpha byte values)63 self.pxcount = header[0]64 # tile_flags = header[1:] # TODO what do they do?65 dbg("blending mode %d tiles have %d pixels", idx, self.pxcount)66 # as we draw in isometric tile format, this is the row count67 self.row_count = int(sqrt(self.pxcount)) + 1 # should be 4968 # alpha_masks_raw is an array of bytes that will draw 32 images,69 # which are bit masks.70 #71 # one of these masks also has 2353 pixels72 # the storage of the bit masks is 4*tilesize, here's why:73 #74 # 4 * 8bit * 2353 pixels = 75296 bitpixels75 # ==> 75296/(32 images) = 2353 bitpixel/image76 #77 # this means if we interprete the 75296 bitpixels as 32 images,78 # each of these images gets 2353 bit as data.79 # TODO: why 32 images? isn't that depending on tile_count?80 alpha_masks_raw = unpack_from("%dB" % (self.pxcount * 4),81 data_file.read(self.pxcount * 4))82 # list of alpha-mask tiles83 self.alphamasks = list()84 # draw mask tiles for this blending mode85 for _ in range(tile_count):86 pixels = unpack_from("%dB" % self.pxcount,87 data_file.read(self.pxcount))88 self.alphamasks.append(self.get_tile_from_data(pixels))89 bitvalues = list()90 for i in alpha_masks_raw:91 for b_id in range(7, -1, -1):92 # bitmask from 0b00000001 to 0b1000000093 bit_mask = 2 ** b_id94 bitvalues.append(i & bit_mask)95 # list of bit-mask tiles96 self.bitmasks = list()97 # TODO: is 32 really hardcoded?98 for i in range(32):99 pixels = bitvalues[i * self.pxcount:(i + 1) * self.pxcount]100 self.bitmasks.append(self.get_tile_from_data(pixels))101 def get_tile_from_data(self, data):102 """103 get the data pixels, interprete them in isometric tile format104 ....*....105 ..*****..106 *********107 ..*****..108 ....*.... like this, only bigger..109 we end up drawing the rhombus with 49 rows.110 the space indicated by . is added by the function.111 """112 half_row_count = self.row_count // 2113 tile_size = len(data)114 read_so_far = 0115 max_width = 0116 tilerows = list()117 for y_pos in range(self.row_count):118 if y_pos < half_row_count:119 # upper half of the tile120 # row i+1 has 4 more pixels than row i121 # another +1 for the middle one122 read_values = 1 + (4 * y_pos)123 else:124 # lower half of tile125 read_values = (((self.row_count * 2) - 1) -126 (4 * (y_pos - half_row_count)))127 if read_values > (tile_size - read_so_far):128 raise Exception("reading more bytes than tile has left")129 if read_values < 0:130 raise Exception("reading negative count: %d" % read_values)131 # grab the pixels out of the big list132 pixels = list(data[read_so_far:(read_so_far + read_values)])133 # how many empty pixels on the left before the real data begins134 space_count = self.row_count - 1 - (read_values // 2)135 # insert padding to the left and right (-1 for fully transparent)136 padding = ([-1] * space_count)137 pixels = padding + pixels + padding138 if len(pixels) > max_width:139 max_width = len(pixels)140 read_so_far += read_values141 tilerows.append(pixels)142 if read_so_far != tile_size:143 raise Exception("got leftover bytes: %d" % (tile_size - read_so_far))144 return BlendingTile(tilerows, max_width, self.row_count)145class Blendomatic(Exportable):146 """147 Represents the blendomatic.dat file.148 In it are multiple blending modes,149 which then contain multiple tiles.150 """151 name_struct = "blending_mode"152 name_struct_file = "blending_mode"153 struct_description = ("describes one blending mode, "154 "a blending transition shape "155 "between two different terrain types.")156 data_format = (157 (True, "blend_mode", "int32_t"),158 )159 # struct blendomatic_header {160 # unsigned int nr_blending_modes;161 # unsigned int nr_tiles;162 # };163 blendomatic_header = Struct("< I I")164 def __init__(self, fileobj):165 super().__init__()166 buf = fileobj.read(Blendomatic.blendomatic_header.size)167 self.header = Blendomatic.blendomatic_header.unpack_from(buf)168 blending_mode_count, tile_count = self.header169 dbg("%d blending modes, each %d tiles",170 blending_mode_count, tile_count)171 blending_mode = Struct("< I %dB" % (tile_count))172 self.blending_modes = list()173 for i in range(blending_mode_count):174 header_data = fileobj.read(blending_mode.size)175 bmode_header = blending_mode.unpack_from(header_data)176 new_mode = BlendingMode(i, fileobj, tile_count, bmode_header)177 self.blending_modes.append(new_mode)178 fileobj.close()179 def get_textures(self):180 """181 generate a list of textures.182 one atlas per blending mode is generated,183 each atlas contains all blending masks merged on one texture184 """185 from .texture import Texture186 return [Texture(b_mode) for b_mode in self.blending_modes]187 def dump(self, filename):188 data = [189 {"blend_mode": idx}190 for idx, _ in enumerate(self.blending_modes)191 ]192 return [DataDefinition(self, data, filename)]193 @classmethod194 def structs(cls):195 return [StructDefinition(cls)]196 def save(self, fslikeobj, path, save_format):197 """198 Save the blending mask textures to disk.199 """200 for idx, texture in enumerate(self.get_textures()):201 name = "mode%02d.png" % idx202 dbg("saving blending mode %02d texture -> %s", idx, name)203 texture.save(fslikeobj, path + '/' + name, save_format)204 dbg("blending masks successfully exported")205 def __str__(self):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!