Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/openpyxl/drawing/effect.py: 76%

209 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2023-07-17 14:22 -0600

1# Copyright (c) 2010-2022 openpyxl 

2 

3from openpyxl.descriptors.serialisable import Serialisable 

4from openpyxl.descriptors import ( 

5 Typed, 

6 String, 

7 Set, 

8 Bool, 

9 Integer, 

10 NoneSet, 

11 Float, 

12) 

13 

14 

15from .colors import ColorChoice 

16 

17 

18class TintEffect(Serialisable): 

19 

20 tagname = "tint" 

21 

22 hue = Integer() 

23 amt = Integer() 

24 

25 def __init__(self, 

26 hue=0, 

27 amt=0, 

28 ): 

29 self.hue = hue 

30 self.amt = amt 

31 

32 

33class LuminanceEffect(Serialisable): 

34 

35 tagname = "lum" 

36 

37 bright = Integer() #Pct ? 

38 contrast = Integer() #Pct# 

39 

40 def __init__(self, 

41 bright=0, 

42 contrast=0, 

43 ): 

44 self.bright = bright 

45 self.contrast = contrast 

46 

47 

48class HSLEffect(Serialisable): 

49 

50 hue = Integer() 

51 sat = Integer() 

52 lum = Integer() 

53 

54 def __init__(self, 

55 hue=None, 

56 sat=None, 

57 lum=None, 

58 ): 

59 self.hue = hue 

60 self.sat = sat 

61 self.lum = lum 

62 

63 

64class GrayscaleEffect(Serialisable): 

65 

66 tagname = "grayscl" 

67 

68 

69class FillOverlayEffect(Serialisable): 

70 

71 blend = Set(values=(['over', 'mult', 'screen', 'darken', 'lighten'])) 

72 

73 def __init__(self, 

74 blend=None, 

75 ): 

76 self.blend = blend 

77 

78 

79class DuotoneEffect(Serialisable): 

80 

81 pass 

82 

83class ColorReplaceEffect(Serialisable): 

84 

85 pass 

86 

87class Color(Serialisable): 

88 

89 pass 

90 

91class ColorChangeEffect(Serialisable): 

92 

93 useA = Bool(allow_none=True) 

94 clrFrom = Typed(expected_type=Color, ) 

95 clrTo = Typed(expected_type=Color, ) 

96 

97 def __init__(self, 

98 useA=None, 

99 clrFrom=None, 

100 clrTo=None, 

101 ): 

102 self.useA = useA 

103 self.clrFrom = clrFrom 

104 self.clrTo = clrTo 

105 

106 

107class BlurEffect(Serialisable): 

108 

109 rad = Float() 

110 grow = Bool(allow_none=True) 

111 

112 def __init__(self, 

113 rad=None, 

114 grow=None, 

115 ): 

116 self.rad = rad 

117 self.grow = grow 

118 

119 

120class BiLevelEffect(Serialisable): 

121 

122 thresh = Integer() 

123 

124 def __init__(self, 

125 thresh=None, 

126 ): 

127 self.thresh = thresh 

128 

129 

130class AlphaReplaceEffect(Serialisable): 

131 

132 a = Integer() 

133 

134 def __init__(self, 

135 a=None, 

136 ): 

137 self.a = a 

138 

139 

140class AlphaModulateFixedEffect(Serialisable): 

141 

142 amt = Integer() 

143 

144 def __init__(self, 

145 amt=None, 

146 ): 

147 self.amt = amt 

148 

149 

150class EffectContainer(Serialisable): 

151 

152 type = Set(values=(['sib', 'tree'])) 

153 name = String(allow_none=True) 

154 

155 def __init__(self, 

156 type=None, 

157 name=None, 

158 ): 

159 self.type = type 

160 self.name = name 

161 

162 

163class AlphaModulateEffect(Serialisable): 

164 

165 cont = Typed(expected_type=EffectContainer, ) 

166 

167 def __init__(self, 

168 cont=None, 

169 ): 

170 self.cont = cont 

171 

172 

173class AlphaInverseEffect(Serialisable): 

174 

175 pass 

176 

177class AlphaFloorEffect(Serialisable): 

178 

