node-stylus
v1.0.3
Published
A cross-platform library for virtual stylus input on Windows and macOS
Downloads
9
Maintainers
Readme
node-stylus
Windows와 macOS에서 가상 스타일러스 입력을 시뮬레이션하기 위한 Node.js 네이티브 애드온입니다. 이 라이브러리를 사용하면 압력 감지 기능이 있는 펜/스타일러스 입력 이벤트를 프로그래밍 방식으로 시뮬레이션할 수 있습니다.
특징
- Windows와 macOS 크로스 플랫폼 지원
- 사용자 정의 좌표로 펜/스타일러스 입력 이벤트 시뮬레이션
- 압력 감도 지원 (0.0 - 1.0)
- Electron 애플리케이션과 쉽게 통합
설치
npm install node-stylus사용 방법
const nodeStylus = require('node-stylus');
// 펜 디바이스 초기화 (Windows에서 필수)
const initialized = nodeStylus.initPenDevice();
console.log(`펜 디바이스 초기화 상태: ${initialized}`);
// 좌표와 압력을 통한 펜 이벤트 전송
// 매개변수: x, y, pressure (0.0에서 1.0 사이)
nodeStylus.sendPenEvent(100, 200, 0.5);Electron 애플리케이션에서 사용하기
const { app, BrowserWindow } = require('electron');
const nodeStylus = require('node-stylus');
const path = require('path');
app.whenReady().then(() => {
// 가능한 빨리 펜 디바이스 초기화
nodeStylus.initPenDevice();
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
});
// 이제 nodeStylus.sendPenEvent()를 사용하여 펜 입력을 시뮬레이션할 수 있습니다
});API
nodeStylus.initPenDevice()
가상 펜 디바이스를 초기화합니다. 펜 이벤트를 보내기 전에 Windows에서는 반드시 필요합니다.
반환값: boolean - 초기화가 성공적이면 true.
nodeStylus.sendPenEvent(x, y, pressure)
지정된 좌표에 주어진 압력으로 가상 펜 이벤트를 전송합니다.
매개변수:
x(number): 펜 이벤트의 X 좌표y(number): 펜 이벤트의 Y 좌표pressure(number, 옵션): 0.0에서 1.0 사이의 압력 값. 기본값은 1.0.
반환값: boolean - 이벤트가 성공적으로 전송되었으면 true.
플랫폼별 세부 사항
Windows
Windows 포인터 API를 사용하여 펜 입력 이벤트를 시뮬레이션합니다. Windows 8 이상 필요.
macOS
CoreGraphics API를 사용하여 태블릿 포인터 이벤트를 시뮬레이션합니다.
라이센스
MIT
