Commit Graph

232 Commits

Author SHA1 Message Date
Mikael Sand
fc63635f3c Implement basic support for Pattern element 2018-09-02 16:06:44 +03:00
Mikael Sand
11a57526fc [ios] Fix clipped bounds calculation for gradients
Fixes https://github.com/react-native-community/react-native-svg/issues/738
2018-09-01 13:49:13 +03:00
Mikael Sand
a1097b8594 Fix spec conformance of clipping path with multiple child elements.
https://www.w3.org/TR/SVG11/masking.html#EstablishingANewClippingPath

The raw geometry of each child element exclusive of rendering properties such as ‘fill’, ‘stroke’, ‘stroke-width’ within a ‘clipPath’ conceptually defines a 1-bit mask (with the possible exception of anti-aliasing along the edge of the geometry) which represents the silhouette of the graphics associated with that element. Anything outside the outline of the object is masked out. If a child element is made invisible by ‘display’ or ‘visibility’ it does not contribute to the clipping path. When the ‘clipPath’ element contains multiple child elements, the silhouettes of the child elements are logically OR'd together to create a single silhouette which is then used to restrict the region onto which paint can be applied. Thus, a point is inside the clipping path if it is inside any of the children of the ‘clipPath’.

For a given graphics element, the actual clipping path used will be the intersection of the clipping path specified by its ‘clip-path’ property (if any) with any clipping paths on its ancestors, as specified by the ‘clip-path’ property on the ancestor elements, or by the ‘overflow’ property on ancestor elements which establish a new viewport. Also, see the discussion of the initial clipping path.)

Fixes issues highlighted by https://github.com/react-native-community/react-native-svg/issues/752
Fix https://github.com/react-native-community/react-native-svg/issues/280
Fix https://github.com/react-native-community/react-native-svg/issues/517

[android] Fix https://github.com/react-native-community/react-native-svg/issues/766
`Region.Op.REPLACE` is deprecated in API level 28
Replace with clipPath (Path path) to Intersect instead.
2018-09-01 02:55:36 +03:00
Mikael Sand
f1f0e2f186 [ios] Fix clipping of images 2018-08-25 12:36:48 +03:00
Mikael Sand
d0a9cbaceb Fix caching of text 2018-08-25 00:17:36 +03:00
Mikael Sand
0de4213e03 Rename regex to be namespaced 2018-08-19 23:57:30 +03:00
Mikael Sand
e98b0fe1d1 Merge branch 'master' into NativeAnimation
# Conflicts:
#	android/src/main/java/com/horcrux/svg/RenderableShadowNode.java
#	android/src/main/java/com/horcrux/svg/SvgViewShadowNode.java
#	elements/Image.js
#	elements/Rect.js
#	elements/Use.js
#	lib/attributes.js
2018-08-19 15:48:40 +03:00
Mikael Sand
3879c90bd8 Support native animation of fill and stroke 2018-08-17 22:09:47 +03:00
boygirl
3ac213f8e1 fixes animating clipPath in ios 2018-07-25 16:00:40 -07:00
Mikael Sand
f225d0648d [ios] Restore ability to disable kerning 2018-07-02 09:10:15 +03:00
Mikael Sand
85729ee658 [ios] Fix kerning for Korean and Chinese characters. Issue #719 2018-07-02 08:16:05 +03:00
Mikael Sand
eafe5d4f7c [ios] Fix crash on nested svg 2018-07-02 05:25:20 +03:00
Maksym Komarychev
4fc6f4fd87 [ios] fire onLayout 2018-06-09 00:20:27 +03:00
Mikael Sand
01452d7354 Merge remote-tracking branch 'max/touches-group-use' 2018-06-07 21:20:35 +03:00
Nicolas Martino
7d03b74636 Fixed TVOS target 2018-04-18 14:38:15 -04:00
Maksym Komarychev
374d166372 [ios] save hit area even if not responsible 2018-04-14 19:38:11 +03:00
Maksym Komarychev
2d698e92d5 [ios] Handle touches within use 2018-04-14 19:38:11 +03:00
Maksym Komarychev
de01bb8638 [ios] Fix touch handling in groups
Check all children before current node itself.
Add shortcut check to return active node if `event` is null. Otherwise
it may return wrong node which have higher z-index value.
2018-04-14 19:36:48 +03:00
Bilal Syed
ca92b72944 Set _imageSize on load 2018-03-19 13:51:13 +03:00
Mikael Sand
57e458c328 Fix missing rect parameter 2018-03-19 01:11:33 +02:00
Mikael Sand
13fcdf6f15 Merge remote-tracking branch 'msand/NestedSvg' into merge-test
# Conflicts:
#	ios/Elements/RNSVGGroup.m
#	ios/RNSVGNode.h
#	ios/RNSVGNode.m
2018-03-19 00:27:01 +02:00
Mikael Sand
6b0ff5e19f Fix merge issue. 2018-03-18 23:32:04 +02:00
Mikael Sand
e334c74c7c Merge branch 'fix-display-none' into bugfix/278-memory-leak-issue 2018-03-18 23:17:56 +02:00
Mikael Sand
40a17c838d Merge remote-tracking branch 'uxbert/5.5.1-load-image-from-url' into fix-display-none
# Conflicts:
#	android/src/main/java/com/horcrux/svg/ImageShadowNode.java
#	ios/Elements/RNSVGImage.m
2018-03-18 23:14:29 +02:00
Mikael Sand
0eb501d5e8 Alternative approach without TextureView. 2018-03-18 22:39:44 +02:00
Mikael Sand
7deabf8287 Add RenderableView, fix names. Allow percentages in nested SVG (iOS). 2018-03-17 23:22:40 +02:00
Bilal Syed
77ebefb650 Load Image from URL 2018-03-15 19:00:58 +03:00
James Reggio
ca9855b1cd Fix issue where Svg never draws if mounted while parent is hidden (iOS only) 2018-03-15 11:17:27 -04:00
Nikolay Demyankov
f7c81ef368 Remove getAlignmentBaseline and getBaselineShift methods, use property methods instead. 2018-03-14 17:00:38 +01:00
Nikolay Demyankov
ef8b687ff0 Fix retain cycle for the textRoot property. 2018-03-14 15:31:02 +01:00
Nikolay Demyankov
26964598fc Fix retain cycle for nested views. 2018-03-14 11:05:20 +01:00
Mikael Sand
fbd6591251 Experiment to allow animating fillOpacity of Rect using native driver.
import React, { Component } from 'react';
import { StyleSheet, View, Dimensions, Animated } from 'react-native';
import { Svg, Rect } from 'react-native-svg';

