微信截图pos值转换

微信截图生成的 pos 值来转换为 HTML 的 coords
需要进行一定的调整,因为两者的坐标系统可能有所不同。

微信截图的 pos

微信截图的 pos 值通常是以某种形式表示的区域坐标,可能包括位置的左上角和右下角坐标。
例如,pos: [x1, y1, x2, y2] 表示一个矩形区域。

如何转换成 HTML 的 coords

  1. 矩形区域 (rect): - 微信坐标:pos: [x1, y1, x2, y2] - HTML coordscoords="x1,y1,x2,y2"
  2. 圆形区域 (circle): - 如果 pos 表示的是某个点的坐标和半径,你需要把它按照 coords="x,y,r" 的格式填写。
  • 示例:如果你有 pos: [x, y] 和半径 r,则 coords 可以写为 coords="x,y,r"
  1. 多边形区域 (poly):
  • 如果 pos 是一系列顶点的坐标,你只需要将这些坐标提取并用逗号分隔:
  • 示例:pos: [x1, y1, x2, y2, x3, y3] 应改为 coords="x1,y1,x2,y2,x3,y3"
  • 假设你的微信截图 pos 值是:pos: [50, 50, 250, 200],你想将其转换为 HTML 的 coords 值。
<area shape="rect" coords="50,50,250,200" href="https://www.example.com" alt="链接"> 
  • 注意事项

  1. 坐标系统:确保你理解微信截图坐标是相对于图像大小的,而 HTML 中的坐标是基于网页布局的。
  2. 响应式设计:如果图像是响应式的,可能需要使用 JavaScript 来调整 coords,以适应不同屏幕尺寸。

举例代码:

<!DOCTYPE html>

<html lang="zh">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>热点链接图片示例</title>

    <style>

        body {

            display: flex;

            justify-content: center;

            align-items: center;

            height: 100vh;

            background-color: #f0f0f0;

        }

        img {

            max-width: 800px;

        }

    </style>

</head>

<body>

  

<a href="https://www.baidu.com" target="_blank">

    <img src="1.jpg" alt="热点链接图片" usemap="#image-map">

</a>

  

<map name="image-map">

    <area shape="rect" coords="13,11,165,144" href="https://www.baidu.com" alt="链接1">

    <area shape="rect" coords="325,5,479,148" href="https://blog.csdn.net/qq_44652591?type=blog" alt="链接2">

    <area shape="rect" coords="10,325,175,479" href="https://www.bilibili.com/" alt="链接3">

</map>

  

</body>

</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sky wide

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值