179 pass 

180 

181class AlphaCeilingEffect(Serialisable): 

182 

183 pass 

184 

185class AlphaBiLevelEffect(Serialisable): 

186 

187 thresh = Integer() 

188 

189 def __init__(self, 

190 thresh=None, 

191 ): 

192 self.thresh = thresh 

193 

194 

195class GlowEffect(ColorChoice): 

196 

197 rad = Float() 

198 # uses element group EG_ColorChoice 

199 scrgbClr = ColorChoice.scrgbClr 

200 srgbClr = ColorChoice.srgbClr 

201 hslClr = ColorChoice.hslClr 

202 sysClr = ColorChoice.sysClr 

203 schemeClr = ColorChoice.schemeClr 

204 prstClr = ColorChoice.prstClr 

205 

206 __elements__ = ('scrgbClr', 'srgbClr', 'hslClr', 'sysClr', 'schemeClr', 'prstClr') 

207 

208 def __init__(self, 

209 rad=None, 

210 **kw 

211 ): 

212 self.rad = rad 

213 super(GlowEffect, self).__init__(**kw) 

214 

215 

216class InnerShadowEffect(ColorChoice): 

217 

218 blurRad = Float() 

219 dist = Float() 

220 dir = Integer() 

221 # uses element group EG_ColorChoice 

222 scrgbClr = ColorChoice.scrgbClr 

223 srgbClr = ColorChoice.srgbClr 

224 hslClr = ColorChoice.hslClr 

225 sysClr = ColorChoice.sysClr 

226 schemeClr = ColorChoice.schemeClr 

227 prstClr = ColorChoice.prstClr 

228 

229 __elements__ = ('scrgbClr', 'srgbClr', 'hslClr', 'sysClr', 'schemeClr', 'prstClr') 

230 

231 def __init__(self, 

232 blurRad=None, 

233 dist=None, 

234 dir=None, 

235 **kw 

236 ): 

237 self.blurRad = blurRad 

238 self.dist = dist 

239 self.dir = dir 

240 super(InnerShadowEffect, self).__init__(**kw) 

241 

242 

243class OuterShadow(ColorChoice): 

244 

245 tagname = "outerShdw" 

246 

247 blurRad = Float(allow_none=True) 

248 dist = Float(allow_none=True) 

249 dir = Integer(allow_none=True) 

250 sx = Integer(allow_none=True) 

251 sy = Integer(allow_none=True) 

252 kx = Integer(allow_none=True) 

253 ky = Integer(allow_none=True) 

254 algn = Set(values=['tl', 't', 'tr', 'l', 'ctr', 'r', 'bl', 'b', 'br']) 

255 rotWithShape = Bool(allow_none=True) 

256 # uses element group EG_ColorChoice 

257 scrgbClr = ColorChoice.scrgbClr 

258 srgbClr = ColorChoice.srgbClr 

259 hslClr = ColorChoice.hslClr 

260 sysClr = ColorChoice.sysClr 

261 schemeClr = ColorChoice.schemeClr 

262 prstClr = ColorChoice.prstClr 

263 

264 __elements__ = ('scrgbClr', 'srgbClr', 'hslClr', 'sysClr', 'schemeClr', 'prstClr') 

265 

266 def __init__(self, 

267 blurRad=None, 

268 dist=None, 

269 dir=None, 

270 sx=None, 

271 sy=None, 

272 kx=None, 

273 ky=None, 

274 algn=None, 

275 rotWithShape=None, 

276 **kw 

277 ): 

278 self.blurRad = blurRad 

279 self.dist = dist 

280 self.dir = dir 

281 self.sx = sx 

282 self.sy = sy 

283 self.kx = kx 

284 self.ky = ky 

285 self.algn = algn 

286 self.rotWithShape = rotWithShape 

287 super(OuterShadow, self).__init__(**kw) 

288 

289 

290class PresetShadowEffect(ColorChoice): 

291 

292 prst = Set(values=(['shdw1', 'shdw2', 'shdw3', 'shdw4', 'shdw5', 'shdw6', 

293 'shdw7', 'shdw8', 'shdw9', 'shdw10', 'shdw11', 'shdw12', 'shdw13', 

294 'shdw14', 'shdw15', 'shdw16', 'shdw17', 'shdw18', 'shdw19', 'shdw20'])) 

