Spray painting simulation and thickness evaluation
7 views (last 30 days)
Show older comments
I want to simulate a spray painting, like a “brushes” in “paint” program, by using the left mouse.
The idea is that when I click and hold the left mouse, color is continuously sprayed and its coating stroke is uniformed. The thickness is reflected through color intensity
3 Comments
Image Analyst
on 20 Dec 2023
OK, I think you meant "stroke thickness setting". But I don't know how to do it. I'd just use Photoshop for something like that.
Accepted Answer
Angelo Yeo
on 20 Dec 2023
Maybe some basic approach is to use a button down callback and scatter dots that are randomly sampled from normal distribution. Below is my simple implementation of the idea. Good luck.
clear; close all;
I = zeros(1000, 1000);
imagesc(1:1000, 1:1000, I, 'ButtonDownFcn', @sprayCallback);
clim([0, 1]);
colormap([1,1,1; 0,0,0])
axis([0, 1000, 0, 1000])
hold on;
function sprayCallback(h, ~)
cursorLocation = get(ancestor(h, 'axes'),'CurrentPoint');
x = cursorLocation(1, 1);
y = cursorLocation(1, 2);
radius = 30;
scatter(randn(100, 1) * radius + x, randn(100,1) * radius + y, 1, [0,0,0], 'filled', 's')
end
6 Comments
More Answers (0)
See Also
Categories
Find more on Red in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
