Skip to content

Commit

Permalink
changed embeded in html svg to object tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Zergatul committed Jan 25, 2022
1 parent 3edaaf3 commit de32c2c
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 654 deletions.
7 changes: 2 additions & 5 deletions docs/CustomizingMouse.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

Below is an example for mouse, but same logic applies to gamepad SVG.


All examples here are done in Inkscape. This is free and open-source vector graphics editor. You can use another editors, but you may need additional steps which are not covered here. In `wwwroot` directory you can find `mouse.svg`. You can open it in editor to understand how example mouse image works. In Objects window you can see some SVG paths are labeled Mouse1, Mouse2 and so on:
All examples here are done in Inkscape. This is free and open-source vector graphics editor. But you can use any SVG editor. In `wwwroot` directory you can find `mouse.svg`. You can open it in editor to understand how example mouse image works. In Objects window you can see some SVG paths are labeled Mouse1, Mouse2 and so on:

![ObjectsTree](https://github.com/Zergatul/Zergatul.Obs.InputOverlay/blob/master/docs/InkscapeObjectsTree.png?raw=true)

These labels are not required, but they will help you to quickly navigate inside SVG document. If you select one of these labeled paths, in Object Properties window you can see ID of an object:

![ObjectProperties](https://github.com/Zergatul/Zergatul.Obs.InputOverlay/blob/master/docs/InkscapeObjectProperties.png?raw=true)

These ID's are required. In javascript we search SVG elements by ID, and highlight them when buttons are pressed.

Now you can make some changes to example mouse, and try to replace existing mouse image in `default-mouse.html`. After you made some changes to SVG file, open it in any text editor. Copy entire `<svg>` element (this is entire file without first line). Open `default-mouse.html`, delete entire `<svg>` element and `Ctrl+V` another `<svg>` element. Save html file (maybe with different name) and check how it looks.
These ID's are required. In javascript we search SVG elements by ID, and highlight them when buttons are pressed. If javascript code cannot find button by ID, it will not be able to highlight it. Once you make some changes to the SVG, you can save it and check how it looks in browser or OBS. Don't forget to uncomment `background-color` CSS style if you want to check it in browser.
103 changes: 56 additions & 47 deletions src/wwwroot/gamepad.svg → src/wwwroot/XBoxSeriesXController.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 2 additions & 5 deletions src/wwwroot/common.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
function removeUnwantedSvgAttributes(svg) {
svg.removeAttribute('width');
svg.removeAttribute('height');
}
function attachSvgGlowDefinition(svgDoc) {

function attachSvgGlowDefinition(svg) {
let svg = svgDoc.rootElement;

let defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs');

Expand Down
Loading

0 comments on commit de32c2c

Please sign in to comment.