Variable width path
See original GitHub issueHere is a working fiddle with an example of multi-coloured paths, where each coordinate has a different colour, and each segment of the path gets two colours.
Here’s a snippet of the code
class MultiColouredPathLayer extends deck.PathLayer {
initializeState() {
super.initializeState();
this.state.attributeManager.addInstanced({
colors: {
size: this.props.colorFormat.length,
vertexOffset: 0,
type: 0x1401, // UNSIGNED_BYTE
normalized: true,
accessor: 'getColor',
transition: ATTRIBUTE_TRANSITION,
defaultValue: DEFAULT_COLOR,
shaderAttributes: {
instanceFirstColour: {
vertexOffset: 0
},
instanceLastColour: {
vertexOffset: 1
}
}
}
});
}
getShaders() {
return {
...super.getShaders(),
inject: {
'vs:#decl': `
attribute vec4 instanceFirstColour;
attribute vec4 instanceLastColour;
varying vec4 firstColour;
varying vec4 lastColour;
`,
'vs:#main-end':`
firstColour = vec4( instanceFirstColour.rgb, instanceFirstColour.a * opacity );
lastColour = vec4( instanceLastColour.rgb, instanceLastColour.a * opacity );
vColor = mix( firstColour, lastColour, positions.x );
`
}
}
};
}
I’ve tried to extend this where each coordinate also gets its own width
widths: {
size: 1,
vertexOffset: 0,
type: 0x140a, // DOUBLE
//normalized: true,
accessor: 'getWidth',
//transition: ATTRIBUTE_TRANSITION,
defaultValue: 1,
shaderAttributes: {
instanceFirstWidth: {
vertexOffset: 0
},
instanceLastWidth: {
vertexOffset: 1
}
}
}
but I can’t see how to inject into the vertex shader these Instance Width values so the vec2 widthPixels
variable uses them.
So my question is, is it possible to have a segment where either end has a different width, and if so, how do I inject these values into the shader?
Issue Analytics
- State:
- Created 3 years ago
- Comments:10
Top Results From Across the Web
variable width path - Beginners' Questions - Inkscape Forum
I'm hoping the answer to this is yes, as in illustrator I found a cool trick to make lightning effects by varying the...
Read more >How to Create Variable-width Stroke Profiles in Adobe Illustrator
Creating a variable width stroke is one technique that is often used to give ... want the stroke to be wider, then click,...
Read more >Proposals/Variable width stroke - SVG
If only one number is specified, the stroke width is symmetrical. Positions list: <percentage> values represent percentages of the path length.
Read more >Create a stroke with variable width using the Width tool
Learn how to create strokes with variable width in Illustrator. ... Select the trunk path, then head to the tool bar to select...
Read more >Variable-width strokes - The Battle for Wesnoth Wiki
Variable-width strokes · Create your path with any tool you like. · From "Path -> Linked Offset" create a path whose size (and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue can serve as the feature request.
For loops you need to repeat two vertices’ worth of colors/widths to match the internal positions attribute structure:
It has to do with each join requiring 3 vertices (before, current, after) to render correctly.