Subcommittee’s solution sounds like it will work for the way you’re tackling it.
Edit: those gaps at the higher speeds are pretty bad… hmmm
I’ve actually been working on a roblox art canvas most the day. I just about finished the rendering bit, so I’ll get back to you on the drawing. I’m storing the state of each pixel, rendering them with a frame, and then updating that frame whenever the associated pixel changes. Right now I’m thinking I could leave out frames that are the same color as the canvas and possibly combine frames of the same color if possible… if it isn’t more costly to compute than rendering the individual frames.
This isn’t a problem which is unique to roblox. Mice aren’t as smooth as one might expect!
The solution is, as mentioned, to draw a line between the two points. You don’t have to do any plotting, or regression lines. Two points = a line segment. It’s as straightforward as that.
You can compare it to mspaint. Wiggle your mouse around quite fast while using the pencil, and you’ll see distinct lines. And when you move the pencil around more slowly, it looks very natural and smooth!
I see what blobbyblob means. I just did a test with a 1,000 frame mouse trail. The mouse input just isn’t updated frequently enough.
local player = game.Players.LocalPlayer
local gui = Instance.new("ScreenGui")
gui.Parent = player.PlayerGui
local loop = Instance.new("BindableEvent")
local mouse = player:GetMouse()
local frames = {}
local c = 1
local maxFrames = 1000
loop.Event:connect(function()
spawn(function()
loop:Fire()
local frame = nil
if #frames < maxFrames then
frame = Instance.new("Frame")
frame.Size = UDim2.new(0,5,0,5)
frame.Parent = gui
table.insert(frames, frame)
else
frame = frames[c]
c = c + 1
if c > maxFrames then
c = 1
end
end
frame.Position = UDim2.new(0, mouse.X, 0, mouse.Y)
end)
end)
loop:Fire()
Instead of creating frames when the mouse moves, try creating them beforehand and changing them to visible and move them to the correct position when you need them.
[quote] I see what blobbyblob means. I just did a test with a 1,000 frame mouse trail. The mouse input just isn’t updated frequently enough.
[code]
local player = game.Players.LocalPlayer
local gui = Instance.new(“ScreenGui”)
gui.Parent = player.PlayerGui
local loop = Instance.new(“BindableEvent”)
local mouse = player:GetMouse()
local frames = {}
local c = 1
local maxFrames = 1000
loop.Event:connect(function()
spawn(function()
loop:Fire()
local frame = nil
if #frames < maxFrames then
frame = Instance.new(“Frame”)
frame.Size = UDim2.new(0,5,0,5)
frame.Parent = gui
table.insert(frames, frame)
else
frame = frames[c]
c = c + 1
if c > maxFrames then
c = 1
end
end
frame.Position = UDim2.new(0, mouse.X, 0, mouse.Y)
end)
end)
loop:Fire()
[/code] [/quote]
First of all, you’re using a massive super-deep recursive blob of code that doesn’t use UserInputService which will fire every time user input changes
This isn’t a problem with the API, just use lines or research curve fitting with mouse input
First of all, you’re using a massive super-deep recursive blob of code that doesn’t use UserInputService which will fire every time user input changes
This isn’t a problem with the API, just use lines or research curve fitting with mouse input [/quote]
I realize that, I just wanted to make sure the issue wasn’t the speed at which the input was being retrieved. That recursive mess runs pretty darn fast without crashing or pausing.
I was curious if my graphics tablet could provide more precise mouse movement since this problem isn’t apparent while drawing in any programs, but it’s about the same. Graphics applications must rely on the tablet drivers for more precise movement rather than the actual movement of the windows mouse… But this is all observation. I don’t know what i’m talking about.
First of all, you’re using a massive super-deep recursive blob of code that doesn’t use UserInputService which will fire every time user input changes
This isn’t a problem with the API, just use lines or research curve fitting with mouse input [/quote]
I realize that, I just wanted to make sure the issue wasn’t the speed at which the input was being retrieved. That recursive mess runs pretty darn fast without crashing or pausing.
I was curious if my graphics tablet could provide more precise mouse movement since this problem isn’t apparent while drawing in any programs, but it’s about the same. Graphics applications must rely on the tablet drivers for more precise movement rather than the actual movement of the windows mouse… But this is all observation. I don’t know what i’m talking about. :p[/quote]
It’s also possible they draw something like bezier curves between points; it’s hard to tell the difference