Skip to content

Commit 25001d5

Browse files
committed
Add web rendered trail,remove crop
1 parent 9650127 commit 25001d5

File tree

14 files changed

+1427
-122
lines changed

14 files changed

+1427
-122
lines changed

README.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
Fork by 3_4_700, original by upgradeQ
2-
The main purpose of this fork is to be able to make a precise custom cursor, like a handdrawn arm holding a pen for artists
3-
41
# OBS Studio Cursor skin
52
Selected source will follow mouse pointer.
63
Using [`obs_sceneitem_set_pos`](https://obsproject.com/docs/reference-scenes.html#c.obs_sceneitem_set_pos)
@@ -11,31 +8,27 @@ Using [`obs_sceneitem_set_pos`](https://obsproject.com/docs/reference-scenes.htm
118
# Limitations
129
- Multiple monitors setup will not work .
1310
- If used in fullscreen apps, offset will appear.
14-
- Current code only works for 1920x1080 res
1511
# Usage
1612
- Create a _source_ with desired cursor(e.g Image source or Media source).
1713
- In scripts select _that_ source name.
18-
- Make a group, add Display Capture, Window Capture
14+
- Make a group, add Display Capture, Window Capture.
1915

2016
![img](https://i.imgur.com/CHuLwmp.png)
2117

2218
- To crop, crop the _group_, the size should still have the same ratio as your monitor even if you scale it
23-
- To set offset/calibrate, use the Display Capture to see mouse and adjust it at Scripts (or use Tab/Shift+tab to navigate if in Window Capture to not move mouse). You have to do this every time you change the Group scale/move the Group
19+
- To set offset/calibrate, use the Display Capture to see mouse and adjust it at Scripts (or use Tab/Shift+tab to navigate, if in Window Capture, to not move mouse). You have to do this every time you change the Group scale/move it
2420

2521
![img](https://user-images.githubusercontent.com/66927691/121442471-56133280-c9be-11eb-9bb4-ad12b2e4ebfb.jpg)
2622

2723
![img](https://user-images.githubusercontent.com/66927691/121442809-f23d3980-c9be-11eb-954f-c0e635e95d88.jpg)
2824

2925

3026
- Test it: press Start, press Stop, tweak refresh rate.
31-
# Crop auto update
32-
Zoom or higlight.
33-
- Create 2 display captures.
34-
- Create crop filter with this name: `cropXY`.
35-
- Check relative.
36-
- Set Width and Height to relatively small numbers e.g : 64x64 .
37-
- Image mask blend + color correction might be an option too.
38-
- Run script,select this source as cursor source , check Update crop, click start.
27+
28+
# Web rendered mouse cursor trails
29+
- Add browser source with mouse tracking local or online web page.
30+
- Make sure to set resolution as your monitor (base)
31+
- Fill all entries, check `Use browser source`
3932

4033
# Zoom
4134
> Have you ever needed to zoom in on your screen to show some fine detail work,
@@ -53,6 +46,16 @@ They all have some level of transparency.
5346
![img](https://i.imgur.com/8qoRU3i.png)
5447
- green circle
5548
![Imgur](https://i.imgur.com/s3jvZP5.png)
49+
50+
# On the Roadmap
51+
- Visual indicator of mouse up/down state.
52+
- Lua based shaders rendering (on mouse up, down, trail, etc...)
53+
- Custom web page rendering (on mouse up, down, trail, etc...)
54+
55+
# Acknowledgments
56+
- [`3_4_700`](https://github.com/34700) added offsets functionality for precise custom cursor(like a hand drawn arm holding a pen for artists)
57+
- [`tholman/cursor-effects`](https://github.com/tholman/cursor-effects) - stock cursor trails
58+
5659
# Contribute
5760
[Forks](https://help.github.com/articles/fork-a-repo) are a great way to contribute to a repository.
5861
After forking a repository, you can send the original author a [pull request](https://help.github.com/articles/using-pull-requests)

cursor_effects_ported/buble.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Buble cursor</title>
6+
<script src="./cursor-effects-master/src/bubbleCursor.js"></script>
7+
<style>
8+
html, body {
9+
height: 100%;
10+
width: 100%;
11+
padding: 0; margin: 0; /* reset the default stylesheet */
12+
}
13+
</style>
14+
</head>
15+
<body>
16+
<script> new bubbleCursor(); </script>
17+
</body>
18+
</html>
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
function bubbleCursor(options) {
2+
let hasWrapperEl = options && options.element
3+
let element = hasWrapperEl || document.body
4+
5+
let width = window.innerWidth
6+
let height = window.innerHeight
7+
let cursor = { x: width / 2, y: width / 2 }
8+
let particles = []
9+
let canvas, context
10+
11+
let canvImages = []
12+
13+
function init(wrapperEl) {
14+
canvas = document.createElement("canvas")
15+
context = canvas.getContext("2d")
16+
17+
canvas.style.top = "0px"
18+
canvas.style.left = "0px"
19+
canvas.style.pointerEvents = "none"
20+
21+
if (hasWrapperEl) {
22+
canvas.style.position = "absolute"
23+
element.appendChild(canvas)
24+
canvas.width = element.clientWidth
25+
canvas.height = element.clientHeight
26+
} else {
27+
canvas.style.position = "fixed"
28+
document.body.appendChild(canvas)
29+
canvas.width = width
30+
canvas.height = height
31+
}
32+
33+
bindEvents()
34+
loop()
35+
}
36+
37+
// Bind events that are needed
38+
function bindEvents() {
39+
element.addEventListener("mousemove", onMouseMove)
40+
element.addEventListener("touchmove", onTouchMove)
41+
element.addEventListener("touchstart", onTouchMove)
42+
window.addEventListener("resize", onWindowResize)
43+
}
44+
45+
function onWindowResize(e) {
46+
width = window.innerWidth
47+
height = window.innerHeight
48+
49+
if (hasWrapperEl) {
50+
canvas.width = element.clientWidth
51+
canvas.height = element.clientHeight
52+
} else {
53+
canvas.width = width
54+
canvas.height = height
55+
}
56+
}
57+
58+
function onTouchMove(e) {
59+
if (e.touches.length > 0) {
60+
for (let i = 0; i < e.touches.length; i++) {
61+
addParticle(
62+
e.touches[i].clientX,
63+
e.touches[i].clientY,
64+
canvImages[Math.floor(Math.random() * canvImages.length)]
65+
)
66+
}
67+
}
68+
}
69+
70+
function onMouseMove(e) {
71+
if (hasWrapperEl) {
72+
const boundingRect = element.getBoundingClientRect()
73+
cursor.x = e.clientX - boundingRect.left
74+
cursor.y = e.clientY - boundingRect.top
75+
} else {
76+
cursor.x = e.clientX
77+
cursor.y = e.clientY
78+
}
79+
80+
addParticle(cursor.x, cursor.y)
81+
}
82+
83+
function addParticle(x, y, img) {
84+
particles.push(new Particle(x, y, img))
85+
}
86+
87+
function updateParticles() {
88+
context.clearRect(0, 0, width, height)
89+
90+
// Update
91+
for (let i = 0; i < particles.length; i++) {
92+
particles[i].update(context)
93+
}
94+
95+
// Remove dead particles
96+
for (let i = particles.length - 1; i >= 0; i--) {
97+
if (particles[i].lifeSpan < 0) {
98+
particles.splice(i, 1)
99+
}
100+
}
101+
}
102+
103+
function loop() {
104+
updateParticles()
105+
requestAnimationFrame(loop)
106+
}
107+
108+
function Particle(x, y, canvasItem) {
109+
const lifeSpan = Math.floor(Math.random() * 60 + 60)
110+
this.initialLifeSpan = lifeSpan //
111+
this.lifeSpan = lifeSpan //ms
112+
this.velocity = {
113+
x: (Math.random() < 0.5 ? -1 : 1) * (Math.random() / 10),
114+
y: -0.4 + Math.random() * -1,
115+
}
116+
this.position = { x: x, y: y }
117+
this.canv = canvasItem
118+
119+
this.baseDimension = 4
120+
121+
this.update = function(context) {
122+
this.position.x += this.velocity.x
123+
this.position.y += this.velocity.y
124+
this.velocity.x += ((Math.random() < 0.5 ? -1 : 1) * 2) / 75
125+
this.velocity.y -= Math.random() / 600
126+
this.lifeSpan--
127+
128+
const scale =
129+
0.2 + (this.initialLifeSpan - this.lifeSpan) / this.initialLifeSpan
130+
131+
context.fillStyle = "#e6f1f7"
132+
context.strokeStyle = "#3a92c5"
133+
context.beginPath()
134+
context.arc(
135+
this.position.x - (this.baseDimension / 2) * scale,
136+
this.position.y - this.baseDimension / 2,
137+
this.baseDimension * scale,
138+
0,
139+
2 * Math.PI
140+
)
141+
142+
context.stroke()
143+
context.fill()
144+
145+
context.closePath()
146+
}
147+
}
148+
149+
init()
150+
}

0 commit comments

Comments
 (0)