Recommendations for thickness control in pen
Root / Programming Questions / [.]
hakkeCreated:
I was doing a paint program and I wanted to put a velocity-controlled thickness pen, and I did it with the Euclidean distance formula and the GLINER function by ColeslawProductions, but sometimes, when the velocity is fast, the pen simply doesn't draws, there is any alternative?jesus christ you used my GLINER function that was a quick and dirty solution lolthat really needs to be fixed to be honest!
BTW you can actually implement the distance formula with DISTANCE() included in DEFY anyway ;D
(i should know, it's called every time GLINER draws an individual GLINE command)
It does a grid loop, in a square block, the width of which is equal to the draw thickness.
It goes through each of the grid and checks if its distance from the center is less than the thickness, if so, It draws an offset GLINE at the given position.
It could be made faster by using a sine/cosine calculation around the circumfrence of the circle.
The problem, there needs to be a filled circle drawn at one end of the line.
The reason, if the circular ends of the thick line overlap, you'd see it. Since it's only when they overlap though, it only needs to be drawn around one of the points, and the problem will be solved.
I was too lazy to go through this and just used the function as it was because I tolerated it, but now since it's out being used practically apparently, it needs to be fixed.
You could probably use 2 GRIs, 4 GCIRCLEs, and 2 GPAINTs to draw a line with any thickness.
Use the triangles to draw the rectangular part, and filled circles can be:
DEF GFILLCIRCLE X,Y,R,C GCIRCLE X,Y,R,8 GPAINT X,Y,C,8 GCIRCLE X,Y,R,C END8 is the color A:0 R:0 G:0 B:1, which is assumed to not be used elsewhere. Since there's no reason to use a color that's transparent but still has the blue value set, it's safe.