vue自定义颜色选择器(重置版)

实现效果

相较于上次发布的颜色选择器,这次加入了圆形的选择器,并且优化了代码。

<SquareColor ref="squareColor" :color="color" @change="changeColor1" />setColor1() {// this.color = 'rgba(255, 82, 111, 0.5)'this.$refs.squareColor.changeColor('rgba(255, 82, 111, 0.5)')}

使用方式:可以使用color属性传入默认颜色,目前支持hex16进制,rgb,rgba,hsl这四种格式,使用change事件获取颜色修改后的值,如果需要父组件动态修改其中的颜色则需要调用组件中的changeColor方法。

如果需要修改传出的颜色类型可以在组件中的getRGBA方法中进行修改,或者在父组件中使用color-convert进行转换。

在使用该组件之前需要引入color-convert依赖

npm install color-convert

完整代码:该代码主要分为四个部分(方形选择器组件,圆形选择器组件,utils,父组件示例)

方形选择器:

<template><div class="color-box"><div class="color-panel" ref="colorPanel" @mousedown="colorPanelMD" :style="{ background: colorPanelColor }"><div class="color-white-panel"></div><div class="color-black-panel"></div><div ref="colorPanelSliderThumb" class="color-panel-slider-thumb"></div></div><div class="hue-panel" ref="huePanel" @mousedown="huePanelMD"><div ref="huePanelSliderThumb" class="hue-slider-thumb"></div></div><div class="alpha-panel" ref="alphaPanel" @mousedown="alphaPanelMD"><div class="alpha-panel-cover":style="{ background: `linear-gradient(to right, rgba(255, 255, 255, 0) 0, ${colorPanelColor} 100%)` }"></div><div ref="alphaPanelSliderThumb" class="alpha-slider-thumb"></div></div></div>
</template><script>
import convert from 'color-convert'
import { colorTypeConversion } from '@/utils'
export default {props: {color: {type: String,required: true,default: ''}},data() {return {colorPanelColor: 'red',h: 0,s: 0,v: 100,alpha: 1,};},mounted() {this.changeColor(this.color)},methods: {// 设置颜色 转换颜色为hsv类型changeColor(val) {let colorObj = colorTypeConversion(val)if (colorObj?.alpha) {this.alpha = colorObj.alpha}if (colorObj?.color?.length == 3) {let [h, s, v] = colorObj.color// 判断当前颜色是否和需要转换的颜色是否一致,一致则不进行转换if (this.h !== h || this.s !== s || this.v !== v) {this.h = colorObj.color[0]this.s = colorObj.color[1]this.v = colorObj.color[2]this.$nextTick(() => {this.initPosi();})}}},// 初始化hsv初始位置initPosi() {// 设置色相条按钮位置this.$refs.huePanelSliderThumb.style.left = this.h / 360 * this.$refs.huePanel.offsetWidth + 'px'// 设置透明度条按钮位置this.$refs.alphaPanelSliderThumb.style.left = this.alpha * this.$refs.alphaPanel.offsetWidth + 'px'// 设置色盘按钮位置this.$refs.colorPanelSliderThumb.style.left = this.s / 100 * this.$refs.colorPanel.offsetWidth + 'px'this.$refs.colorPanelSliderThumb.style.top = (100 - this.v) / 100 * this.$refs.colorPanel.offsetHeight + 'px'// 设置色盘和透明度背景色this.colorPanelColor = '#' + convert.hsv.hex(this.h, this.s, this.v)},// 色盘鼠标事件colorPanelMD(e) {let that = thislet colorPanel = that.$refs.colorPanellet colorPanelSliderThumb = that.$refs.colorPanelSliderThumblet { width, height } = colorPanel.getBoundingClientRect()colorPanelSliderThumb.style.left = that.judgeBoundary(e.offsetX, 0, width) + 'px'colorPanelSliderThumb.style.top = that.judgeBoundary(e.offsetY, 0, height) + 'px'that.getSV()let initLeft = colorPanelSliderThumb.offsetLeftlet initTop = colorPanelSliderThumb.offsetToplet initX = e.pageXlet initY = e.pageYdocument.addEventListener('mousemove', mouseMove)function mouseMove(e) {colorPanelSliderThumb.style.left = that.judgeBoundary(e.pageX - initX + initLeft, 0, width) + 'px'colorPanelSliderThumb.style.top = that.judgeBoundary(e.pageY - initY + initTop, 0, height) + 'px'that.getSV()}document.addEventListener('mouseup', mouseUp)function mouseUp() {document.removeEventListener('mousemove', mouseMove)document.removeEventListener('mouseup', mouseUp)}},// 获取饱和度和明值getSV() {let that = thislet colorPanel = that.$refs.colorPanellet colorPanelSliderThumb = that.$refs.colorPanelSliderThumblet { width, height } = colorPanel.getBoundingClientRect()let left = colorPanelSliderThumb.offsetLeftlet top = colorPanelSliderThumb.offsetToplet s = left / width * 100let v = 100 - top / height * 100that.s = sthat.v = vthat.getRGBA();},// 色相鼠标事件huePanelMD(e) {let that = thislet huePanel = that.$refs.huePanellet huePanelSliderThumb = that.$refs.huePanelSliderThumblet { width } = huePanel.getBoundingClientRect()huePanelSliderThumb.style.left = that.judgeBoundary(e.offsetX, 0, width) + 'px'that.getHue();let initLeft = huePanelSliderThumb.offsetLeftlet initX = e.pageXdocument.addEventListener('mousemove', mouseMove)function mouseMove(e) {huePanelSliderThumb.style.left = that.judgeBoundary(e.pageX - initX + initLeft, 0, width) + 'px'that.getHue();}document.addEventListener('mouseup', mouseUp)function mouseUp() {document.removeEventListener('mousemove', mouseMove)document.removeEventListener('mouseup', mouseUp)}},// 获取色相并转换成颜色getHue() {let that = thislet huePanel = that.$refs.huePanellet huePanelSliderThumb = that.$refs.huePanelSliderThumblet { width } = huePanel.getBoundingClientRect()let hue = huePanelSliderThumb.offsetLeft / width * 360that.h = huelet color = convert.hsv.hex(hue, 100, 100)that.colorPanelColor = '#' + colorthat.getRGBA();},// 透明度鼠标事件alphaPanelMD(e) {let that = thislet alphaPanel = that.$refs.alphaPanellet alphaPanelSliderThumb = that.$refs.alphaPanelSliderThumblet { width } = alphaPanel.getBoundingClientRect()alphaPanelSliderThumb.style.left = that.judgeBoundary(e.offsetX, 0, width) + 'px'that.getAlpha();let initLeft = alphaPanelSliderThumb.offsetLeftlet initX = e.pageXdocument.addEventListener('mousemove', mouseMove)function mouseMove(e) {alphaPanelSliderThumb.style.left = that.judgeBoundary(e.pageX - initX + initLeft, 0, width) + 'px'that.getAlpha();}document.addEventListener('mouseup', mouseUp)function mouseUp() {document.removeEventListener('mousemove', mouseMove)document.removeEventListener('mouseup', mouseUp)}},getAlpha() {let that = thislet alphaPanel = that.$refs.alphaPanellet alphaPanelSliderThumb = that.$refs.alphaPanelSliderThumblet { width } = alphaPanel.getBoundingClientRect()let alpha = (alphaPanelSliderThumb.offsetLeft / width).toFixed(2)that.alpha = alphathis.getRGBA();},// 获取RGBA色值getRGBA() {let color = convert.hsv.rgb(this.h, this.s, this.v)let rgba = `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${this.alpha})`this.$emit('change', rgba)},// 边界判断judgeBoundary(value, min, max) {if (value < min) {return min}if (value > max) {return max}return value},},
};
</script><style lang="scss" scoped>
.color-box {width: 300px;.color-panel {position: relative;height: 200px;// background-color: red;.color-white-panel {position: absolute;inset: 0;background: linear-gradient(to right, #fff 0%, transparent 100%);}.color-black-panel {position: absolute;inset: 0;background: linear-gradient(to top, #000 0%, transparent 100%);}.color-panel-slider-thumb {position: absolute;top: 0;left: 0;transform: translate(-50%, -50%);width: 5px;height: 5px;box-shadow: 0 0 2px #5a5a5a;border: 3px solid #fff;border-radius: 50%;pointer-events: none;}}.hue-panel {position: relative;height: 12px;margin: 20px 0;background: linear-gradient(to right, red 0, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, red);}.alpha-panel {position: relative;height: 12px;background: url('../../assets/images/alpha.png');.alpha-panel-cover {position: absolute;inset: 0;}.alpha-slider-thumb {left: 100%;}}
}.hue-slider-thumb,
.alpha-slider-thumb {position: absolute;left: 0;top: 50%;transform: translate(-50%, -50%);width: 5px;height: 140%;border-radius: 4px;background-color: #fff;box-shadow: 0 0 2px #5a5a5a;cursor: pointer;pointer-events: none;
}
</style>

圆形选择器:

<template><div class="color-box"><div class="top-part"><div :style="{ width: width + 'px', height: width + 'px' }" class="color-panel" ref="colorPanel"@mousedown="colorPanelMD"><div class="value-bg" ref="valueBg"></div><div ref="colorPanelSliderThumb" class="color-panel-slider-thumb"></div></div><div class="value-panel" @mousedown="valuePanelMD" ref="valuePanel" :style="{ height: width + 'px' }"><div ref="valuePanelSliderThumb" class="value-slider-thumb"></div></div></div><div :style="{ width: width + 'px' }" class="alpha-panel" ref="alphaPanel" @mousedown="alphaPanelMD"><div class="alpha-panel-cover":style="{ background: `linear-gradient(to right, rgba(255, 255, 255, 0) 0, ${colorPanelColor} 100%)` }"></div><div ref="alphaPanelSliderThumb" class="alpha-slider-thumb"></div></div></div>
</template><script>
import convert from 'color-convert'
import { colorTypeConversion } from '@/utils'
export default {props: {width: {type: Number,default: 200,required: false,},color: {type: String,required: true,default: ''}},data() {return {h: 0,s: 0,v: 100,alpha: 1,colorPanelColor: '#fff',};},mounted() {this.changeColor(this.color)},methods: {// 设置颜色 转换颜色为hsv类型changeColor(val) {let colorObj = colorTypeConversion(val)if (colorObj?.alpha) {this.alpha = colorObj.alpha}if (colorObj?.color?.length == 3) {let [h, s, v] = colorObj.color// 判断当前颜色是否和需要转换的颜色是否一致,一致则不进行转换if (this.h !== h || this.s !== s || this.v !== v) {this.h = colorObj.color[0]this.s = colorObj.color[1]this.v = colorObj.color[2]this.$nextTick(() => {this.initPosi();})}}},// 初始化hsv初始位置initPosi() {// 设置明值位置即右侧柱子按钮位置let height = this.$refs.valuePanel.getBoundingClientRect().heightthis.$refs.valuePanelSliderThumb.style.top = height - height * this.v / 100 + 'px'this.$refs.valueBg.style.background = `rgba(0, 0, 0, ${Number(1 - (this.v / 100).toFixed(2))})`// 获取饱和度(长度) 和 色相(夹角)const vector = [0, 1]; // 假设圆心为坐标原点,并使用夹角度数配合旋转矩阵以及按钮距离圆心的长度求取按钮在色盘中的位置let r = this.width / 2let length = this.s / 100 * rlet angle = -Number((this.h - Math.PI / 180).toFixed(2))// 将角度转为弧度const angleInRadians = angle * Math.PI / 180;// 计算另一个向量const x = vector[0] * Math.cos(angleInRadians) - vector[1] * Math.sin(angleInRadians);const y = vector[0] * Math.sin(angleInRadians) + vector[1] * Math.cos(angleInRadians);// 根据长度进行缩放const scaleFactor = length / Math.sqrt(x * x + y * y);const newX = x * scaleFactor;const newY = y * scaleFactor;this.$refs.colorPanelSliderThumb.style.left = newX + r + 'px'this.$refs.colorPanelSliderThumb.style.top = r - newY + 'px'// 给底部透明度设置背景this.colorPanelColor = '#' + convert.hsv.hex(this.h, this.s, this.v)// 设置透明度按钮位置let { width } = this.$refs.alphaPanel.getBoundingClientRect()this.$refs.alphaPanelSliderThumb.style.left = width * this.alpha + 'px'},colorPanelMD(e) {let that = thisconst colorPanelSliderThumb = that.$refs.colorPanelSliderThumbcolorPanelSliderThumb.style.left = e.offsetX + 'px'colorPanelSliderThumb.style.top = e.offsetY + 'px'that.calculateAngle() // 计算夹角 获取色相let initLeft = colorPanelSliderThumb.offsetLeftlet initTop = colorPanelSliderThumb.offsetToplet initX = e.pageXlet initY = e.pageYdocument.addEventListener('mousemove', mouseMove)function mouseMove(e) {let x = e.pageX - initX + initLeftlet y = e.pageY - initY + initTopcolorPanelSliderThumb.style.left = that.circleJudgeBoundary(x, y).targetX + 'px'colorPanelSliderThumb.style.top = that.circleJudgeBoundary(x, y).targetY + 'px'that.calculateAngle() // 计算夹角 获取色相}document.addEventListener('mouseup', mouseUp)function mouseUp(e) {document.removeEventListener('mousemove', mouseMove)document.removeEventListener('mouseup', mouseUp)}},// 获取当前滑块的向量坐标归一化 并获取其饱和度值calcSliderThumbVector() {let r = this.width / 2const colorPanel = this.$refs.colorPanelconst colorPanelSliderThumb = this.$refs.colorPanelSliderThumblet { width, height, left, top } = colorPanel.getBoundingClientRect()let originX = left + width / 2 - colorPanel.offsetLeftlet originY = top + height / 2 - colorPanel.offsetToplet x = (colorPanelSliderThumb.getBoundingClientRect().left - left + colorPanelSliderThumb.getBoundingClientRect().width / 2) - originXlet y = originY - (colorPanelSliderThumb.getBoundingClientRect().top - top + colorPanelSliderThumb.getBoundingClientRect().height / 2)// 获取饱和度let s = Number((Math.sqrt(x ** 2 + y ** 2) / r * 100).toFixed(2))this.s = s <= 100 ? s : 100return this.normalizeVector([x, y])},// 归一化二维向量normalizeVector(vector) {// 计算向量的模长const magnitude = Math.sqrt(vector[0] ** 2 + vector[1] ** 2);// 将向量的每个分量除以模长const normalizedVector = [vector[0] / magnitude, vector[1] / magnitude];return normalizedVector;},// 计算两个二维向量的夹角 夹角度数即色相calculateAngle(vectorA = [0, 1], vectorB = this.calcSliderThumbVector(), isGetRGBA = true) {// 计算向量的点积const dotProduct = vectorA[0] * vectorB[0] + vectorA[1] * vectorB[1];// 计算向量的模长const magnitudeA = Math.sqrt(vectorA[0] ** 2 + vectorA[1] ** 2);const magnitudeB = Math.sqrt(vectorB[0] ** 2 + vectorB[1] ** 2);// 计算夹角的余弦值let cosTheta;if (magnitudeA * magnitudeB === 0) {cosTheta = 0} else {cosTheta = dotProduct / (magnitudeA * magnitudeB);}// 计算夹角的弧度值const angleRad = Math.acos(cosTheta);let h;if (vectorB[0] < 0 && isGetRGBA) {h = Number((((2 * Math.PI - angleRad) * 180) / Math.PI).toFixed(2));} else {h = Number(((angleRad * 180) / Math.PI).toFixed(2));}this.h = hif (isGetRGBA) this.getRGBA();return h;},// 圆盘边界判断circleJudgeBoundary(targetX, targetY) {const colorPanel = this.$refs.colorPanellet { width, height, left, top } = colorPanel.getBoundingClientRect()let originX = left + width / 2 - colorPanel.offsetLeftlet originY = top + height / 2 - colorPanel.offsetToplet x = targetX - originXlet y = originY - targetY// 判断鼠标是否已经超出的圆盘 如果超出了圆盘 则将鼠标位置限制在圆盘内if (Math.sqrt(x ** 2 + y ** 2) <= this.width / 2) {return { targetX, targetY }} else {// 计算目标坐标的夹角let angle = this.calculateAngle([x, 0], [x, y], false)// 计算标记点在圆盘边缘的坐标位置 以圆盘中心为原点let r = this.width / 2 // 半径let realX = (r * Math.cos(angle * Math.PI / 180)) * (x / Math.abs(x)) + rlet realY = r - (r * Math.sin(angle * Math.PI / 180)) * (y / Math.abs(y))return { targetX: Number(realX.toFixed(2)), targetY: Number(realY.toFixed(2)) }}},valuePanelMD(e) {let that = thislet valuePanel = that.$refs.valuePanellet { top, height } = valuePanel.getBoundingClientRect()let valuePanelSliderThumb = that.$refs.valuePanelSliderThumblet initY = e.pageYvaluePanelSliderThumb.style.top = initY - top - valuePanelSliderThumb.getBoundingClientRect().height / 2 + 'px'that.getValue()let initTop = valuePanelSliderThumb.offsetTopdocument.addEventListener('mousemove', mouseMove)function mouseMove(e) {valuePanelSliderThumb.style.top = that.judgeBoundary(initTop + e.pageY - initY, 0, height) + 'px'that.getValue()}document.addEventListener('mouseup', mouseUp)function mouseUp() {document.removeEventListener('mousemove', mouseMove)document.removeEventListener('mouseup', mouseUp)}},// 获取明值getValue() {let valuePanel = this.$refs.valuePanellet { height } = valuePanel.getBoundingClientRect()let offsetTop = this.$refs.valuePanelSliderThumb.offsetTopthis.v = 100 - Number((offsetTop / height * 100).toFixed(2))this.$refs.valueBg.style.background = `rgba(0, 0, 0, ${Number(1 - (this.v / 100).toFixed(2))})`this.getRGBA()},// 透明度鼠标事件alphaPanelMD(e) {let that = thislet alphaPanel = that.$refs.alphaPanellet alphaPanelSliderThumb = that.$refs.alphaPanelSliderThumblet { width } = alphaPanel.getBoundingClientRect()alphaPanelSliderThumb.style.left = that.judgeBoundary(e.offsetX, 0, width) + 'px'that.getAlpha();let initLeft = alphaPanelSliderThumb.offsetLeftlet initX = e.pageXdocument.addEventListener('mousemove', mouseMove)function mouseMove(e) {alphaPanelSliderThumb.style.left = that.judgeBoundary(e.pageX - initX + initLeft, 0, width) + 'px'that.getAlpha();}document.addEventListener('mouseup', mouseUp)function mouseUp() {document.removeEventListener('mousemove', mouseMove)document.removeEventListener('mouseup', mouseUp)}},getAlpha() {let that = thislet alphaPanel = that.$refs.alphaPanellet alphaPanelSliderThumb = that.$refs.alphaPanelSliderThumblet { width } = alphaPanel.getBoundingClientRect()let alpha = (alphaPanelSliderThumb.offsetLeft / width).toFixed(2)that.alpha = alphathis.getRGBA();},// 获取RGBA色值getRGBA() {let color = convert.hsv.rgb(this.h, this.s, this.v)let rgba = `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${this.alpha})`this.colorPanelColor = `rgb(${color[0]}, ${color[1]}, ${color[2]})`this.$emit('change', rgba)},// 明值和透明度边界判断judgeBoundary(value, min, max) {if (value < min) {return min}if (value > max) {return max}return value},},
};
</script>
<style lang="scss" scoped>
.color-box {.top-part {display: flex;.color-panel {position: relative;border-radius: 50%;background: conic-gradient(red 0, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, red);&::before {content: '';position: absolute;inset: 0;border-radius: 50%;z-index: 10000;background: radial-gradient(#fff 0, transparent 80%);}.value-bg {position: absolute;inset: 0;z-index: 10010;border-radius: 50%;}.color-panel-slider-thumb {position: absolute;top: 50%;left: 50%;z-index: 10999;transform: translate(-50%, -50%);width: 6px;height: 6px;background: #fff;border: 1px solid #000;border-radius: 50%;pointer-events: none;box-sizing: border-box;}}.value-panel {position: relative;width: 12px;background: linear-gradient(to bottom, #fff 0, #000 100%);margin-left: 20px;.value-slider-thumb {position: absolute;top: 0;left: 50%;transform: translate(-50%, 0);width: 120%;height: 5px;border-radius: 4px;background-color: #fff;box-shadow: 0 0 2px #5a5a5a;pointer-events: none;}}}.alpha-panel {position: relative;height: 12px;background: url('../../assets/images/alpha.png');margin-top: 20px;.alpha-panel-cover {position: absolute;inset: 0;}.alpha-slider-thumb {position: absolute;left: 100%;top: 50%;transform: translate(-50%, -50%);width: 5px;height: 140%;border-radius: 4px;background-color: #fff;box-shadow: 0 0 2px #5a5a5a;cursor: pointer;pointer-events: none;}}
}
</style>

uitls>index.js:

import convert from 'color-convert'
// color: 颜色,type: 需要转换的类型
export function colorTypeConversion(color, type = 'hsv') {let reg = /(d+(.d+)?)|(.d+)/g// 判断颜色类型 并转换if (color.startsWith('#')) {return {color: convert.hex[type](color),alpha: 1}} else if (color.startsWith('rgba')) {let arr = color.match(reg).map(item => Number(item))return {color: convert.rgb[type](arr[0], arr[1], arr[2]),alpha: arr[3]}} else if (color.startsWith('rgb')) {let arr = color.match(reg).map(item => Number(item))return {color: convert.rgb[type](arr[0], arr[1], arr[2]),alpha: 1}} else if (color.startsWith('hsl')) {let arr = color.match(reg)return {color: convert.hsl[type]([arr[0], arr[1], arr[2]]),alpha: 1}} else {return {color: convert.hex[type](color),alpha: 1}}
}

父组件示例:

<template><div class="page1"><div class="box"><div style="margin-bottom: 25px;"><span>{{ color }}</span><div class="show-color" :style="{ background: color }"></div></div><SquareColor ref="squareColor" :color="color" @change="changeColor1" /><button @click="setColor1">修改为 rgba(255, 82, 111, 0.5)</button></div><div class="box"><div style="margin-bottom: 25px;"><span>{{ color2 }}</span><div class="show-color" :style="{ background: color2 }"></div></div><CircleColor ref="circleColor" :color="color2" @change="changeColor2" /><button @click="setColor2">修改为 #5fff45</button></div></div>
</template><script>
import SquareColor from '@/components/color/square.vue'
import CircleColor from '@/components/color/circle.vue'
export default {name: 'ComponentPage1',components: {SquareColor,CircleColor,},data() {return {color: 'hsl(107.74deg 88.62% 47.73%)',color2: 'rgba(255, 66, 237, 1)',};},mounted() { },methods: {setColor1() {this.color = 'rgba(255, 82, 111, 0.5)'this.$refs.squareColor.changeColor('rgba(255, 82, 111, 0.5)')},setColor2() {this.color2 = '#5fff45'this.$refs.circleColor.changeColor('#5fff45')},changeColor1(color) {this.color = color},changeColor2(color) {this.color2 = color}},
};
</script><style lang="scss" scoped>
.page1 {display: flex;flex-wrap: wrap;gap: 50px;padding: 100px;.box {padding: 20px;box-shadow: 0 0 8px #b8b7b7;border-radius: 10px;.show-color {display: inline-block;width: 100px;height: 25px;margin-left: 25px;vertical-align: middle;box-shadow: 0 0 8px #b8b7b7;border-radius: 4px;}}
}button {background-color: #409eff;color: #fff;border: none;padding: 8px 15px;border-radius: 4px;margin: 20px 0;cursor: pointer;
}
</style>

完整项目代码压缩包:colorPicker

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/890006.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

timestamp 时间戳转换成日期的方法 | java.util

时间戳通常是一个long数据&#xff08;注意java中赋值时需要带上L标识是long整型&#xff0c;否则int过长报错&#xff09; 代码实现 常用工具类&#xff1a; java.util.Datejava.time.Instantjava.time.format.DateTimeFormatter toInstant() 方法的功能是将一个 Date 对象…

Minio入门搭建图片服务器

Minio入门搭建图片服务器 闲来无事&#xff0c;之前一直想弄弄图片服务器的软件&#xff0c;搜索了一下有zimg、Nginx、Thumbor、Minio等。想想之前也用过minio&#xff0c;所以就用这个搭建啦。 1. docker安装 docker run -d -p 9000:9000 -p 9001:9001 \ …

从腾讯云的恶意文件查杀学习下PHP的eval函数

问题来自于腾讯云的主机安全通知&#xff1a; &#x1f680;一键接入&#xff0c;畅享GPT及AI大模型服务&#xff01;【顶级API中转品牌】&#xff1a; https://api.ablai.top/ 病毒文件副本内容如下&#xff1a; <?php function x($x){eval($x);}x(str_rot13(riny($_CBF…

CISC RISC

CISC&#xff1a;设计目标是通过复杂的指令来提高代码密度&#xff0c;减少指令数量&#xff0c;适合内存资源较为有限的系统。CISC处理器的硬件复杂度较高&#xff0c;但在某些应用场合&#xff08;如桌面计算机&#xff09;能够提供足够的性能。 RISC&#xff1a;设计目标是…

使用LSTM神经网络对股票日线行情进行回归训练(Pytorch版)

版权声明&#xff1a;本文为博主原创文章&#xff0c;如需转载请贴上原博文链接&#xff1a;使用LSTM神经网络对股票日线行情进行回归训练&#xff08;Pytorch版&#xff09;-CSDN博客 前言&#xff1a;近期在尝试使用lstm对股票日线数据进行拟合&#xff0c;初见成型但是效果不…

睡岗和玩手机数据集,4653张原始图,支持YOLO,VOC XML,COCO JSON格式的标注

睡岗和玩手机数据集&#xff0c;4653张原始图&#xff0c;支持YOLO&#xff0c;VOC XML&#xff0c;COCO JSON格式的标注 数据集分割 训练组70&#xff05; 3257图片 有效集20&#xff05; 931图片 测试集10&#xff05; 465图片 预处理 没有采用任何预处…

Pandas 索引

在 Pandas 中&#xff0c;索引&#xff08;Index&#xff09;是 DataFrame 和 Series 的核心组成部分&#xff0c;用于标识和访问数据。索引提供了快速、灵活和强大的数据检索方法。以下是关于 Pandas 索引的一些关键点&#xff1a; 1. 创建索引 当创建一个 DataFrame 或 Seri…

labml.ai Deep Learning Paper Implementations (带注释的 PyTorch 版论文实现)

labml.ai Deep Learning Paper Implementations {带注释的 PyTorch 版论文实现} 1. labml.ai2. labml.ai Deep Learning Paper Implementations3. Sampling Techniques for Language Models (语言模型的采样技术)4. Multi-Headed Attention (MHA)References 1. labml.ai https…

使用 Marp 将 Markdown 导出为 PPT 后不可编辑的原因说明及解决方案

Marp 是一个流行的 Markdown 演示文稿工具&#xff0c;能够将 Markdown 文件转换为 PPTX 格式。然而&#xff0c;用户在使用 Marp 导出 PPT 时&#xff0c;可能会遇到以下问题&#xff1a; 导出 PPT 不可直接编辑的原因 根据 Marp GitHub 讨论&#xff0c;Marp 导出的 PPTX 文…

构建一个rust生产应用读书笔记四(实战2)

此门课程学习采用actix-web框架完成一个生产级别的rust应用&#xff0c;在 actix-web 中&#xff0c;Extractors 是一个非常重要的概念&#xff0c;它们用于从传入的 HTTP 请求中提取特定的信息片段。actix-web 提供了多种内置的提取器&#xff0c;以满足常见的使用场景。说白了…

优选生产报工系统:关键选择要素

【优选生产报工系统&#xff1a;数据分析、产品管理与基础数据登录的关键选择要素】 在快速变化的制造业环境中&#xff0c;生产报工系统的重要性不言而喻。它不仅仅是一种记录工时和监控生产进度的工具&#xff0c;更是一种能够实现数据驱动决策、优化产品管理和确保基础数据…

使用Python打造高效的PDF文件管理应用(合并以及分割)

在日常工作和学习中&#xff0c;我们经常需要处理大量PDF文件。手动合并、分割PDF不仅耗时&#xff0c;还容易出错。今天&#xff0c;我们将使用Python的wxPython和PyMuPDF库&#xff0c;开发一个强大且易用的PDF文件管理工具。 C:\pythoncode\new\mergeAndsplitPdf.py 所有代…

【C语言程序设计——入门】C语言程序开发环境(头歌实践教学平台习题)【合集】

目录&#x1f60b; <第1关&#xff1a;程序改错> 任务描述 相关知识 编程要求 测试说明 我的通关代码: 测试结果&#xff1a; <第2关&#xff1a;scanf 函数> 任务描述 相关知识 编程要求 测试说明 我的通关代码: 测试结果&#xff1a; <第1关&a…

皮肤伤口分割数据集labelme格式248张5类别

数据集格式&#xff1a;labelme格式(不包含mask文件&#xff0c;仅仅包含jpg图片和对应的json文件) 图片数量(jpg文件个数)&#xff1a;284 标注数量(json文件个数)&#xff1a;284 标注类别数&#xff1a;5 标注类别名称:["bruises","burns","cu…

JVM系列之内存区域

每日禅语 有一位年轻和尚&#xff0c;一心求道&#xff0c;多年苦修参禅&#xff0c;但一直没有开悟。有一天&#xff0c;他打听到深山中有一古寺&#xff0c;住持和尚修炼圆通&#xff0c;是得道高僧。于是&#xff0c;年轻和尚打点行装&#xff0c;跋山涉水&#xff0c;千辛万…

大腾智能CAD:国产云原生三维设计新选择

在快速发展的工业设计领域&#xff0c;CAD软件已成为不可或缺的核心工具。它通过强大的建模、分析、优化等功能&#xff0c;不仅显著提升了设计效率与精度&#xff0c;还促进了设计思维的创新与拓展&#xff0c;为产品从概念构想到实体制造的全过程提供了强有力的技术支持。然而…

leetcode 3195.包含所有1的最小矩形面积I

1.题目要求: 2.解题步骤: class Solution { public:int minimumArea(vector<vector<int>>& grid) {//设置二维数组deque<deque<int>> row_distance;for(int i 0;i < grid.size();i){//遍历数组&#xff0c;把每行头部1的小标和尾部1的下标代…

搭建Tomcat(三)---重写service方法

目录 引入 一、在Java中创建一个新的空项目&#xff08;初步搭建&#xff09; 问题&#xff1a; 要求在tomcat软件包下的MyTomcat类中编写main文件&#xff0c;实现在MyTomcat中扫描myweb软件包中的所有Java文件&#xff0c;并返回“WebServlet(url"myFirst")”中…

Linux介绍与安装CentOS 7操作系统

什么是操作系统 操作系统&#xff0c;英⽂名称 Operating System&#xff0c;简称 OS&#xff0c;是计算机系统中必不 可少的基础系统软件&#xff0c;它是 应⽤程序运⾏以及⽤户操作必备的基础环境 ⽀撑&#xff0c;是计算机系统的核⼼。 操作系统的作⽤是管理和控制计算机系…

【Linux】深入理解进程信号机制:信号的产生、捕获与阻塞

&#x1f3ac; 个人主页&#xff1a;谁在夜里看海. &#x1f4d6; 个人专栏&#xff1a;《C系列》《Linux系列》《算法系列》 ⛰️ 时间不语&#xff0c;却回答了所有问题 目录 &#x1f4da;前言 &#x1f4da;一、信号的本质 &#x1f4d6;1.异步通信 &#x1f4d6;2.信…