Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsvgstyle.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qsvgstyle_p.h"
5
6#include "qsvgfont_p.h"
7#include "qsvggraphics_p.h"
8#include "qsvgnode_p.h"
10
11#include "qpainter.h"
12#include "qpair.h"
13#include "qcolor.h"
14#include "qdebug.h"
15#include "qmath.h"
16#include "qnumeric.h"
17
19
21 : fillOpacity(1.0),
22 strokeOpacity(1.0),
23 svgFont(0),
24 textAnchor(Qt::AlignLeft),
25 fontWeight(QFont::Normal),
26 fillRule(Qt::WindingFill),
27 strokeDashOffset(0),
28 vectorEffect(false),
29 imageRendering(QSvgQualityStyle::ImageRenderingAuto)
30{
31}
32
36
38{
39 Q_ASSERT(!"This should not be called!");
40}
41
43{
44 Q_ASSERT(!"This should not be called!");
45}
46
47
49 : m_imageRendering(QSvgQualityStyle::ImageRenderingAuto)
50 , m_oldImageRendering(QSvgQualityStyle::ImageRenderingAuto)
51 , m_imageRenderingSet(0)
52{
54}
55
57 m_imageRendering = hint;
58 m_imageRenderingSet = 1;
59}
60
62{
63 m_oldImageRendering = states.imageRendering;
64 if (m_imageRenderingSet) {
65 states.imageRendering = m_imageRendering;
66 }
67 if (m_imageRenderingSet) {
68 bool smooth = false;
69 if (m_imageRendering == ImageRenderingAuto)
70 // auto (the spec says to prefer quality)
71 smooth = true;
72 else
73 smooth = (m_imageRendering == ImageRenderingOptimizeQuality);
74 p->setRenderHint(QPainter::SmoothPixmapTransform, smooth);
75 }
76}
77
79{
80 if (m_imageRenderingSet) {
81 states.imageRendering = m_oldImageRendering;
82 bool smooth = false;
83 if (m_oldImageRendering == ImageRenderingAuto)
84 smooth = true;
85 else
86 smooth = (m_oldImageRendering == ImageRenderingOptimizeQuality);
87 p->setRenderHint(QPainter::SmoothPixmapTransform, smooth);
88 }
89}
90
92 : m_style(0)
93 , m_fillRule(Qt::WindingFill)
94 , m_oldFillRule(Qt::WindingFill)
95 , m_fillOpacity(1.0)
96 , m_oldFillOpacity(0)
97 , m_paintStyleResolved(1)
98 , m_fillRuleSet(0)
99 , m_fillOpacitySet(0)
100 , m_fillSet(0)
101{
102}
103
105{
106 m_fillRuleSet = 1;
107 m_fillRule = f;
108}
109
111{
112 m_fillOpacitySet = 1;
113 m_fillOpacity = opacity;
114}
115
117{
118 m_style = style;
119 m_fillSet = 1;
120}
121
123{
124 m_fill = std::move(brush);
125 m_style = nullptr;
126 m_fillSet = 1;
127}
128
130{
131 m_oldFill = p->brush();
132 m_oldFillRule = states.fillRule;
133 m_oldFillOpacity = states.fillOpacity;
134
135 if (m_fillRuleSet)
136 states.fillRule = m_fillRule;
137 if (m_fillSet) {
138 if (m_style)
139 p->setBrush(m_style->brush(p, n, states));
140 else
141 p->setBrush(m_fill);
142 }
143 if (m_fillOpacitySet)
144 states.fillOpacity = m_fillOpacity;
145}
146
148{
149 if (m_fillOpacitySet)
150 states.fillOpacity = m_oldFillOpacity;
151 if (m_fillSet)
152 p->setBrush(m_oldFill);
153 if (m_fillRuleSet)
154 states.fillRule = m_oldFillRule;
155}
156
158 : m_viewportFill(brush)
159{
160}
161
163{
164 m_oldFill = p->brush();
165 p->setBrush(m_viewportFill);
166}
167
169{
170 p->setBrush(m_oldFill);
171}
172
174 : m_svgFont(font)
175 , m_doc(doc)
176 , m_familySet(0)
177 , m_sizeSet(0)
178 , m_styleSet(0)
179 , m_variantSet(0)
180 , m_weightSet(0)
181 , m_textAnchorSet(0)
182{
183}
184
186 : m_svgFont(0)
187 , m_doc(0)
188 , m_familySet(0)
189 , m_sizeSet(0)
190 , m_styleSet(0)
191 , m_variantSet(0)
192 , m_weightSet(0)
193 , m_textAnchorSet(0)
194{
195}
196
198{
199 m_oldQFont = p->font();
200 m_oldSvgFont = states.svgFont;
201 m_oldTextAnchor = states.textAnchor;
202 m_oldWeight = states.fontWeight;
203
204 if (m_textAnchorSet)
205 states.textAnchor = m_textAnchor;
206
207 QFont font = m_oldQFont;
208 if (m_familySet) {
209 states.svgFont = m_svgFont;
210 font.setFamilies(m_qfont.families());
211 }
212
213 if (m_sizeSet)
214 font.setPointSizeF(m_qfont.pointSizeF());
215
216 if (m_styleSet)
217 font.setStyle(m_qfont.style());
218
219 if (m_variantSet)
221
222 if (m_weightSet) {
223 if (m_weight == BOLDER) {
224 states.fontWeight = qMin(states.fontWeight + 100, static_cast<int>(QFont::Black));
225 } else if (m_weight == LIGHTER) {
226 states.fontWeight = qMax(states.fontWeight - 100, static_cast<int>(QFont::Thin));
227 } else {
228 states.fontWeight = m_weight;
229 }
231 states.fontWeight,
232 static_cast<int>(QFont::Weight::Black))));
233 }
234
235 p->setFont(font);
236}
237
239{
240 p->setFont(m_oldQFont);
241 states.svgFont = m_oldSvgFont;
242 states.textAnchor = m_oldTextAnchor;
243 states.fontWeight = m_oldWeight;
244}
245
247 : m_strokeOpacity(1.0)
248 , m_oldStrokeOpacity(0.0)
249 , m_strokeDashOffset(0)
250 , m_oldStrokeDashOffset(0)
251 , m_style(0)
252 , m_paintStyleResolved(1)
253 , m_vectorEffect(0)
254 , m_oldVectorEffect(0)
255 , m_strokeSet(0)
256 , m_strokeDashArraySet(0)
257 , m_strokeDashOffsetSet(0)
258 , m_strokeLineCapSet(0)
259 , m_strokeLineJoinSet(0)
260 , m_strokeMiterLimitSet(0)
261 , m_strokeOpacitySet(0)
262 , m_strokeWidthSet(0)
263 , m_vectorEffectSet(0)
264{
265}
266
268{
269 m_oldStroke = p->pen();
270 m_oldStrokeOpacity = states.strokeOpacity;
271 m_oldStrokeDashOffset = states.strokeDashOffset;
272 m_oldVectorEffect = states.vectorEffect;
273
274 QPen pen = p->pen();
275
276 qreal oldWidth = pen.widthF();
277 qreal width = m_stroke.widthF();
278 if (oldWidth == 0)
279 oldWidth = 1;
280 if (width == 0)
281 width = 1;
282 qreal scale = oldWidth / width;
283
284 if (m_strokeOpacitySet)
285 states.strokeOpacity = m_strokeOpacity;
286
287 if (m_vectorEffectSet)
288 states.vectorEffect = m_vectorEffect;
289
290 if (m_strokeSet) {
291 if (m_style)
292 pen.setBrush(m_style->brush(p, n, states));
293 else
294 pen.setBrush(m_stroke.brush());
295 }
296
297 if (m_strokeWidthSet)
298 pen.setWidthF(m_stroke.widthF());
299
300 bool setDashOffsetNeeded = false;
301
302 if (m_strokeDashOffsetSet) {
303 states.strokeDashOffset = m_strokeDashOffset;
304 setDashOffsetNeeded = true;
305 }
306
307 if (m_strokeDashArraySet) {
308 if (m_stroke.style() == Qt::SolidLine) {
310 } else if (m_strokeWidthSet || oldWidth == 1) {
311 // If both width and dash array was set, the dash array is already scaled correctly.
312 pen.setDashPattern(m_stroke.dashPattern());
313 setDashOffsetNeeded = true;
314 } else {
315 // If dash array was set, but not the width, the dash array has to be scaled with respect to the old width.
316 QList<qreal> dashes = m_stroke.dashPattern();
317 for (int i = 0; i < dashes.size(); ++i)
318 dashes[i] /= oldWidth;
319 pen.setDashPattern(dashes);
320 setDashOffsetNeeded = true;
321 }
322 } else if (m_strokeWidthSet && pen.style() != Qt::SolidLine && scale != 1) {
323 // If the width was set, but not the dash array, the old dash array must be scaled with respect to the new width.
324 QList<qreal> dashes = pen.dashPattern();
325 for (int i = 0; i < dashes.size(); ++i)
326 dashes[i] *= scale;
327 pen.setDashPattern(dashes);
328 setDashOffsetNeeded = true;
329 }
330
331 if (m_strokeLineCapSet)
332 pen.setCapStyle(m_stroke.capStyle());
333 if (m_strokeLineJoinSet)
334 pen.setJoinStyle(m_stroke.joinStyle());
335 if (m_strokeMiterLimitSet)
336 pen.setMiterLimit(m_stroke.miterLimit());
337
338 // You can have dash offset on solid strokes in SVG files, but not in Qt.
339 // QPen::setDashOffset() will set the pen style to Qt::CustomDashLine,
340 // so don't call the method if the pen is solid.
341 if (setDashOffsetNeeded && pen.style() != Qt::SolidLine) {
342 qreal currentWidth = pen.widthF();
343 if (currentWidth == 0)
344 currentWidth = 1;
345 pen.setDashOffset(states.strokeDashOffset / currentWidth);
346 }
347
348 pen.setCosmetic(states.vectorEffect);
349
350 p->setPen(pen);
351}
352
354{
355 p->setPen(m_oldStroke);
356 states.strokeOpacity = m_oldStrokeOpacity;
357 states.strokeDashOffset = m_oldStrokeDashOffset;
358 states.vectorEffect = m_oldVectorEffect;
359}
360
361void QSvgStrokeStyle::setDashArray(const QList<qreal> &dashes)
362{
363 if (m_strokeWidthSet) {
364 QList<qreal> d = dashes;
365 qreal w = m_stroke.widthF();
366 if (w != 0 && w != 1) {
367 for (int i = 0; i < d.size(); ++i)
368 d[i] /= w;
369 }
370 m_stroke.setDashPattern(d);
371 } else {
372 m_stroke.setDashPattern(dashes);
373 }
374 m_strokeDashArraySet = 1;
375}
376
378 : m_solidColor(color)
379{
380}
381
383 : m_gradient(grad), m_gradientStopsSet(false)
384{
385}
386
388{
389 if (!m_link.isEmpty()) {
390 resolveStops();
391 }
392
393 // If the gradient is marked as empty, insert transparent black
394 if (!m_gradientStopsSet) {
395 m_gradient->setStops(QGradientStops() << QGradientStop(0.0, QColor(0, 0, 0, 0)));
396 m_gradientStopsSet = true;
397 }
398
399 QBrush b(*m_gradient);
400
401 if (!m_transform.isIdentity())
402 b.setTransform(m_transform);
403
404 return b;
405}
406
407
409{
410 m_transform = transform;
411}
412
418
420{
421 m_patternImage = m_pattern->patternImage(p, states, node);
422 QBrush b(m_patternImage);
423 b.setTransform(m_pattern->appliedTransform());
424 return b;
425}
426
428 : m_transform(trans)
429{
430}
431
433{
434 m_oldWorldTransform = p->worldTransform();
435 p->setWorldTransform(m_transform, true);
436}
437
439{
440 p->setWorldTransform(m_oldWorldTransform, false /* don't combine */);
441}
442
447
452
457
462
467
472
477
482
487
488
494
496{
497 m_oldMode = p->compositionMode();
498 p->setCompositionMode(m_mode);
499}
500
502{
503 p->setCompositionMode(m_oldMode);
504}
505
510
514
516{
517 if (quality) {
518 quality->apply(p, node, states);
519 }
520
521 if (fill) {
522 fill->apply(p, node, states);
523 }
524
525 if (viewportFill) {
526 viewportFill->apply(p, node, states);
527 }
528
529 if (font) {
530 font->apply(p, node, states);
531 }
532
533 if (stroke) {
534 stroke->apply(p, node, states);
535 }
536
537 if (transform) {
538 transform->apply(p, node, states);
539 }
540
541 if (animateColor) {
542 animateColor->apply(p, node, states);
543 }
544
545 //animated transforms have to be applied
546 //_after_ the original object transformations
547 if (!animateTransforms.isEmpty()) {
548 qreal totalTimeElapsed = node->document()->currentElapsed();
549 // Find the last animateTransform with additive="replace", since this will override all
550 // previous animateTransforms.
551 QList<QSvgRefCounter<QSvgAnimateTransform> >::const_iterator itr = animateTransforms.constEnd();
552 do {
553 --itr;
554 if ((*itr)->animActive(totalTimeElapsed)
555 && (*itr)->additiveType() == QSvgAnimateTransform::Replace) {
556 // An animateTransform with additive="replace" will replace the transform attribute.
557 if (transform)
558 transform->revert(p, states);
559 break;
560 }
561 } while (itr != animateTransforms.constBegin());
562
563 // Apply the animateTransforms after and including the last one with additive="replace".
564 for (; itr != animateTransforms.constEnd(); ++itr) {
565 if ((*itr)->animActive(totalTimeElapsed))
566 (*itr)->apply(p, node, states);
567 }
568 }
569
570 if (opacity) {
571 opacity->apply(p, node, states);
572 }
573
574 if (compop) {
575 compop->apply(p, node, states);
576 }
577}
578
580{
581 if (quality) {
583 }
584
585 if (fill) {
586 fill->revert(p, states);
587 }
588
589 if (viewportFill) {
591 }
592
593 if (font) {
594 font->revert(p, states);
595 }
596
597 if (stroke) {
599 }
600
601 //animated transforms need to be reverted _before_
602 //the native transforms
603 if (!animateTransforms.isEmpty()) {
604 QList<QSvgRefCounter<QSvgAnimateTransform> >::const_iterator itr = animateTransforms.constBegin();
605 for (; itr != animateTransforms.constEnd(); ++itr) {
606 if ((*itr)->transformApplied()) {
607 (*itr)->revert(p, states);
608 break;
609 }
610 }
611 for (; itr != animateTransforms.constEnd(); ++itr)
612 (*itr)->clearTransformApplied();
613 }
614
615 if (transform) {
616 transform->revert(p, states);
617 }
618
619 if (animateColor) {
621 }
622
623 if (opacity) {
625 }
626
627 if (compop) {
629 }
630}
631
632QSvgAnimateTransform::QSvgAnimateTransform(int startMs, int endMs, int byMs )
634 m_from(startMs),
635 m_totalRunningTime(endMs - startMs),
636 m_type(Empty),
637 m_additive(Replace),
638 m_count(0),
639 m_finished(false),
640 m_freeze(false),
641 m_repeatCount(-1.),
642 m_transformApplied(false)
643{
644 Q_UNUSED(byMs);
645}
646
648{
649 m_type = type;
650 m_args = args;
651 m_additive = additive;
652 Q_ASSERT(!(args.size()%3));
653 m_count = args.size() / 3;
654}
655
657{
658 m_oldWorldTransform = p->worldTransform();
659 resolveMatrix(node);
660 p->setWorldTransform(m_transform, true);
661 m_transformApplied = true;
662}
663
665{
666 p->setWorldTransform(m_oldWorldTransform, false /* don't combine */);
667 m_transformApplied = false;
668}
669
671{
672 qreal totalTimeElapsed = node->document()->currentElapsed();
673 if (totalTimeElapsed < m_from || m_finished)
674 return;
675
676 qreal fractionOfTotalTime = 0;
677 if (m_totalRunningTime != 0) {
678 fractionOfTotalTime = (totalTimeElapsed - m_from) / m_totalRunningTime;
679
680 if (m_repeatCount >= 0 && m_repeatCount < fractionOfTotalTime) {
681 m_finished = true;
682 fractionOfTotalTime = m_repeatCount;
683 }
684 }
685
686 qreal fractionOfCurrentIterationTime = fractionOfTotalTime - std::trunc(fractionOfTotalTime);
687
688 qreal currentIndexPosition = fractionOfCurrentIterationTime * (m_count - 1);
689 int endElem = qCeil(currentIndexPosition);
690 int startElem = qMax(endElem - 1, 0);
691
692 qreal fractionOfCurrentElement = currentIndexPosition - std::trunc(currentIndexPosition);
693
694 switch(m_type)
695 {
696 case Translate: {
697 startElem *= 3;
698 endElem *= 3;
699 qreal from1, from2;
700 qreal to1, to2;
701 from1 = m_args[startElem++];
702 from2 = m_args[startElem++];
703 to1 = m_args[endElem++];
704 to2 = m_args[endElem++];
705
706 qreal transXDiff = (to1 - from1) * fractionOfCurrentElement;
707 qreal transX = from1 + transXDiff;
708 qreal transYDiff = (to2 - from2) * fractionOfCurrentElement;
709 qreal transY = from2 + transYDiff;
710 m_transform = QTransform();
711 m_transform.translate(transX, transY);
712 break;
713 }
714 case Scale: {
715 startElem *= 3;
716 endElem *= 3;
717 qreal from1, from2;
718 qreal to1, to2;
719 from1 = m_args[startElem++];
720 from2 = m_args[startElem++];
721 to1 = m_args[endElem++];
722 to2 = m_args[endElem++];
723
724 qreal transXDiff = (to1 - from1) * fractionOfCurrentElement;
725 qreal transX = from1 + transXDiff;
726 qreal transYDiff = (to2 - from2) * fractionOfCurrentElement;
727 qreal transY = from2 + transYDiff;
728 if (transY == 0)
729 transY = transX;
730 m_transform = QTransform();
731 m_transform.scale(transX, transY);
732 break;
733 }
734 case Rotate: {
735 startElem *= 3;
736 endElem *= 3;
737 qreal from1, from2, from3;
738 qreal to1, to2, to3;
739 from1 = m_args[startElem++];
740 from2 = m_args[startElem++];
741 from3 = m_args[startElem++];
742 to1 = m_args[endElem++];
743 to2 = m_args[endElem++];
744 to3 = m_args[endElem++];
745
746 qreal rotationDiff = (to1 - from1) * fractionOfCurrentElement;
747 //qreal rotation = from1 + rotationDiff;
748
749 qreal transXDiff = (to2 - from2) * fractionOfCurrentElement;
750 qreal transX = from2 + transXDiff;
751 qreal transYDiff = (to3 - from3) * fractionOfCurrentElement;
752 qreal transY = from3 + transYDiff;
753 m_transform = QTransform();
754 m_transform.translate(transX, transY);
755 m_transform.rotate(rotationDiff);
756 m_transform.translate(-transX, -transY);
757 break;
758 }
759 case SkewX: {
760 startElem *= 3;
761 endElem *= 3;
762 qreal from1;
763 qreal to1;
764 from1 = m_args[startElem++];
765 to1 = m_args[endElem++];
766
767 qreal transXDiff = (to1 - from1) * fractionOfCurrentElement;
768 qreal transX = from1 + transXDiff;
769 m_transform = QTransform();
770 m_transform.shear(qTan(qDegreesToRadians(transX)), 0);
771 break;
772 }
773 case SkewY: {
774 startElem *= 3;
775 endElem *= 3;
776 qreal from1;
777 qreal to1;
778 from1 = m_args[startElem++];
779 to1 = m_args[endElem++];
780
781 qreal transYDiff = (to1 - from1) * fractionOfCurrentElement;
782 qreal transY = from1 + transYDiff;
783 m_transform = QTransform();
784 m_transform.shear(0, qTan(qDegreesToRadians(transY)));
785 break;
786 }
787 default:
788 break;
789 }
790}
791
796
798{
799 m_freeze = freeze;
800}
801
803{
804 m_repeatCount = repeatCount;
805}
806
807QSvgAnimateColor::QSvgAnimateColor(int startMs, int endMs, int byMs)
809 m_from(startMs),
810 m_totalRunningTime(endMs - startMs),
811 m_fill(false),
812 m_finished(false),
813 m_freeze(false),
814 m_repeatCount(-1.)
815{
816 Q_UNUSED(byMs);
817}
818
820 const QList<QColor> &colors)
821{
822 m_fill = fill;
823 m_colors = colors;
824}
825
827{
828 m_freeze = freeze;
829}
830
832{
833 m_repeatCount = repeatCount;
834}
835
837{
838 qreal totalTimeElapsed = node->document()->currentElapsed();
839 if (totalTimeElapsed < m_from || m_finished)
840 return;
841
842 qreal animationFrame = 0;
843 if (m_totalRunningTime != 0)
844 animationFrame = (totalTimeElapsed - m_from) / m_totalRunningTime;
845
846 if (m_repeatCount >= 0 && m_repeatCount < animationFrame) {
847 m_finished = true;
848 animationFrame = m_repeatCount;
849 }
850
851 qreal percentOfAnimation = animationFrame;
852 if (percentOfAnimation > 1) {
853 percentOfAnimation -= ((int)percentOfAnimation);
854 }
855
856 qreal currentPosition = percentOfAnimation * (m_colors.size() - 1);
857
858 int startElem = qFloor(currentPosition);
859 int endElem = qCeil(currentPosition);
860 QColor start = m_colors[startElem];
861 QColor end = m_colors[endElem];
862
863 qreal percentOfColorMorph = currentPosition;
864 if (percentOfColorMorph > 1) {
865 percentOfColorMorph -= ((int)percentOfColorMorph);
866 }
867
868 // Interpolate between the two fixed colors start and end
869 qreal aDiff = (end.alpha() - start.alpha()) * percentOfColorMorph;
870 qreal rDiff = (end.red() - start.red()) * percentOfColorMorph;
871 qreal gDiff = (end.green() - start.green()) * percentOfColorMorph;
872 qreal bDiff = (end.blue() - start.blue()) * percentOfColorMorph;
873
874 int alpha = int(start.alpha() + aDiff);
875 int red = int(start.red() + rDiff);
876 int green = int(start.green() + gDiff);
877 int blue = int(start.blue() + bDiff);
878
880
881 if (m_fill) {
882 QBrush b = p->brush();
883 m_oldBrush = b;
885 p->setBrush(b);
886 } else {
887 QPen pen = p->pen();
888 m_oldPen = pen;
889 pen.setColor(color);
890 p->setPen(pen);
891 }
892}
893
895{
896 if (m_fill) {
897 p->setBrush(m_oldBrush);
898 } else {
899 p->setPen(m_oldPen);
900 }
901}
902
907
909 : m_opacity(opacity), m_oldOpacity(0)
910{
911
912}
913
915{
916 m_oldOpacity = p->opacity();
917 p->setOpacity(m_opacity * m_oldOpacity);
918}
919
921{
922 p->setOpacity(m_oldOpacity);
923}
924
929
931{
932 m_link = link;
933 m_doc = doc;
934}
935
937{
938 QStringList visited;
939 resolveStops_helper(&visited);
940}
941
943{
944 if (!m_link.isEmpty() && m_doc) {
945 QSvgStyleProperty *prop = m_doc->styleProperty(m_link);
946 if (prop && !visited->contains(m_link)) {
947 visited->append(m_link);
948 if (prop->type() == QSvgStyleProperty::GRADIENT) {
950 static_cast<QSvgGradientStyle*>(prop);
951 st->resolveStops_helper(visited);
952 m_gradient->setStops(st->qgradient()->stops());
953 m_gradientStopsSet = st->gradientStopsSet();
954 }
955 } else {
956 qWarning("Could not resolve property : %s", qPrintable(m_link));
957 }
958 m_link = QString();
959 }
960}
961
\inmodule QtGui
Definition qbrush.h:30
void setColor(const QColor &color)
Sets the brush color to the given color.
Definition qbrush.cpp:687
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\reentrant
Definition qfont.h:22
void setStyle(Style style)
Sets the style of the font to style.
Definition qfont.cpp:1116
void setFamilies(const QStringList &)
Definition qfont.cpp:2721
void setCapitalization(Capitalization)
Definition qfont.cpp:1725
Capitalization capitalization() const
Definition qfont.cpp:1743
QStringList families() const
Definition qfont.cpp:2699
qreal pointSizeF() const
Returns the point size of the font.
Definition qfont.cpp:1034
Style style() const
Returns the style of the font.
Definition qfont.cpp:1105
void setPointSizeF(qreal)
Sets the point size to pointSize.
Definition qfont.cpp:1010
Weight
Qt uses a weighting scale from 1 to 1000 compatible with OpenType.
Definition qfont.h:63
@ Thin
Definition qfont.h:64
@ Black
Definition qfont.h:72
void setWeight(Weight weight)
Sets the weight of the font to weight, using the scale defined by \l QFont::Weight enumeration.
Definition qfont.cpp:1205
\inmodule QtGui
Definition qbrush.h:135
void setStops(const QGradientStops &stops)
Replaces the current set of stop points with the given stopPoints.
Definition qbrush.cpp:1608
qsizetype size() const noexcept
Definition qlist.h:397
bool isEmpty() const noexcept
Definition qlist.h:401
const_iterator constBegin() const noexcept
Definition qlist.h:632
const_iterator constEnd() const noexcept
Definition qlist.h:633
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
@ SmoothPixmapTransform
Definition qpainter.h:54
CompositionMode
Defines the modes supported for digital image compositing.
Definition qpainter.h:97
\inmodule QtGui
Definition qpen.h:28
void setCapStyle(Qt::PenCapStyle pcs)
Sets the pen's cap style to the given style.
Definition qpen.cpp:650
qreal widthF() const
Returns the pen width with floating point precision.
Definition qpen.cpp:572
void setStyle(Qt::PenStyle)
[0]
QList< qreal > dashPattern() const
Returns the dash pattern of this pen.
Definition qpen.cpp:400
void setWidthF(qreal width)
Sets the pen width to the given width in pixels with floating point precision.
Definition qpen.cpp:618
Qt::PenCapStyle capStyle() const
Returns the pen's cap style.
Definition qpen.cpp:636
void setColor(const QColor &color)
Sets the color of this pen's brush to the given color.
Definition qpen.cpp:705
void setBrush(const QBrush &brush)
Sets the brush used to fill strokes generated with this pen to the given brush.
Definition qpen.cpp:726
void setJoinStyle(Qt::PenJoinStyle pcs)
Sets the pen's join style to the given style.
Definition qpen.cpp:677
void setDashOffset(qreal doffset)
Sets the dash offset (the starting point on the dash pattern) for this pen to the offset specified.
Definition qpen.cpp:506
void setMiterLimit(qreal limit)
Sets the miter limit of this pen to the given limit.
Definition qpen.cpp:545
Qt::PenJoinStyle joinStyle() const
Returns the pen's join style.
Definition qpen.cpp:663
void setCosmetic(bool cosmetic)
Sets this pen to cosmetic or non-cosmetic, depending on the value of cosmetic.
Definition qpen.cpp:770
void setDashPattern(const QList< qreal > &pattern)
Sets the dash pattern for this pen to the given pattern.
Definition qpen.cpp:463
qreal miterLimit() const
Returns the miter limit of the pen.
Definition qpen.cpp:524
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
Definition qpen.cpp:715
Qt::PenStyle style() const
Returns the pen style.
Definition qpen.cpp:366
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
void revert(QPainter *p, QSvgExtraStates &states) override
void setRepeatCount(qreal repeatCount)
void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states) override
void setFreeze(bool freeze)
void setArgs(bool fill, const QList< QColor > &colors)
Type type() const override
QSvgAnimateColor(int startMs, int endMs, int by=0)
QSvgAnimateTransform(int startMs, int endMs, int by=0)
void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states) override
void setFreeze(bool freeze)
void setArgs(TransformType type, Additive additive, const QList< qreal > &args)
void setRepeatCount(qreal repeatCount)
Type type() const override
void revert(QPainter *p, QSvgExtraStates &states) override
void resolveMatrix(const QSvgNode *node)
QSvgCompOpStyle(QPainter::CompositionMode mode)
void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states) override
Type type() const override
void revert(QPainter *p, QSvgExtraStates &states) override
void setFillRule(Qt::FillRule f)
void setFillOpacity(qreal opacity)
void revert(QPainter *p, QSvgExtraStates &states) override
void setBrush(QBrush brush)
void setFillStyle(QSvgPaintStyleProperty *style)
Type type() const override
void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states) override
QSvgPaintStyleProperty * style() const
Type type() const override
void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states) override
static const int BOLDER
static const int LIGHTER
void revert(QPainter *p, QSvgExtraStates &states) override
Type type() const override
QBrush brush(QPainter *, const QSvgNode *, QSvgExtraStates &) override
void setTransform(const QTransform &transform)
void resolveStops_helper(QStringList *visited)
void setStopLink(const QString &link, QSvgTinyDocument *doc)
QSvgGradientStyle(QGradient *grad)
QSvgStyleProperty * styleProperty(QSvgStyleProperty::Type type) const
Definition qsvgnode.cpp:258
QSvgTinyDocument * document() const
Definition qsvgnode.cpp:372
void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states) override
QSvgOpacityStyle(qreal opacity)
void revert(QPainter *p, QSvgExtraStates &states) override
Type type() const override
virtual QBrush brush(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)=0
void revert(QPainter *p, QSvgExtraStates &states) override
Definition qsvgstyle.cpp:42
void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states) override
Definition qsvgstyle.cpp:37
QBrush brush(QPainter *, const QSvgNode *, QSvgExtraStates &) override
Type type() const override
QSvgPatternStyle(QSvgPattern *pattern)
QImage patternImage(QPainter *p, QSvgExtraStates &states, const QSvgNode *patternElement)
const QTransform & appliedTransform() const
void revert(QPainter *p, QSvgExtraStates &states) override
Definition qsvgstyle.cpp:78
Type type() const override
void setImageRendering(ImageRendering)
Definition qsvgstyle.cpp:56
void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states) override
Definition qsvgstyle.cpp:61
QSvgQualityStyle(int color)
Definition qsvgstyle.cpp:48
QSvgSolidColorStyle(const QColor &color)
Type type() const override
void setDashArray(const QList< qreal > &dashes)
void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states) override
void revert(QPainter *p, QSvgExtraStates &states) override
Type type() const override
virtual Type type() const =0
virtual ~QSvgStyleProperty()
Definition qsvgstyle.cpp:33
void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
QSvgRefCounter< QSvgOpacityStyle > opacity
QSvgRefCounter< QSvgViewportFillStyle > viewportFill
QList< QSvgRefCounter< QSvgAnimateTransform > > animateTransforms
QSvgRefCounter< QSvgFontStyle > font
QSvgRefCounter< QSvgStrokeStyle > stroke
QSvgRefCounter< QSvgAnimateColor > animateColor
QSvgRefCounter< QSvgQualityStyle > quality
QSvgRefCounter< QSvgFillStyle > fill
QSvgRefCounter< QSvgCompOpStyle > compop
void revert(QPainter *p, QSvgExtraStates &states)
Type type() const override
QSvgTransformStyle(const QTransform &transform)
void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states) override
void revert(QPainter *p, QSvgExtraStates &states) override
void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states) override
QSvgViewportFillStyle(const QBrush &brush)
void revert(QPainter *p, QSvgExtraStates &states) override
Type type() const override
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
QTransform & rotate(qreal a, Qt::Axis axis=Qt::ZAxis, qreal distanceToPlane=1024.0f)
QTransform & scale(qreal sx, qreal sy)
Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the mat...
QTransform & shear(qreal sh, qreal sv)
Shears the coordinate system by sh horizontally and sv vertically, and returns a reference to the mat...
QTransform & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
bool isIdentity() const
Returns true if the matrix is the identity matrix, otherwise returns false.
Definition qtransform.h:169
Combined button and popup list for selecting options.
Definition qcompare.h:63
@ SolidLine
Definition brush.cpp:5
QPair< qreal, QColor > QGradientStop
Definition qbrush.h:131
QList< QGradientStop > QGradientStops
Definition qbrush.h:132
#define qWarning
Definition qlogging.h:166
int qFloor(T v)
Definition qmath.h:42
int qCeil(T v)
Definition qmath.h:36
constexpr float qDegreesToRadians(float degrees)
Definition qmath.h:260
auto qTan(T v)
Definition qmath.h:66
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qBound(const T &min, const T &val, const T &max)
Definition qminmax.h:44
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLboolean GLboolean GLboolean b
GLenum mode
GLfloat GLfloat GLfloat w
[0]
GLuint GLuint end
GLfloat GLfloat f
GLint GLsizei width
GLuint color
[2]
GLenum type
GLuint start
GLfloat n
GLuint GLenum GLenum transform
GLbyte GLbyte blue
Definition qopenglext.h:385
GLfloat GLfloat p
[1]
GLfloat GLfloat GLfloat alpha
Definition qopenglext.h:418
GLbyte green
Definition qopenglext.h:385
GLenum GLenum GLenum GLenum GLenum scale
GLubyte * pattern
GLuint * states
static QT_BEGIN_NAMESPACE const QRgb colors[][14]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define qPrintable(string)
Definition qstring.h:1531
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define Q_UNUSED(x)
double qreal
Definition qtypes.h:187
ba fill(true)
QJSValueList args
QGraphicsSvgItem * red