-
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.
Added background colour (pending gradient/pattern fills)
- Loading branch information
Showing
17 changed files
with
207 additions
and
12 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
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
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
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,98 @@ | ||
export class Background extends HTMLElement { | ||
static get observedAttributes () { | ||
return ['colour', 'color'] | ||
} | ||
|
||
constructor () { | ||
super() | ||
|
||
this.internal = { | ||
onChange: null, | ||
onChanged: null | ||
} | ||
|
||
const template = document.querySelector('#template-background') | ||
const stylesheet = document.createElement('link') | ||
const content = template.content | ||
const shadow = this.attachShadow({ mode: 'open' }) | ||
const clone = content.cloneNode(true) | ||
|
||
stylesheet.setAttribute('rel', 'stylesheet') | ||
stylesheet.setAttribute('href', '/css/components.css') | ||
|
||
shadow.appendChild(stylesheet) | ||
shadow.appendChild(clone) | ||
} | ||
|
||
connectedCallback () { | ||
const shadow = this.shadowRoot | ||
const rgb = shadow.querySelector('input#rgb') | ||
|
||
rgb.oninput = (event) => onChange(this) | ||
rgb.onchange = (event) => onChanged(this) | ||
} | ||
|
||
disconnectedCallback () { | ||
} | ||
|
||
adoptedCallback () { | ||
} | ||
|
||
attributeChangedCallback (name, from, to) { | ||
if (name === 'colour' || name === 'color') { | ||
this.colour = to | ||
} | ||
} | ||
|
||
get onchange () { | ||
return this.internal.onChange | ||
} | ||
|
||
set onchange (v) { | ||
this.internal.onChange = v | ||
} | ||
|
||
get onchanged () { | ||
return this.internal.onChanged | ||
} | ||
|
||
set onchanged (v) { | ||
this.internal.onChanged = v | ||
} | ||
|
||
get colour () { | ||
const shadow = this.shadowRoot | ||
const input = shadow.querySelector('input#rgb') | ||
const rgb = input.value | ||
|
||
return `${rgb}ff` | ||
} | ||
|
||
set colour (v) { | ||
const shadow = this.shadowRoot | ||
const input = shadow.querySelector('input#rgb') | ||
const match = `${v}`.match(/^#([a-fA-F0-9]{6})([a-fA-F0-9]{2})?$/) | ||
|
||
if (match != null) { | ||
const rgb = Number.parseInt(match[1], 16).toString(16).padStart(6, '0') | ||
|
||
input.value = `#${rgb}` | ||
} | ||
} | ||
} | ||
|
||
function onChange (component) { | ||
const colour = component.colour | ||
if (component.onchange) { | ||
component.onchange(colour) | ||
} | ||
} | ||
|
||
function onChanged (component) { | ||
const colour = component.colour | ||
if (component.onchanged) { | ||
component.onchanged(colour) | ||
} | ||
} | ||
|
||
customElements.define('wav2png-background', Background) |
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
2 changes: 1 addition & 1 deletion
2
webgpu/html/javascript/background.js → webgpu/html/javascript/fill.js
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
@charset "UTF-8"; | ||
|
||
$black: #222222; | ||
$white: #ffffff; | ||
$shadow: #11111111; | ||
$grey: grey; |
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,33 @@ | ||
fieldset.background { | ||
width: 100%; | ||
height: fit-content; | ||
border: 1px solid #c0c0c0; | ||
border-radius: 8px; | ||
|
||
padding-top: 4px; | ||
padding-bottom: 12px; | ||
padding-left: 12px; | ||
padding-right: 12px; | ||
|
||
legend { | ||
padding-left: 2px; | ||
padding-right: 2px; | ||
|
||
color: grey; | ||
font-family: sans-serif; | ||
font-style: italic; | ||
font-size: 0.8em; | ||
white-space: nowrap; | ||
} | ||
|
||
div { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
input[type="color"] { | ||
width: 48px; | ||
height: 48px; | ||
border: none; | ||
} | ||
} |
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