Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated hat shapes #1868

Merged
merged 39 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
447e0ca
Updated hat shape svg and associated settings
AndreasArvidsson Sep 8, 2023
a77ecc5
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Sep 8, 2023
c5554da
Update hole
AndreasArvidsson Sep 8, 2023
94534ac
Merge branch 'main' into updatedHatShapes
AndreasArvidsson Sep 8, 2023
04d8741
Update replace
AndreasArvidsson Sep 8, 2023
1654726
Replace with space
AndreasArvidsson Sep 8, 2023
a7f4661
Updated regex
AndreasArvidsson Sep 9, 2023
d5f5156
Updated preprocess script
AndreasArvidsson Sep 9, 2023
bc5d0e2
Merge branch 'main' into updatedHatShapes
AndreasArvidsson Sep 9, 2023
c46dafe
Removed clip rectangle
AndreasArvidsson Sep 9, 2023
0fad9b7
Update hole
AndreasArvidsson Sep 9, 2023
6dae082
Update frame size
AndreasArvidsson Sep 9, 2023
8aacef0
Rebalance frame
AndreasArvidsson Sep 11, 2023
97394c3
update
AndreasArvidsson Sep 11, 2023
880d658
Merge branch 'main' into updatedHatShapes
AndreasArvidsson Sep 12, 2023
aa27b01
Added changelog
AndreasArvidsson Sep 12, 2023
9db047e
Update changelog/2023-09-updatedHatShapes.md
AndreasArvidsson Sep 14, 2023
64d2131
Fix preprocess script
pokey Sep 14, 2023
65f9a4d
Merge branch 'main' into updatedHatShapes
AndreasArvidsson Sep 15, 2023
3a857fa
Update hole
AndreasArvidsson Sep 16, 2023
0b93152
Update eye
AndreasArvidsson Sep 16, 2023
6568e77
Update frame
AndreasArvidsson Sep 16, 2023
b594b30
Update crosshairs
AndreasArvidsson Sep 16, 2023
1c4be3a
fix script
AndreasArvidsson Oct 3, 2023
e38a1a7
Update hats
AndreasArvidsson Oct 3, 2023
d14cbeb
Updates script path
AndreasArvidsson Oct 3, 2023
17456c0
2.6 shapes
AndreasArvidsson Oct 17, 2023
461b98c
Up date shape adjustment
AndreasArvidsson Oct 17, 2023
b957096
Merge branch 'main' into updatedHatShapes
AndreasArvidsson Oct 17, 2023
6eeb84a
change alignment
AndreasArvidsson Oct 17, 2023
887a3ae
Update default dark theme color
AndreasArvidsson Oct 18, 2023
f0f65ed
Update order and sizes
AndreasArvidsson Oct 19, 2023
c03ed11
Remove offsets
AndreasArvidsson Oct 19, 2023
0b684a9
Update shapes
AndreasArvidsson Oct 23, 2023
ddfaf5e
Revert "Update shapes"
AndreasArvidsson Oct 23, 2023
0c6cdce
Initial attempt to show message
pokey Oct 23, 2023
3731151
tweak
pokey Oct 23, 2023
c4761ed
tweak
pokey Oct 23, 2023
a4a417c
tweak
pokey Oct 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions data/playground/hat-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4 changes: 3 additions & 1 deletion images/hats/bolt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion images/hats/crosshairs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion images/hats/curve.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion images/hats/default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion images/hats/ex.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion images/hats/eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion images/hats/fox.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion images/hats/frame.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion images/hats/hole.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion images/hats/play.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion images/hats/wing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,16 @@ export default class VscodeHatRenderer {

private constructColoredSvgDataUri(originalSvg: string, color: string) {
if (
originalSvg.match(/fill="[^"]+"/) == null &&
originalSvg.match(/fill:[^;]+;/) == null
originalSvg.match(/fill="(?!none)[^"]+"/) == null &&
originalSvg.match(/fill:(?!none)[^;]+;/) == null
) {
throw Error("Raw svg doesn't have fill");
}

const svg = originalSvg
.replace(/fill="[^"]+"/, `fill="${color}"`)
.replace(/fill:[^;]+;/, `fill:${color};`);
AndreasArvidsson marked this conversation as resolved.
Show resolved Hide resolved
.replace(/fill="(?!none)[^"]+"/g, `fill="${color}"`)
.replace(/fill:(?!none)[^;]+;/g, `fill:${color};`)
.replace(/\r?\n/g, " ");

const encoded = encodeURIComponent(svg);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,52 @@ export interface HatAdjustments {

export type IndividualHatAdjustmentMap = Record<HatShape, HatAdjustments>;

export const DEFAULT_HAT_HEIGHT_EM = 0.29;
export const DEFAULT_HAT_HEIGHT_EM = 0.38;
export const DEFAULT_VERTICAL_OFFSET_EM = 0.032;

export const defaultShapeAdjustments: IndividualHatAdjustmentMap = {
default: {
sizeAdjustment: -14,
verticalOffset: -0.35,
sizeAdjustment: -15,
pokey marked this conversation as resolved.
Show resolved Hide resolved
verticalOffset: 0,
},
ex: {
sizeAdjustment: 10,
sizeAdjustment: 0,
verticalOffset: 0,
},
fox: {
sizeAdjustment: 10,
sizeAdjustment: 0,
verticalOffset: 0,
},
wing: {
sizeAdjustment: 15.5,
verticalOffset: 1.1,
sizeAdjustment: 0,
verticalOffset: 0,
},
hole: {
sizeAdjustment: 32.5,
verticalOffset: -2,
sizeAdjustment: 0,
verticalOffset: 0,
},
frame: {
sizeAdjustment: -15,
verticalOffset: -2.25,
sizeAdjustment: -10,
verticalOffset: 0,
},
curve: {
sizeAdjustment: -21,
verticalOffset: -3.15,
sizeAdjustment: 0,
verticalOffset: -5,
},
eye: {
sizeAdjustment: -6.5,
verticalOffset: -1,
sizeAdjustment: 0,
verticalOffset: 0,
},
play: {
sizeAdjustment: -8,
verticalOffset: -0.5,
sizeAdjustment: 0,
verticalOffset: 0,
},
bolt: {
sizeAdjustment: 22.5,
sizeAdjustment: 0,
verticalOffset: 0,
},
crosshairs: {
sizeAdjustment: 29.5,
verticalOffset: -1,
sizeAdjustment: 0,
verticalOffset: 0,
},
};
5 changes: 3 additions & 2 deletions packages/cursorless-vscode/src/scripts/preprocessSvgHats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ async function main() {
const dumper = new parser.XMLBuilder({
ignoreAttributes: false,
suppressEmptyNode: true,
format: true,
});

readdirSync(directory, { withFileTypes: true }).forEach(async (dirent) => {
Expand All @@ -30,8 +31,8 @@ async function main() {

const outputSvg = dumper
.build(svgJson)
.replace(/fill="[^"]+"/, `fill="#666666"`)
.replace(/fill:[^;]+;/, `fill:#666666;`);
.replace(/fill="(?!none)[^"]+"/g, 'fill="#666666"')
.replace(/fill:(?!none)[^;]+;/g, "fill:#666666;");

await fsp.writeFile(filePath, outputSvg);
});
Expand Down