const { width, height } = Dimensions.get('window');
const AnimatedRect = Animated.createAnimatedComponent(Rect);

export default class App extends Component {
  state = {
    anim: new Animated.Value(0),
  };

  componentDidMount() {
    Animated.timing(this.state.anim, {
      toValue: 1,
      duration: 3000,
      useNativeDriver: true,
    }).start();
  }

  render() {
    const { anim } = this.state;
    return (
      <View style={styles.container}>
        <Svg width={width} height={height} viewBox="0 0 100 100">
          <AnimatedRect
            x="5"
            y="5"
            width="90"
            height="90"
            fill="green"
            fillOpacity={anim}
          />
        </Svg>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    backgroundColor: '#ecf0f1',
  },
});
2018-02-24 23:45:42 +02:00
Mikael Sand
8ff052ce40 Optimize group hitTest 2018-02-23 01:38:41 +02:00
Mikael Sand
cd43fc151e Optimize hit testing. 2018-02-23 00:19:10 +02:00
Mikael Sand
db8f1da46b Improve path caching on ios 2018-02-22 03:48:39 +02:00
Mikael Sand
b5eeb1ee72 Allow nesting React-Native View components inside svg 2018-02-21 12:17:12 +02:00
Mikael Sand
ee1d1f78cc First attempt at nested svg support. 2018-02-21 12:17:12 +02:00
Ben Roth
5f74c92a58 Namespaces or un-globalifies a handful more iOS globals 2018-02-16 17:14:10 -08:00
Mikael Sand
13487029c0 Fix paths. 2018-02-15 13:29:32 +02:00
Ben Roth
b217dcaff8 Prefix iOS symbols with RNSVG
fixes https://github.com/react-native-community/react-native-svg/issues/603
2018-02-14 19:04:32 -08:00
James Ide
10f8134dab Add "typedef" to NS_ENUM declarations, fix duplicate symbol error
NS_ENUM is designed to go with typedef c.f. Apple docs: https://developer.apple.com/library/content/releasenotes/ObjectiveC/ModernizationObjC/AdoptingModernObjective-C/AdoptingModernObjective-C.html#//apple_ref/doc/uid/TP40014150-CH1-SW6

Fixes #579
2018-02-12 18:14:04 -08:00
Mikael Sand
be81454041 Fix strokeWidth hitArea units calculation 2018-02-03 20:09:36 +02:00
Douglas Lowder
27f0245110 Fix tvOS compile issue (BezierElement.m) 2018-01-26 23:08:39 -08:00
Mikael Sand
310fbed841 Fix image rendering 2018-01-03 20:30:36 +02:00
Mikael Sand
83d00d09db Optimize and improve accuracy of textPath. 2018-01-02 23:39:58 +02:00
Mikael Sand
4a8808b0fb Fix handling of combined ligatures and kerning.
Remove hasGlyph helper and ligature tracking array.
Use single call to:
 - CFAttributedStringCreate
 - CTLineCreateWithAttributedString
and a call per bi-di/layout run to:
 - CTRunGetGlyphs for glyphs
 - CTFontGetAdvancesForGlyphs for advances
 - CTRunGetStringIndices for indices of ligatures
And an efficient loop over the substituted characters of ligatures,
to make glyph context calls for incrementing the attribute indices.
2018-01-02 23:17:04 +02:00
Mikael Sand
17a66f3c2c Fix ligature glyph advance value calculation on ios 2017-12-31 15:36:26 +02:00
Mikael Sand
f8b0d34c6a Fix types and glyph context nextX spacing handling. 2017-12-31 04:23:58 +02:00
Mikael Sand
9ab405cbec Add binary search for text paths with lineCount >= 16 2017-12-31 01:38:28 +02:00
Mikael Sand
f07e8f041c Allow TextPath to reference any RNSVGNode instead of only RNSVGPath.
Remove unused RNSVGTextAnchor
2017-12-30 03:35:58 +02:00