ObjFW
Loading...
Searching...
No Matches
OFCanvas.h
1/*
2 * Copyright (c) 2008-2026 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License version 3.0 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * version 3.0 for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * version 3.0 along with this program. If not, see
17 * <https://www.gnu.org/licenses/>.
18 */
19
20#import "OFObject.h"
21#import "OFImage.h"
22
23OF_ASSUME_NONNULL_BEGIN
24
34@protocol OFCanvas <OFObject>
38@property (retain, nonatomic) OFColor *backgroundColor;
39
47- (void)clearRect: (OFRect)rect;
48
62- (void)drawImage: (OFImage *)image
63 sourceRect: (OFRect)sourceRect
64 destinationRect: (OFRect)destinationRect;
65@end
66
73OF_SUBCLASSING_RESTRICTED
75{
76 OFMutableImage *_destinationImage;
77 size_t _width;
78 OFRect _rect;
79 void *_pixels;
80 OFPixelFormat _pixelFormat;
81 OFColor *_backgroundColor;
82}
83
90+ (instancetype)canvasWithDestinationImage: (OFMutableImage *)image;
91
92- (instancetype)init OF_UNAVAILABLE;
93
101- (instancetype)initWithDestinationImage: (OFMutableImage *)image;
102@end
103
104OF_ASSUME_NONNULL_END
An implementation of <OFCanvas> that draws to an OFImage.
Definition OFCanvas.h:76
A class for storing a color.
Definition OFColor.h:31
A class representing an image.
Definition OFImage.h:117
A class representing a mutable image.
Definition OFMutableImage.h:30
The root class for all other classes inside ObjFW.
Definition OFObject.h:956
A protocol for a canvas that can be drawn to.
Definition OFCanvas.h:34
OFColor * backgroundColor
The background color of the canvas.
Definition OFCanvas.h:38
instancetype retain()
Increases the retain count.
A rectangle.
Definition OFObject.h:343