LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

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?

use a better function, I guess EDIT: well that was a completely useless answer. I think the problem is probably that GLINER tries to draw a 0 thickness line when the thickness is below 1. Try using CEIL()

The key of the extract is J3EKEXA1

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!

Yeah I noticed it doesn't draw with a radius of 0 when it really should but anyway, the whole function should be rewritten because it's hideously inefficient i didn't think anyone would use it seriously

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.

Btw, from how it's coded, the line thickness is supposed to scale like this.

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
END
8 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.

irrelevanceIt took me a second to comprehend that. xD I didn't know GPAINT had a border color option, but it's there. Anyway I made this illustration to avoid this case thought it's already taken care of but dangit i made it already and I'm posting it xD I was actually gonna suggest a more convoluted, slow solution that would involve GSAVE and GLOAD like, twice each
Anyway now this just means we have to calculate the coordinates of the GTRI commands which shouldn't be too difficult. Throw in an ATAN, maybe a SIN and COS and badabingbadaboom you got your GTRI coordinates.

Adding if this helps.

When finished calculating P2,P3,P4 and P5 from P0 and P1, -Draw the filled circles at P0 and P1 -Draw a triangle with points P2, P3, and P4, and another triangle with points P3, P4, and P5.

OK thanks

The main problem is that the triangles might not line up perfectly in the middle.

The main problem is that the triangles might not line up perfectly in the middle.
From when I was messing around with DEFY3D, I've yet to see that be a problem.