295 dist = Float() 

296 dir = Integer() 

297 # uses element group EG_ColorChoice 

298 scrgbClr = ColorChoice.scrgbClr 

299 srgbClr = ColorChoice.srgbClr 

300 hslClr = ColorChoice.hslClr 

301 sysClr = ColorChoice.sysClr 

302 schemeClr = ColorChoice.schemeClr 

303 prstClr = ColorChoice.prstClr 

304 

305 __elements__ = ('scrgbClr', 'srgbClr', 'hslClr', 'sysClr', 'schemeClr', 'prstClr') 

306 

307 def __init__(self, 

308 prst=None, 

309 dist=None, 

310 dir=None, 

311 **kw 

312 ): 

313 self.prst = prst 

314 self.dist = dist 

315 self.dir = dir 

316 super(PresetShadowEffect, self).__init__(**kw) 

317 

318 

319class ReflectionEffect(Serialisable): 

320 

321 blurRad = Float() 

322 stA = Integer() 

323 stPos = Integer() 

324 endA = Integer() 

325 endPos = Integer() 

326 dist = Float() 

327 dir = Integer() 

328 fadeDir = Integer() 

329 sx = Integer() 

330 sy = Integer() 

331 kx = Integer() 

332 ky = Integer() 

333 algn = Set(values=(['tl', 't', 'tr', 'l', 'ctr', 'r', 'bl', 'b', 'br'])) 

334 rotWithShape = Bool(allow_none=True) 

335 

336 def __init__(self, 

337 blurRad=None, 

338 stA=None, 

339 stPos=None, 

340 endA=None, 

341 endPos=None, 

342 dist=None, 

343 dir=None, 

344 fadeDir=None, 

345 sx=None, 

346 sy=None, 

347 kx=None, 

348 ky=None, 

349 algn=None, 

350 rotWithShape=None, 

351 ): 

352 self.blurRad = blurRad 

353 self.stA = stA 

354 self.stPos = stPos 

355 self.endA = endA 

356 self.endPos = endPos 

357 self.dist = dist 

358 self.dir = dir 

359 self.fadeDir = fadeDir 

360 self.sx = sx 

361 self.sy = sy 

362 self.kx = kx 

363 self.ky = ky 

364 self.algn = algn 

365 self.rotWithShape = rotWithShape 

366 

367 

368class SoftEdgesEffect(Serialisable): 

369 

370 rad = Float() 

371 

372 def __init__(self, 

373 rad=None, 

374 ): 

375 self.rad = rad 

376 

377 

378class EffectList(Serialisable): 

379 

380 blur = Typed(expected_type=BlurEffect, allow_none=True) 

381 fillOverlay = Typed(expected_type=FillOverlayEffect, allow_none=True) 

382 glow = Typed(expected_type=GlowEffect, allow_none=True) 

383 innerShdw = Typed(expected_type=InnerShadowEffect, allow_none=True) 

384 outerShdw = Typed(expected_type=OuterShadow, allow_none=True) 

385 prstShdw = Typed(expected_type=PresetShadowEffect, allow_none=True) 

386 reflection = Typed(expected_type=ReflectionEffect, allow_none=True) 

387 softEdge = Typed(expected_type=SoftEdgesEffect, allow_none=True) 

388 

389 __elements__ = ('blur', 'fillOverlay', 'glow', 'innerShdw', 'outerShdw', 

390 'prstShdw', 'reflection', 'softEdge') 

391 

392 def __init__(self, 

393 blur=None, 

394 fillOverlay=None, 

395 glow=None, 

396 innerShdw=None, 

397 outerShdw=None, 

398 prstShdw=None, 

399 reflection=None, 

400 softEdge=None, 

401 ): 

402 self.blur = blur 

403 self.fillOverlay = fillOverlay 

404 self.glow = glow 

405 self.innerShdw = innerShdw 

406 self.outerShdw = outerShdw 

407 self.prstShdw = prstShdw 

408 self.reflection = reflection 

409 self.softEdge = softEdge