style: lighten web LIGHTS arc rendering
This commit is contained in:
@@ -513,7 +513,8 @@ function prepareLightArcCanvas(){
|
|||||||
function canvasArcAngle(degrees,bearing){
|
function canvasArcAngle(degrees,bearing){
|
||||||
return (degrees + bearing - 90) * Math.PI / 180;
|
return (degrees + bearing - 90) * Math.PI / 180;
|
||||||
}
|
}
|
||||||
function drawCaArc(ctx,x,y,radius,startDeg,endDeg,bearing,color,width){
|
function drawCaArc(ctx,x,y,radius,startDeg,endDeg,bearing,color,width,alpha){
|
||||||
|
ctx.save();
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(
|
ctx.arc(
|
||||||
x,y,radius,
|
x,y,radius,
|
||||||
@@ -522,9 +523,11 @@ function drawCaArc(ctx,x,y,radius,startDeg,endDeg,bearing,color,width){
|
|||||||
false
|
false
|
||||||
);
|
);
|
||||||
ctx.strokeStyle=color;
|
ctx.strokeStyle=color;
|
||||||
|
ctx.globalAlpha=alpha==null?1:alpha;
|
||||||
ctx.lineWidth=width;
|
ctx.lineWidth=width;
|
||||||
ctx.lineCap="butt";
|
ctx.lineCap="butt";
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
|
ctx.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawCaLeg(ctx,x,y,length,degrees,bearing){
|
function drawCaLeg(ctx,x,y,length,degrees,bearing){
|
||||||
@@ -535,7 +538,8 @@ function drawCaLeg(ctx,x,y,length,degrees,bearing){
|
|||||||
ctx.moveTo(x,y);
|
ctx.moveTo(x,y);
|
||||||
ctx.lineTo(x+length*Math.cos(angle),y+length*Math.sin(angle));
|
ctx.lineTo(x+length*Math.cos(angle),y+length*Math.sin(angle));
|
||||||
ctx.strokeStyle=CA_COLOR.CHBLK;
|
ctx.strokeStyle=CA_COLOR.CHBLK;
|
||||||
ctx.lineWidth=2;
|
ctx.globalAlpha=0.82;
|
||||||
|
ctx.lineWidth=1.35;
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
@@ -570,8 +574,12 @@ function drawLightArcFeature(ctx,feature,bearing,width,height){
|
|||||||
if(end<=start)end+=360;
|
if(end<=start)end+=360;
|
||||||
const arcColor=CA_COLOR[args.length>=8?args[2]:props.s52_arc_color] || CA_COLOR.CHMGD;
|
const arcColor=CA_COLOR[args.length>=8?args[2]:props.s52_arc_color] || CA_COLOR.CHMGD;
|
||||||
const outlineColor=CA_COLOR[args.length>=8?args[0]:props.s52_arc_outline_color] || CA_COLOR.OUTLW;
|
const outlineColor=CA_COLOR[args.length>=8?args[0]:props.s52_arc_outline_color] || CA_COLOR.OUTLW;
|
||||||
drawCaArc(ctx,point.x,point.y,radius,start,end,bearing,outlineColor,metrics.arcWidth+metrics.outlineWidth);
|
// Keep the S-52 CA radius/angles intact, but map millimetre pen widths to a
|
||||||
drawCaArc(ctx,point.x,point.y,radius,start,end,bearing,arcColor,metrics.arcWidth);
|
// lighter screen preview. Raw OUTLW=4 can otherwise dominate the chart.
|
||||||
|
const visualArcWidth=Math.max(1.6,Math.min(3.0,metrics.arcWidth*0.90));
|
||||||
|
const visualOutlineExtra=Math.max(2.6,Math.min(4.2,metrics.outlineWidth*0.38));
|
||||||
|
drawCaArc(ctx,point.x,point.y,radius,start,end,bearing,outlineColor,visualArcWidth+visualOutlineExtra,0.88);
|
||||||
|
drawCaArc(ctx,point.x,point.y,radius,start,end,bearing,arcColor,visualArcWidth,0.94);
|
||||||
if(sectorRadius>0){
|
if(sectorRadius>0){
|
||||||
drawCaLeg(ctx,point.x,point.y,sectorRadius,start,bearing);
|
drawCaLeg(ctx,point.x,point.y,sectorRadius,start,bearing);
|
||||||
drawCaLeg(ctx,point.x,point.y,sectorRadius,end,bearing);
|
drawCaLeg(ctx,point.x,point.y,sectorRadius,end,bearing);
|
||||||
|
|||||||
Reference in New Issue
Block a user