Click here to Skip to main content
15,886,110 members

Comments by 0x01AA (Top 200 by date)

0x01AA 2 days ago View    
Most probably you have reasons why you use JS Canvas.

Only as a hint: Using SVG can make your life more easy. With SVG you can define a so called 'viewBox'. This frees you from the constant conversion and rethinking of a Cartesian coordinate (with origin in left bottom) system to screen coordinates (with origin left top). Also for scaling you don't have to bother, once the 'viewBox' is defined.

I hope you can understand my cryptic English ;)
0x01AA 2 days ago View    
I expected this will come ;)

start angle: Math.asin(opposite/hypotenuse)
end angle: pi - start angle

where in the formula above:
opposite is b/4
and hypotenuse is the radius of the circle, therefore b/2

[Edit]
(b/4)/(b/2)= 2/4= 0.5
Start: asin(0.5) = 0.5236
End: pi - 0.5236= 2.618

[Edit1]
Taking into acount the inversed y axis it should than be more:
ctx.arc(100, 75, 50, -0.5236, 0.5236-Math.PI, true);

See here for more background:
Trigonometry - Wikipedia[^]
0x01AA 2 days ago View    
Without guarantee and not verified, but the idea should be ok:
You know the vertical distance from the center of the circle where it crosses the top line: b/4
You know the raduis of the circle: b/2
With this you have the horizontal distance where the circle crosses the top line.
Pyhtagoras: r^2 - (b/4)^2= (b/2)^2- (b/4=^2= b^2/4 - b^2/16= 4b^2/16-b^2/16= 3b^2/16
Horizontal distance of the crossing point from center= Sqrt(3b^2/16)
0x01AA 19-Apr-24 11:34am View    
Quote: "The conversion is as easy as already answered but you need to take care when making it to a COLORREF again"

Nope:
COLREF do have always the byte order BGR (ABGR), and assigning it to and from an int does note change it.
0x01AA 15-Apr-24 14:11pm View    
I don't recognize an SQL statement .... ?