UNPKG

3.51 kBtext/x-cView Raw
1/**
2 * Copyright (c) 2015-present, Horcrux.
3 * All rights reserved.
4 *
5 * This source code is licensed under the MIT-style license found in the
6 * LICENSE file in the root directory of this source tree.
7 */
8
9#import <React/UIView+React.h>
10#import "RNSVGCGFCRule.h"
11#import "RNSVGSvgView.h"
12@class RNSVGGroup;
13
14/**
15 * RNSVG nodes are implemented as base UIViews. They should be implementation for all basic
16 *interfaces for all non-definition nodes.
17 */
18
19@interface RNSVGNode : UIView
20
21/*
22 N[1/Sqrt[2], 36]
23 The inverse of the square root of 2.
24 Provide enough digits for the 128-bit IEEE quad (36 significant digits).
25 */
26extern CGFloat const RNSVG_M_SQRT1_2l;
27extern CGFloat const RNSVG_DEFAULT_FONT_SIZE;
28
29@property (nonatomic, strong) NSString *name;
30@property (nonatomic, assign) CGFloat opacity;
31@property (nonatomic, assign) RNSVGCGFCRule clipRule;
32@property (nonatomic, strong) NSString *clipPath;
33@property (nonatomic, strong) NSString *mask;
34@property (nonatomic, strong) NSString *markerStart;
35@property (nonatomic, strong) NSString *markerMid;
36@property (nonatomic, strong) NSString *markerEnd;
37@property (nonatomic, assign) BOOL responsible;
38@property (nonatomic, assign) CGAffineTransform matrix;
39@property (nonatomic, assign) CGAffineTransform transforms;
40@property (nonatomic, assign) CGAffineTransform invmatrix;
41@property (nonatomic, assign) CGAffineTransform invTransform;
42@property (nonatomic, assign) BOOL active;
43@property (nonatomic, assign) BOOL dirty;
44@property (nonatomic, assign) BOOL merging;
45@property (nonatomic, assign) BOOL skip;
46@property (nonatomic, assign) CGPathRef path;
47@property (nonatomic, assign) CGPathRef strokePath;
48@property (nonatomic, assign) CGRect clientRect;
49@property (nonatomic, assign) CGRect pathBounds;
50@property (nonatomic, copy) RCTDirectEventBlock onLayout;
51
52
53/**
54 * RNSVGSvgView which ownes current RNSVGNode
55 */
56@property (nonatomic, readonly, weak) RNSVGSvgView *svgView;
57@property (nonatomic, readonly, weak) RNSVGGroup *textRoot;
58
59- (void)invalidate;
60
61- (RNSVGGroup *)getParentTextRoot;
62
63- (void)renderTo:(CGContextRef)context rect:(CGRect)rect;
64
65/**
66 * @abstract
67 * renderTo will take opacity into account and draw renderLayerTo off-screen if there is opacity
68 * specified, then composite that onto the context. renderLayerTo always draws at opacity=1.
69 */
70- (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect;
71
72/**
73 * get clipPath from cache
74 */
75- (CGPathRef)getClipPath;
76
77/**
78 * get clipPath through context
79 */
80- (CGPathRef)getClipPath:(CGContextRef)context;
81
82/**
83 * clip node by clipPath
84 */
85- (void)clip:(CGContextRef)context;
86
87/**
88 * getPath will return the path inside node as a ClipPath.
89 */
90- (CGPathRef)getPath:(CGContextRef) context;
91
92- (CGFloat)relativeOnWidthString:(NSString *)length;
93
94- (CGFloat)relativeOnHeightString:(NSString *)length;
95
96- (CGFloat)relativeOnOtherString:(NSString *)length;
97
98- (CGFloat)relativeOn:(RNSVGLength *)length relative:(CGFloat)relative;
99
100- (CGFloat)relativeOnWidth:(RNSVGLength *)length;
101
102- (CGFloat)relativeOnHeight:(RNSVGLength *)length;
103
104- (CGFloat)relativeOnOther:(RNSVGLength *)length;
105
106- (CGFloat)getFontSizeFromContext;
107
108- (CGFloat)getContextWidth;
109
110- (CGFloat)getContextHeight;
111
112/**
113 * save element`s reference into svg element.
114 */
115- (void)parseReference;
116
117- (void)beginTransparencyLayer:(CGContextRef)context;
118
119- (void)endTransparencyLayer:(CGContextRef)context;
120
121- (void)traverseSubviews:(BOOL (^)(__kindof UIView *node))block;
122
123- (void)clearChildCache;
124
125- (void)clearPath;
126
127@end