question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support vector effect property

See original GitHub issue

Is there any plans to support thenon-scaling-stroke value of vector-effect property (as described here)?

One solution would be to flatten the transformations (using for example: https://github.com/fontello/svgpath), but I wouldn’t be able to animate these transforms without changing the stroke appearance.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:29 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
scottmascommented, Feb 27, 2019

Oh also, we should probably update the typings. I’m not quite sure how I would go about contributing to your existing branch so here’s the relevant code…

export interface VectorEffectProps {
  vectorEffect?: 'none' | 'non-scaling-stroke',
}
export interface CommonPathProps extends FillProps, StrokeProps, ClipProps, TransformProps, VectorEffectProps, ResponderProps, TouchableProps, DefinitionProps, CommonMaskProps {}
2reactions
msandcommented, Feb 27, 2019

Tested using this:

import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import { Svg, Rect, G, Line } from 'react-native-svg';

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Svg width="300" height="200" viewBox="0 0 600 400">
          <Rect
            x="1"
            y="1"
            width="598"
            height="398"
            fill="none"
            stroke="black"
          />

          <G transform="scale(9,1)">
            <Line
              stroke="black"
              strokeWidth="5"
              x1="10"
              y1="50"
              x2="10"
              y2="350"
            />
            <Line
              vectorEffect="non-scaling-stroke"
              stroke="black"
              strokeWidth="5"
              x1="32"
              y1="50"
              x2="32"
              y2="350"
            />
            <Line
              vectorEffect="none"
              stroke="black"
              strokeWidth="5"
              x1="55"
              y1="50"
              x2="55"
              y2="350"
            />
          </G>
        </Svg>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',
  },
});

ios: simulator screen shot - iphone xr - 2019-02-27 at 22 11 26

android: screenshot_1551298348

Read more comments on GitHub >

github_iconTop Results From Across the Web

vector-effect - SVG: Scalable Vector Graphics - MDN Web Docs
The vector-effect property specifies the vector effect to use when drawing an object. Vector effects are applied before any of the other ...
Read more >
SVG vector-effect: non-scaling-stroke | Can I use... Support ...
The non-scaling-stroke value for the vector-effect SVG attribute/CSS property makes strokes appear as the same width regardless of any transformations ...
Read more >
Support vector effect property · Issue #885 - GitHub
Is there any plans to support the non-scaling-stroke value of vector-effect property (as described here)?. One solution would be to flatten ...
Read more >
Support Vector Machine — Simply Explained | by Lilly Chen
SVM address non-linearly separable cases by introducing two concepts: Soft Margin and Kernel Tricks. Let's use an example. If I add one red...
Read more >
An Idiot's guide to Support vector machines (SVMs)
Support vectors are the elements of the training set that would change the position of the dividing hyperplane if removed. • Support vectors...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found