-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from jansule/line-styles
feat: write line styles
- Loading branch information
Showing
12 changed files
with
310 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const lineSimpleline = { | ||
styleId: 'simpleline', | ||
rules: [ | ||
{ | ||
style: { | ||
lineStrokeCap: 'butt' | ||
} | ||
}, | ||
{ | ||
style: { | ||
lineStrokeCap: 'round' | ||
} | ||
}, | ||
{ | ||
style: { | ||
lineStrokeCap: 'square' | ||
} | ||
} | ||
] | ||
}; | ||
|
||
export default lineSimpleline; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const lineSimpleline = { | ||
styleId: 'simpleline', | ||
rules: [ | ||
{ | ||
style: { | ||
lineStrokeDash: [1, 2] | ||
} | ||
} | ||
] | ||
}; | ||
|
||
export default lineSimpleline; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const lineSimpleline = { | ||
styleId: 'simpleline', | ||
rules: [ | ||
{ | ||
style: { | ||
lineStrokeJoin: 'bevel' | ||
} | ||
}, | ||
{ | ||
style: { | ||
lineStrokeJoin: 'round' | ||
} | ||
}, | ||
{ | ||
style: { | ||
lineStrokeJoin: 'miter' | ||
} | ||
} | ||
] | ||
}; | ||
|
||
export default lineSimpleline; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const lineSimpleline = { | ||
styleId: 'simpleline', | ||
rules: [ | ||
{ | ||
style: { | ||
lineStrokeColor: [197, 219, 110, 1], | ||
lineStrokeWidth: 1 | ||
} | ||
} | ||
] | ||
}; | ||
|
||
export default lineSimpleline; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Style } from 'geostyler-style'; | ||
|
||
const lineSimpleline: Style = { | ||
name: 'simpleline', | ||
rules: [ | ||
{ | ||
name: '', | ||
symbolizers: [ | ||
{ | ||
kind: 'Line', | ||
cap: 'butt' | ||
} | ||
] | ||
}, | ||
{ | ||
name: '', | ||
symbolizers: [ | ||
{ | ||
kind: 'Line', | ||
cap: 'round' | ||
} | ||
] | ||
}, | ||
{ | ||
name: '', | ||
symbolizers: [ | ||
{ | ||
kind: 'Line', | ||
cap: 'square' | ||
} | ||
] | ||
} | ||
] | ||
}; | ||
|
||
export default lineSimpleline; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Style } from 'geostyler-style'; | ||
|
||
const lineSimpleline: Style = { | ||
name: 'simpleline', | ||
rules: [ | ||
{ | ||
name: '', | ||
symbolizers: [ | ||
{ | ||
kind: 'Line', | ||
dasharray: [1, 2] | ||
} | ||
] | ||
} | ||
] | ||
}; | ||
|
||
export default lineSimpleline; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Style } from 'geostyler-style'; | ||
|
||
const lineSimpleline: Style = { | ||
name: 'simpleline', | ||
rules: [ | ||
{ | ||
name: '', | ||
symbolizers: [ | ||
{ | ||
kind: 'Line', | ||
join: 'bevel' | ||
} | ||
] | ||
}, | ||
{ | ||
name: '', | ||
symbolizers: [ | ||
{ | ||
kind: 'Line', | ||
join: 'round' | ||
} | ||
] | ||
}, | ||
{ | ||
name: '', | ||
symbolizers: [ | ||
{ | ||
kind: 'Line', | ||
join: 'miter' | ||
} | ||
] | ||
} | ||
] | ||
}; | ||
|
||
export default lineSimpleline; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Style } from 'geostyler-style'; | ||
|
||
const lineSimpleline: Style = { | ||
name: 'simpleline', | ||
rules: [ | ||
{ | ||
name: '', | ||
symbolizers: [ | ||
{ | ||
kind: 'Line', | ||
color: '#c5db6e', | ||
width: 1 | ||
} | ||
] | ||
} | ||
] | ||
}; | ||
|
||
export default lineSimpleline; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { hexToRgba } from './MpUtil'; | ||
|
||
describe('MpUtil', () => { | ||
describe('hexToRgba', () => { | ||
it('converts a hex color to rgba', () => { | ||
const hex = '#ff0000'; | ||
const alpha = 1; | ||
const rgba = hexToRgba(hex, alpha); | ||
expect(rgba).toEqual([255, 0, 0, 1]); | ||
}); | ||
it('returns undefined for invalid hex', () => { | ||
const hex = '#ff00'; | ||
const alpha = 1; | ||
const rgba = hexToRgba(hex, alpha); | ||
expect(rgba).toBeUndefined(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const hexToRgba = (hex: string, alpha: number): number[] | undefined => { | ||
if (hex.length !== 7) { | ||
return; | ||
} | ||
const r = parseInt(hex.slice(1, 3), 16); | ||
const g = parseInt(hex.slice(3, 5), 16); | ||
const b = parseInt(hex.slice(5, 7), 16); | ||
return [r, g, b, alpha]; | ||
}; |