JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_GraphicsContext.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
44class JUCE_API Graphics final
45{
46public:
47 //==============================================================================
57 explicit Graphics (const Image& imageToDrawOnto);
58
59 //==============================================================================
70 void setColour (Colour newColour);
71
81 void setOpacity (float newOpacity);
82
84 void setGradientFill (const ColourGradient& gradient);
85
87 void setGradientFill (ColourGradient&& gradient);
88
93 void setTiledImageFill (const Image& imageToUse,
94 int anchorX, int anchorY,
95 float opacity);
96
100 void setFillType (const FillType& newFill);
101
102 //==============================================================================
106 void setFont (const Font& newFont);
107
113 void setFont (float newFontHeight);
114
116 Font getCurrentFont() const;
117
130 void drawSingleLineText (const String& text,
131 int startX, int baselineY,
132 Justification justification = Justification::left) const;
133
143 void drawMultiLineText (const String& text,
144 int startX, int baselineY,
145 int maximumLineWidth,
146 Justification justification = Justification::left,
147 float leading = 0.0f) const;
148
158 void drawText (const String& text,
159 int x, int y, int width, int height,
160 Justification justificationType,
161 bool useEllipsesIfTooBig = true) const;
162
172 void drawText (const String& text,
173 Rectangle<int> area,
174 Justification justificationType,
175 bool useEllipsesIfTooBig = true) const;
176
186 void drawText (const String& text,
187 Rectangle<float> area,
188 Justification justificationType,
189 bool useEllipsesIfTooBig = true) const;
190
210 void drawFittedText (const String& text,
211 int x, int y, int width, int height,
212 Justification justificationFlags,
213 int maximumNumberOfLines,
214 float minimumHorizontalScale = 0.0f) const;
215
235 void drawFittedText (const String& text,
236 Rectangle<int> area,
237 Justification justificationFlags,
238 int maximumNumberOfLines,
239 float minimumHorizontalScale = 0.0f) const;
240
241 //==============================================================================
247 void fillAll() const;
248
254 void fillAll (Colour colourToUse) const;
255
256 //==============================================================================
260 void fillRect (Rectangle<int> rectangle) const;
261
265 void fillRect (Rectangle<float> rectangle) const;
266
270 void fillRect (int x, int y, int width, int height) const;
271
275 void fillRect (float x, float y, float width, float height) const;
276
282 void fillRectList (const RectangleList<float>& rectangles) const;
283
289 void fillRectList (const RectangleList<int>& rectangles) const;
290
294 void fillRoundedRectangle (float x, float y, float width, float height,
295 float cornerSize) const;
296
300 void fillRoundedRectangle (Rectangle<float> rectangle,
301 float cornerSize) const;
302
304 void fillCheckerBoard (Rectangle<float> area,
305 float checkWidth, float checkHeight,
306 Colour colour1, Colour colour2) const;
307
312 void drawRect (int x, int y, int width, int height, int lineThickness = 1) const;
313
318 void drawRect (float x, float y, float width, float height, float lineThickness = 1.0f) const;
319
324 void drawRect (Rectangle<int> rectangle, int lineThickness = 1) const;
325
330 void drawRect (Rectangle<float> rectangle, float lineThickness = 1.0f) const;
331
335 void drawRoundedRectangle (float x, float y, float width, float height,
336 float cornerSize, float lineThickness) const;
337
341 void drawRoundedRectangle (Rectangle<float> rectangle,
342 float cornerSize, float lineThickness) const;
343
344 //==============================================================================
349 void fillEllipse (float x, float y, float width, float height) const;
350
355 void fillEllipse (Rectangle<float> area) const;
356
360 void drawEllipse (float x, float y, float width, float height,
361 float lineThickness) const;
362
366 void drawEllipse (Rectangle<float> area, float lineThickness) const;
367
368 //==============================================================================
374 void drawLine (float startX, float startY, float endX, float endY) const;
375
381 void drawLine (float startX, float startY, float endX, float endY, float lineThickness) const;
382
388 void drawLine (Line<float> line) const;
389
395 void drawLine (Line<float> line, float lineThickness) const;
396
408 void drawDashedLine (Line<float> line,
409 const float* dashLengths, int numDashLengths,
410 float lineThickness = 1.0f,
411 int dashIndexToStartFrom = 0) const;
412
420 void drawVerticalLine (int x, float top, float bottom) const;
421
429 void drawHorizontalLine (int y, float left, float right) const;
430
431 //==============================================================================
433 void fillPath (const Path& path) const;
434
436 void fillPath (const Path& path, const AffineTransform& transform) const;
437
439 void strokePath (const Path& path,
440 const PathStrokeType& strokeType,
441 const AffineTransform& transform = {}) const;
442
450 void drawArrow (Line<float> line,
451 float lineThickness,
452 float arrowheadWidth,
453 float arrowheadLength) const;
454
455
456 //==============================================================================
462 {
463 lowResamplingQuality = 0,
464 mediumResamplingQuality = 1,
465 highResamplingQuality = 2,
466 };
467
472 void setImageResamplingQuality (ResamplingQuality newQuality);
473
485 void drawImageAt (const Image& imageToDraw, int topLeftX, int topLeftY,
486 bool fillAlphaChannelWithCurrentBrush = false) const;
487
513 void drawImage (const Image& imageToDraw,
514 int destX, int destY, int destWidth, int destHeight,
515 int sourceX, int sourceY, int sourceWidth, int sourceHeight,
516 bool fillAlphaChannelWithCurrentBrush = false) const;
517
535 void drawImageTransformed (const Image& imageToDraw,
536 const AffineTransform& transform,
537 bool fillAlphaChannelWithCurrentBrush = false) const;
538
552 void drawImage (const Image& imageToDraw, Rectangle<float> targetArea,
553 RectanglePlacement placementWithinTarget = RectanglePlacement::stretchToFit,
554 bool fillAlphaChannelWithCurrentBrush = false) const;
555
577 void drawImageWithin (const Image& imageToDraw,
578 int destX, int destY, int destWidth, int destHeight,
579 RectanglePlacement placementWithinTarget,
580 bool fillAlphaChannelWithCurrentBrush = false) const;
581
582 //==============================================================================
586 Rectangle<int> getClipBounds() const;
587
594 bool clipRegionIntersects (Rectangle<int> area) const;
595
601 bool reduceClipRegion (int x, int y, int width, int height);
602
608 bool reduceClipRegion (Rectangle<int> area);
609
615 bool reduceClipRegion (const RectangleList<int>& clipRegion);
616
622 bool reduceClipRegion (const Path& path, const AffineTransform& transform = AffineTransform());
623
635 bool reduceClipRegion (const Image& image, const AffineTransform& transform);
636
638 void excludeClipRegion (Rectangle<int> rectangleToExclude);
639
641 bool isClipEmpty() const;
642
643 //==============================================================================
648 void saveState();
649
653 void restoreState();
654
660 {
661 public:
664
665 private:
666 Graphics& context;
668 };
669
670 //==============================================================================
681 void beginTransparencyLayer (float layerOpacity);
682
686 void endTransparencyLayer();
687
698 void setOrigin (Point<int> newOrigin);
699
710 void setOrigin (int newOriginX, int newOriginY);
711
720 void addTransform (const AffineTransform& transform);
721
723 void resetToDefaultState();
724
726 bool isVectorDevice() const;
727
728 //==============================================================================
734
736 LowLevelGraphicsContext& getInternalContext() const noexcept { return context; }
737
738private:
739 //==============================================================================
742
743 bool saveStatePending = false;
744 void saveStateIfPending();
745
747};
748
749} // namespace juce
Represents a 2D affine-transformation matrix.
Describes the layout and colours that should be used to paint a colour gradient.
Represents a colour, also including a transparency value.
Definition juce_Colour.h:38
Represents a colour or fill pattern to use for rendering paths.
Represents a particular font, including its size, style, etc.
Definition juce_Font.h:42
Uses RAII to save and restore the state of a graphics context.
A graphics context, used for drawing a component or image.
ResamplingQuality
Types of rendering quality that can be specified when drawing images.
Holds a fixed-size bitmap.
Definition juce_Image.h:58
Represents a type of justification to be used when positioning graphical items.
Represents a line.
Definition juce_Line.h:47
Interface class for graphics context objects, used internally by the Graphics class.
Describes a type of stroke used to render a solid outline along a path.
A path is a sequence of lines and curves that may either form a closed shape or be open-ended.
Definition juce_Path.h:65
A pair of (x, y) coordinates.
Definition juce_Point.h:42
Maintains a set of rectangles as a complex region.
Defines the method used to position some kind of rectangular object within a rectangular viewport.
Manages a rectangle and allows geometric operations to be performed on it.
The JUCE String class!
Definition juce_String.h:53
#define JUCE_DECLARE_NON_COPYABLE(className)
This is a shorthand macro for deleting a class's copy constructor and copy assignment operator.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88