让你的Label拥有描边及模糊投影效果

******************日志自动版权说明*******************
原创作者:『DYlike』  QQ 20353841
作品由本人原创,转载请保留此版权信息。
*****************************************************

DYLIKESHADOWLABEL.rarLABEL控件渲染器
版本:1.0
型版:免费
作者:DYLIKE
支持效果:仿桌面图标文字投影+文字描边
可调属性:文字颜色,描边颜色,是否描边,是否投影,是否渲染所有窗口内的Label控件。
注意事项:不适用用于动态Label.Text文本长度变化(否则会出现文字不全)
 如:Label1.Text="123" 动态变成 Label1.Text="1234"
为达到更好的模糊代码及性能,未使用属性隐藏或分类,所有功能项掺合在控件主属性内。
文字效果可在设计模式时随时调整,效果会即时在DYLIKESHADOWLABEL控件上显示,运行时该控件自动隐藏。
==========================================================
--------------特别注意:-----------
Label控件一旦被渲染,则无法取出Label.Text属性,而应该从Label.Tag取值,但仍然可以通过Label.Text赋值给Label控件。
例:在渲染后的赋值及取值操作
Label1.Text="123" => 正确,属于正常赋值
Label1.Tag=123"  => 错误,请使用上面一条
S=Label1.Text  => 错误,已经被渲染的Label无法再从Text取值,将会返回空值
S=Label1.Tag  => 正确,渲染后的Tag可以直接取值,该值与Text原值一致,不是空值
==========================================================

'--------------是示例代码1:-----------

        Dylikeshadowlabel1.DrawLabelShadowText
 渲染自身所在窗体内的Label控件

'--------------是示例代码1:-----------

        Dylikeshadowlabel1.DrawLabelShadowText(Me)
 渲染自身所在窗体内的Label控件

'--------------是示例代码1:-----------

        Dylikeshadowlabel1.DrawLabelShadowText(Panel1)
 渲染Panel1容器内的Label控件
==========================================================

'--------------功能属性(默认继承属性略)-----------
属性名   类型  默认值 说明
DrawChild  Boolean  True 是否渲染所有容器(包含子容器)的Label控件
DrawOutsideLine  Boolean  False 是否渲染文字描边
DrawTextShadow  Boolean  True 是否渲染文字投影
OutsideLineColor Color  Black 文字描边时呈现的边缘颜色
TextColor  Color  White 文字本身应渲染的颜色

//绘制路线周边设备上图 showDevicesOnMap(devices) { this.clearDeviceMarkers(); console.log("位置--===", devices); // devices.forEach((device, index) => { // const { longitude, latitude } = device; // const markerElement = document.createElement("div"); // markerElement.style.position = "relative"; // markerElement.style.width = "34px"; // markerElement.style.height = "50px"; // // 设备图标 // const icon = document.createElement("div"); // icon.style.width = "30px"; // icon.style.height = "20px"; // icon.style.backgroundImage = device.online // ? 'url("/images/jk_online.png")' // : 'url("/images/jk_unline.png")'; // icon.style.backgroundSize = "100% 100%"; // icon.style.backgroundRepeat = "no-repeat"; // icon.style.position = "absolute"; // 改为绝对定位 // icon.style.top = "10px"; // 调整顶部位置以适应容器 // icon.style.left = "50%"; // markerElement.appendChild(icon); // // 序号标签 // const label = document.createElement("div"); // label.textContent = index + 1; // label.style.position = "absolute"; // label.style.top = "0px"; // label.style.left = "50%"; // label.style.transform = "translateX(-50%)"; // label.style.backgroundColor = // this.selectedDeviceId === device.id ? "#FF6666" : "#45CCDA"; // label.style.color = "white"; // label.style.borderRadius = "50%"; // label.style.width = "20px"; // label.style.height = "20px"; // label.style.textAlign = "center"; // label.style.lineHeight = "20px"; // label.style.fontSize = "12px"; // label.style.zIndex = "10"; // 确保标签在最上层 // markerElement.appendChild(label); // // 计算图标实际尺寸 // const iconHeight = 50; // 图标高度(包含标签) // // 直接使用原始坐标,不进行任何偏移计算 // const marker = new minemap.Marker(markerElement, { // offset: [0, -iconHeight / 2], // 垂直偏移补偿 // anchor: "center", // 使用中心定位 // }) // .setLngLat([longitude, latitude]) // 直接使用原始坐标 // .addTo(this.mapObj); // // 点击事件 // markerElement.addEventListener("click", (e) => { // e.stopPropagation(); // this.toggleDeviceSelection(device.id, label); // }); // this.deviceMarkers.push({ marker, device, label }); // }); // 创建新的数据源 // 创建GeoJSON数据源 } toggleDeviceSelection(deviceId, labelElement) { // 更新选中状态 const isSelected = this.selectedDeviceId === deviceId; this.selectedDeviceId = isSelected ? null : deviceId; // 更新标签颜色 labelElement.style.backgroundColor = isSelected ? "#45CCDA" : "#FF6666"; // 通知父组件 this.$emit("device-selected", this.selectedDeviceId, deviceId); },把这些替换为图层标记的方法类似于 // const dataSource = { // type: "FeatureCollection", // features: devices.map((device) => ({ // id: device.id, // type: "Feature", // geometry: { // type: "Point", // coordinates: [device.longitude, device.latitude], // }, // properties: { // ...device, // title: device.name, // "custom-image": device.online ? "jk_online" : "jk_unline", // index: device.index || 1, // 添加序号属性 // }, // })), // }; // // 设置数据源 // const mapSource = this.mapObj.getSource("data-point"); // mapSource.setData(dataSource);
最新发布
07-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值