@@ -180,76 +180,72 @@ def quit(self: Self) -> None:
180
180
181
181
def copy (self : Self ) -> None :
182
182
clipboard = QGuiApplication .clipboard ()
183
-
184
- match self .languageDropDown .currentData ():
185
- case Language .GLSL :
186
- match self .representationDropDown .currentData ():
187
- case Representation .ColorMap :
188
- clipboard .setText (self .gradientEditor ._gradient .buildColorMap (self .weightDropDown .currentData (), self .mixDropDown .currentData ()))
189
- case Representation .Picked3ComponentColor :
190
- clipboard .setText ('vec3({:.2f}, {:.2f}, {:.2f})' .format (* self .picker .components ))
191
- case Representation .Picked4ComponentColor :
192
- clipboard .setText ('vec4({:.2f}, {:.2f}, {:.2f}, 1)' .format (* self .picker .components ))
193
- case Representation .PickedNearestGradientWeight :
194
- for weight , mix , colorMap in self .gradientEditor ._allColorMaps :
195
- if weight == self .weightDropDown .currentData () and mix == self .mixDropDown .currentData ():
196
- clipboard .setText ('{:.2f}' .format (self .gradientEditor ._gradient .nearestWeightInColorMap (colorMap , vec3 (* self .picker .components ))))
197
- case Representation .GradientColorArray :
198
- clipboard .setText ('vec3[{}]({})' .format (
199
- len (self .gradientEditor ._gradient ._colors ),
200
- ', ' .join (map (
201
- str ,
202
- self .gradientEditor ._gradient ._colors ,
203
- )),
204
- ))
205
- case Representation .GradientWeightArray :
206
- weights = self .gradientEditor ._gradient .determineWeights (self .weightDropDown .currentData ())
207
- clipboard .setText ('float[{}]({})' .format (
208
- len (weights ),
209
- ', ' .join (map (
210
- lambda weight : '{:.2f}' .format (weight ),
211
- weights ,
212
- )),
213
- ))
214
- case Language .HLSL :
215
- match self .representationDropDown .currentData ():
216
- case Representation .ColorMap :
217
- clipboard .setText (self .gradientEditor ._gradient .buildColorMap (self .weightDropDown .currentData (), self .mixDropDown .currentData ()).replace ('vec3' , 'float3' ))
218
- case Representation .Picked3ComponentColor :
219
- clipboard .setText ('float3({:.2f}, {:.2f}, {:.2f})' .format (* self .picker .components ))
220
- case Representation .Picked4ComponentColor :
221
- clipboard .setText ('float4({:.2f}, {:.2f}, {:.2f}, 1)' .format (* self .picker .components ))
222
- case Representation .PickedNearestGradientWeight :
223
- for weight , mix , colorMap in self .gradientEditor ._allColorMaps :
224
- if weight == self .weightDropDown .currentData () and mix == self .mixDropDown .currentData ():
225
- clipboard .setText ('{:.2f}' .format (self .gradientEditor ._gradient .nearestWeightInColorMap (colorMap , vec3 (* self .picker .components ))))
226
- case Representation .GradientColorArray :
227
- clipboard .setText ('{{{}}}' .format (
228
- ', ' .join (map (
229
- lambda color : ', ' .join (map (lambda component : '{:.2f}' .format (component ), color ._color .to_tuple ())),
230
- self .gradientEditor ._gradient ._colors ,
231
- )),
232
- ))
233
- case Representation .GradientWeightArray :
234
- weights = self .gradientEditor ._gradient .determineWeights (self .weightDropDown .currentData ())
235
- clipboard .setText ('{{{}}}' .format (
236
- ', ' .join (map (
237
- lambda weight : '{:.2f}' .format (weight ),
238
- weights ,
239
- )),
240
- ))
241
- case Language .CSS :
242
- match self .representationDropDown .currentData ():
243
- case Representation .ColorMap :
244
- clipboard .setText (self .gradientEditor ._gradient .buildCSSGradient (self .weightDropDown .currentData (), self .mixDropDown .currentData ()))
245
- case Representation .Picked3ComponentColor :
246
- clipboard .setText (self .picker ._color .name ())
247
- case Language .SVG :
248
- match self .representationDropDown .currentData ():
249
- case Representation .ColorMap :
250
- clipboard .setText (self .gradientEditor ._gradient .buildSVGGradient (self .weightDropDown .currentData (), self .mixDropDown .currentData ()))
251
- case Representation .Picked3ComponentColor :
252
- clipboard .setText (self .picker ._color .name ())
183
+ currentLanguage : Language = self .languageDropDown .currentData ()
184
+ currentRepresentation : Representation = self .representationDropDown .currentData ()
185
+ if currentLanguage == Language .GLSL :
186
+ if currentRepresentation == Representation .ColorMap :
187
+ clipboard .setText (self .gradientEditor ._gradient .buildColorMap (self .weightDropDown .currentData (), self .mixDropDown .currentData ()))
188
+ elif currentRepresentation == Representation .Picked3ComponentColor :
189
+ clipboard .setText ('vec3({:.2f}, {:.2f}, {:.2f})' .format (* self .picker .components ))
190
+ elif currentRepresentation == Representation .Picked4ComponentColor :
191
+ clipboard .setText ('vec4({:.2f}, {:.2f}, {:.2f}, 1)' .format (* self .picker .components ))
192
+ elif currentRepresentation == Representation .PickedNearestGradientWeight :
193
+ for weight , mix , colorMap in self .gradientEditor ._allColorMaps :
194
+ if weight == self .weightDropDown .currentData () and mix == self .mixDropDown .currentData ():
195
+ clipboard .setText ('{:.2f}' .format (self .gradientEditor ._gradient .nearestWeightInColorMap (colorMap , vec3 (* self .picker .components ))))
196
+ elif currentRepresentation == Representation .GradientColorArray :
197
+ clipboard .setText ('vec3[{}]({})' .format (
198
+ len (self .gradientEditor ._gradient ._colors ),
199
+ ', ' .join (map (
200
+ str ,
201
+ self .gradientEditor ._gradient ._colors ,
202
+ )),
203
+ ))
204
+ elif currentRepresentation == Representation .GradientWeightArray :
205
+ weights = self .gradientEditor ._gradient .determineWeights (self .weightDropDown .currentData ())
206
+ clipboard .setText ('float[{}]({})' .format (
207
+ len (weights ),
208
+ ', ' .join (map (
209
+ lambda weight : '{:.2f}' .format (weight ),
210
+ weights ,
211
+ )),
212
+ ))
213
+ elif currentLanguage == Language .HLSL :
214
+ if currentRepresentation == Representation .ColorMap :
215
+ clipboard .setText (self .gradientEditor ._gradient .buildColorMap (self .weightDropDown .currentData (), self .mixDropDown .currentData ()).replace ('vec3' , 'float3' ))
216
+ elif currentRepresentation == Representation .Picked3ComponentColor :
217
+ clipboard .setText ('float3({:.2f}, {:.2f}, {:.2f})' .format (* self .picker .components ))
218
+ elif currentRepresentation == Representation .Picked4ComponentColor :
219
+ clipboard .setText ('float4({:.2f}, {:.2f}, {:.2f}, 1)' .format (* self .picker .components ))
220
+ elif currentRepresentation == Representation .PickedNearestGradientWeight :
221
+ for weight , mix , colorMap in self .gradientEditor ._allColorMaps :
222
+ if weight == self .weightDropDown .currentData () and mix == self .mixDropDown .currentData ():
223
+ clipboard .setText ('{:.2f}' .format (self .gradientEditor ._gradient .nearestWeightInColorMap (colorMap , vec3 (* self .picker .components ))))
224
+ elif currentRepresentation == Representation .GradientColorArray :
225
+ clipboard .setText ('{{{}}}' .format (
226
+ ', ' .join (map (
227
+ lambda color : ', ' .join (map (lambda component : '{:.2f}' .format (component ), color ._color .to_tuple ())),
228
+ self .gradientEditor ._gradient ._colors ,
229
+ )),
230
+ ))
231
+ elif currentRepresentation == Representation .GradientWeightArray :
232
+ weights = self .gradientEditor ._gradient .determineWeights (self .weightDropDown .currentData ())
233
+ clipboard .setText ('{{{}}}' .format (
234
+ ', ' .join (map (
235
+ lambda weight : '{:.2f}' .format (weight ),
236
+ weights ,
237
+ )),
238
+ ))
239
+ elif currentLanguage == Language .CSS :
240
+ if currentRepresentation == Representation .ColorMap :
241
+ clipboard .setText (self .gradientEditor ._gradient .buildCSSGradient (self .weightDropDown .currentData (), self .mixDropDown .currentData ()))
242
+ elif currentRepresentation == Representation .Picked3ComponentColor :
243
+ clipboard .setText (self .picker ._color .name ())
244
+ elif currentLanguage == Language .SVG :
245
+ if currentRepresentation == Representation .ColorMap :
246
+ clipboard .setText (self .gradientEditor ._gradient .buildSVGGradient (self .weightDropDown .currentData (), self .mixDropDown .currentData ()))
247
+ elif currentRepresentation == Representation .Picked3ComponentColor :
248
+ clipboard .setText (self .picker ._color .name ())
253
249
254
250
def paste (self : Self ) -> None :
255
251
clipboard = QGuiApplication .clipboard ()
0 commit comments