pref: 针对 HiDPI 屏幕捕获的优化。
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
import { listen } from '@tauri-apps/api/event';
|
||||
import {
|
||||
Component,
|
||||
createEffect,
|
||||
@ -8,7 +7,6 @@ import {
|
||||
createSignal,
|
||||
For,
|
||||
JSX,
|
||||
onCleanup,
|
||||
splitProps,
|
||||
useContext,
|
||||
} from 'solid-js';
|
||||
@ -77,9 +75,15 @@ export const LedStripPart: Component<LedStripPartProps> = (props) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const offset = mapper.pos;
|
||||
const offset = mapper.pos * 3;
|
||||
|
||||
const colors = new Array(localProps.config.len).fill(null).map((_, i) => {
|
||||
const index = offset + i * 3;
|
||||
return `rgb(${ledStripStore.colors[index]}, ${ledStripStore.colors[index + 1]}, ${
|
||||
ledStripStore.colors[index + 2]
|
||||
})`;
|
||||
});
|
||||
|
||||
const colors = ledStripStore.colors.slice(offset, offset + localProps.config.len);
|
||||
setColors(colors);
|
||||
});
|
||||
|
||||
|
@ -115,12 +115,21 @@ const SorterItem: Component<{ strip: LedStripConfig; mapper: LedStripPixelMapper
|
||||
// update fullLeds
|
||||
createEffect(() => {
|
||||
const fullLeds = new Array(ledStripStore.totalLedCount).fill(null);
|
||||
const colors = ledStripStore.colors;
|
||||
|
||||
const { start, end, pos } = props.mapper;
|
||||
const isForward = start < end;
|
||||
const step = isForward ? 1 : -1;
|
||||
for (let i = start, j = pos; i !== end; i += step, j++) {
|
||||
fullLeds[i] = ledStripStore.colors[j];
|
||||
let c1 = `rgb(${Math.floor(colors[j * 3] * 0.8)}, ${Math.floor(
|
||||
colors[j * 3 + 1] * 0.8,
|
||||
)}, ${Math.floor(colors[j * 3 + 2] * 0.8)})`;
|
||||
let c2 = `rgb(${Math.min(Math.floor(colors[j * 3] * 1.2), 255)}, ${Math.min(
|
||||
Math.floor(colors[j * 3 + 1] * 1.2),
|
||||
255,
|
||||
)}, ${Math.min(Math.floor(colors[j * 3 + 2] * 1.2), 255)})`;
|
||||
|
||||
fullLeds[i] = `linear-gradient(70deg, ${c1} 10%, ${c2})`;
|
||||
}
|
||||
|
||||
setFullLeds(fullLeds);
|
||||
|
Reference in New Issue
Block a user