当前位置: 首页 > news >正文

Unity照片墙简易圆形交互效果总结

还要很多可以优化的点地方,有兴趣的可以做
比如对象的销毁和生成可以做成对象池,走到最左边后再移动到最右边循环利用

分析过程文件,采用Blender,资源已上传,可以播放动画看效果,下面截个图:
在这里插入图片描述

视频效果如下:

anim

Untiy结构如下:
在这里插入图片描述
上面的ImageItem是我手动添加展示关系用的,默认就一个Target,PictureWall挂PictureWall脚本,ImageItem(预制体)挂ImageItemController 脚本即可

using UnityEngine;public class ImageItemController : MonoBehaviour
{public RectTransform target;public float speed = 10;[SerializeField]private float radiusScale = 1;public float horizontalOffset = 0;private RectTransform rect;private float radius = 0;private Vector2 originalPos = Vector2.zero;private bool isCheck = false;private bool isStartRotate = false;private Vector2 circleCenter;private float xDelta = 0;private float offset = 0;void Start(){rect = transform as RectTransform;rect.anchoredPosition = new Vector2(rect.anchoredPosition.x - horizontalOffset, rect.anchoredPosition.y);radius = target.rect.width * radiusScale;// * Random.Range(0.8f, 1); 半径可以在范围内随机}/* 1.现根据接触点计算出圆的路径:目标移动的位移,计算在圆的的位置,只需修改x即可,y保持不变* 2.计算出的位置x加上移动的距离,得出最总x的位置* 3.设置位置即可* 4.走远时的接触点:开始接触时的关于x对称位置  * 5.添加移动:平移原点和圆点即可*///移动void Update(){if (!isCheck){var dis = Vector2.Distance(target.anchoredPosition, rect.anchoredPosition);if (dis <= radius){isCheck = true;originalPos = rect.anchoredPosition;float y = Mathf.Abs(originalPos.y - target.anchoredPosition.y);float xToCircleCenter = Mathf.Sqrt(radius * radius - y * y);float x = originalPos.x - xToCircleCenter;circleCenter = new Vector2(x, target.anchoredPosition.y);isStartRotate = true;rect.SetSiblingIndex(transform.parent.childCount - 2);}}xDelta = Time.deltaTime * speed;rect.anchoredPosition = new Vector2(rect.anchoredPosition.x - xDelta, rect.anchoredPosition.y);if (isStartRotate){circleCenter.x -= xDelta;originalPos.x -= xDelta;float moveXDistance = target.anchoredPosition.x - circleCenter.x;float x = originalPos.x - circleCenter.x - moveXDistance;float y = Mathf.Sqrt(radius * radius - x * x);float maxY = radius;if (originalPos.y < circleCenter.y){y = -y;maxY = -radius;}Vector2 circlePoint = new Vector2(x, y);if (rect.anchoredPosition.x >= target.anchoredPosition.x){var v1 = circlePoint - (originalPos - circleCenter);var v2 = (originalPos - circleCenter) + new Vector2(0, maxY);v2.Normalize();offset = Vector2.Dot(v1, v2);}else{float tempX = originalPos.x - circleCenter.x;Vector2 originalPos2 = originalPos + 2 * new Vector2(-tempX, 0);var v1 = circlePoint - new Vector2(0, maxY);var v2 = originalPos2 - circleCenter + new Vector2(0, maxY);v2.Normalize();offset = -Vector2.Dot(v1, v2);}if (float.IsNaN(offset)){offset = 0;}x += moveXDistance + offset;Vector2 pos = circleCenter + new Vector2(x, y);rect.anchoredPosition = pos;if (target.anchoredPosition.x >= originalPos.x + originalPos.x - circleCenter.x){rect.anchoredPosition = originalPos;rect.SetAsFirstSibling();}else if (target.anchoredPosition.x <= circleCenter.x){rect.anchoredPosition = originalPos;rect.SetAsFirstSibling();}}if (rect.anchoredPosition.x < -rect.rect.width){Destroy(gameObject);}}
}
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
using Utility;public class PictureWall : MonoBehaviour
{[SerializeField]private GameObject prefab;private const float WIDTH = 3072;private const float HEIGHT = 1664;private int row = 6;private int column;private float intervalDistance = 20;[SerializeField]private float offset = 200;private float itemWidth;private float itemHeight;public float speed = 10;private float time = 0;[SerializeField]private RectTransform target;private string path = "/PictureWall/";private List<string> texturePaths;private int currentIndex = 0;private List<Texture2D> textureList;void Start(){textureList = new List<Texture2D>();path = Application.streamingAssetsPath + path;ReadImage();CalculateRowColumn();enabled = false;}private void ReadImage(){if (!Directory.Exists(path)){Directory.CreateDirectory(path);return;}texturePaths = new List<string>();var jpgs = Directory.GetFiles(path, "*.jpg");texturePaths.AddRange(jpgs);texturePaths.Reverse();if (texturePaths.Count > 100){for (int i = texturePaths.Count - 1; i == 100; i--){File.Delete(texturePaths[i]);texturePaths.RemoveAt(i);}}foreach (var filePath in texturePaths){UtilityLoadImage.I.LoadImage(filePath, tex =>{textureList.Add(tex);addNum++;if (addNum == texturePaths.Count){Spawn();}});}}float addNum = 0;private void Spawn(){float x = 0;float y = 0;for (int i = 0; i < row; i++){y = i * (itemHeight + intervalDistance);for (int j = 0; j < column; j++){x = j * (itemWidth + intervalDistance);if (i % 2 != 0){//x -= offset;}RectTransform rect = Instantiate(prefab, transform).transform as RectTransform;rect.pivot = new Vector2(0.5f, 0.5f);rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, itemWidth);rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, itemHeight);rect.anchoredPosition = new Vector2(x, -y) + new Vector2(rect.rect.width / 2, -rect.rect.height / 2);var controller = rect.GetComponent<ImageItemController>();controller.speed = speed;controller.target = target;if (i % 2 != 0){controller.horizontalOffset = offset;}SetTexture(rect);}}target.SetAsLastSibling();  enabled = true;}private void CalculateRowColumn(){itemHeight = (HEIGHT - (row - 1) * intervalDistance) / row;itemWidth = itemHeight * 16 / 9;//offset = itemWidth / 2;column = (int)(WIDTH / (itemWidth + intervalDistance)) + 3;time = itemWidth / speed;}bool isSpawned = false;private void Update(){if (!isSpawned && transform.childCount <= (column - 1) * row + 1){isSpawned = true;SpawnColumn();}}private void SpawnColumn(){float x = 0;float y = 0;for (int i = 0; i < row; i++){y = i * (itemHeight + intervalDistance);for (int j = 0; j < 1; j++){x = (column - 1) * (itemWidth + intervalDistance);RectTransform rect = Instantiate(prefab, transform).transform as RectTransform;rect.pivot = new Vector2(0.5f, 0.5f);rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, itemWidth);rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, itemHeight);rect.anchoredPosition = new Vector2(x, -y) + new Vector2(intervalDistance - Time.deltaTime * speed, -rect.rect.height / 2);var controller = rect.GetComponent<ImageItemController>();controller.speed = speed;controller.target = target;if (i % 2 != 0){controller.horizontalOffset = offset;}SetTexture(rect);}}target.SetAsLastSibling();StartCoroutine(Delay());}private void SetTexture(RectTransform rect){        rect.GetComponent<RawImage>().texture = textureList[currentIndex];currentIndex = (currentIndex + 1) % texturePaths.Count;}private IEnumerator Delay(){//yield return new WaitForSeconds(0.1f);yield return null;isSpawned = false;}
}
工具类
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;namespace Utility
{public class UtilityLoadImage{public class MonoHelper : MonoBehaviour { }public static UtilityLoadImage I;private static MonoHelper helper;static UtilityLoadImage(){var go = new GameObject("UtilityLoadImage");helper = go.AddComponent<MonoHelper>();UnityEngine.Object.DontDestroyOnLoad(go);I = new UtilityLoadImage();}private UtilityLoadImage() { }#region  inner methodprivate IEnumerator LoadTexture2D(string path, Action<Texture2D> callback){           //Debug.Log("path:" + path);           UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(path);yield return uwr.SendWebRequest();if (uwr.downloadHandler.isDone){var tex = DownloadHandlerTexture.GetContent(uwr);callback?.Invoke(tex);}}private void LoadTexture2DByFile(string path, Action<Texture2D> callback){if (path.StartsWith("file://")){var bytes = File.ReadAllBytes(path);Texture2D tex = new Texture2D(1, 1);if (tex.LoadImage(bytes))callback?.Invoke(tex);}}private IEnumerator LoadByte(string path, Action<byte[]> callback){UnityWebRequest uwr = UnityWebRequest.Get(path);yield return uwr.SendWebRequest();if (uwr.downloadHandler.isDone){var data = uwr.downloadHandler.data;callback?.Invoke(data);}}private void DeleteFolder(string savedFolder, bool clearSavedPath, bool isRecursive = false){if (!Directory.Exists(savedFolder)){Debug.LogError("要删除的文件夹不存在!");return;}if (clearSavedPath){Directory.Delete(savedFolder, isRecursive);Directory.CreateDirectory(savedFolder);}}private byte[] Texture2DToByte(string path, Texture2D tex){byte[] data = null;int index = path.LastIndexOf('.');if (index != -1){string expandedName = path.Substring(index + 1);switch (expandedName){case "jpeg":case "jpg":data = tex.EncodeToJPG();break;case "png":data = tex.EncodeToPNG();break;default:Debug.Log("");break;}}else{Debug.Log("path is not correct!!!");}return data;}private IEnumerator LoadAudio(string path, string savedFolder, string fileName, Action<AudioClip> callback){UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(path, AudioType.MPEG);yield return request.SendWebRequest();if (request.downloadHandler.isDone){File.WriteAllBytes(savedFolder + "/" + fileName, request.downloadHandler.data);AudioClip clip = DownloadHandlerAudioClip.GetContent(request);callback?.Invoke(clip);}}private IEnumerator LoadAudio(string path, string savePath, Action<AudioClip> callback){UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(path, AudioType.MPEG);yield return request.SendWebRequest();if (request.downloadHandler.isDone){File.WriteAllBytes(savePath, request.downloadHandler.data);AudioClip clip = DownloadHandlerAudioClip.GetContent(request);callback?.Invoke(clip);}}private IEnumerator LoadAudio(string path, Action<AudioClip> callback){UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(path, AudioType.MPEG);yield return request.SendWebRequest();if (request.downloadHandler.isDone){AudioClip clip = DownloadHandlerAudioClip.GetContent(request);if (callback != null)callback(clip);elseDebug.Log("加载音频回调为null");}}#endregion#region load and download imagepublic void LoadImage(string path, Action<Texture2D> callback){helper.StartCoroutine(LoadTexture2D(path, callback));}public void LoadImageByFile(string path, Action<Texture2D> callback){LoadTexture2DByFile(path, callback);}public void LoadImages(string[] paths, Action<List<Texture2D>> callback){Debug.Log("start!!!!!");List<Texture2D> list = new List<Texture2D>();for (int i = 0; i < paths.Length; i++){LoadImage(paths[i], tex => list.Add(tex));}callback?.Invoke(list);Debug.Log("end!!!!!" + list.Count);}public void LoadImagesByFile(string[] paths, Action<List<Texture2D>> callback){List<Texture2D> list = new List<Texture2D>();for (int i = 0; i < paths.Length; i++){var data = File.ReadAllBytes(paths[i]);Texture2D tex = new Texture2D(1, 1);if (tex.LoadImage(data))list.Add(tex);}callback?.Invoke(list);}public void DownloadImageAndSave(string url, string savedFolder, string fileName, Action callback = null){helper.StartCoroutine(LoadTexture2D(url, tex =>{File.WriteAllBytes(savedFolder + "/" + fileName, Texture2DToByte(url, tex));callback?.Invoke();}));}public void DownloadImageAndSave(string url, string savePath, Action callback = null){helper.StartCoroutine(LoadTexture2D(url, tex =>{File.WriteAllBytes(savePath, Texture2DToByte(url, tex));callback?.Invoke();}));}public void DownloadImageAndSave_Texture2D(string url, string savedFolder, string fileName, Action<Texture2D> callback = null){helper.StartCoroutine(LoadTexture2D(url, tex =>{File.WriteAllBytes(savedFolder + "/" + fileName, Texture2DToByte(url, tex));callback?.Invoke(tex);}));}public void DownloadImageAndSave_Texture2D(string url, string savePath, Action<Texture2D> callback = null){helper.StartCoroutine(LoadTexture2D(url, tex =>{File.WriteAllBytes(savePath, Texture2DToByte(url, tex));callback?.Invoke(tex);}));}public void DownloadImageAndSave_FilePath(string url, string savedFolder, string fileName, Action<string> callback = null){helper.StartCoroutine(LoadTexture2D(url, tex =>{string path = savedFolder + "/" + fileName;File.WriteAllBytes(path, Texture2DToByte(url, tex));callback?.Invoke(path);}));}public void DownloadImageAndSave_FilePath(string url, string savePath, Action<string> callback = null){helper.StartCoroutine(LoadTexture2D(url, tex =>{File.WriteAllBytes(savePath, Texture2DToByte(url, tex));callback?.Invoke(savePath);}));}public void DownloadImagesAndSave(string[] urls, string savedFolder, string[] fileNames, Action completedCallback = null, bool deleteFolder = false, bool recursive = false){if (urls.Length != fileNames.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}DeleteFolder(savedFolder, deleteFolder, recursive);int completedNum = 0;for (int i = 0; i < urls.Length; i++){DownloadImageAndSave(urls[i], savedFolder, fileNames[i], () =>{++completedNum;if (completedNum == urls.Length){completedCallback?.Invoke();Debug.Log("所以文件下载完成!");}});}}public void DownloadImagesAndSave_Texture2DPaths(string[] urls, string savedFolder, string[] fileNames, Action<string[]> callback = null, bool deleteFolder = false, bool recursive = false){if (urls.Length != fileNames.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}DeleteFolder(savedFolder, deleteFolder, recursive);int completedNum = 0;string[] filePaths = new string[fileNames.Length];for (int i = 0; i < urls.Length; i++){DownloadImageAndSave_FilePath(urls[i], savedFolder, fileNames[i], path =>{filePaths[completedNum] = path;++completedNum;if (completedNum == urls.Length){callback?.Invoke(filePaths);Debug.Log("所以图片下载完成!");}});}}public void DownloadImagesAndSave_Texture2DPaths(string[] urls, string[] savePaths, Action<string[]> callback = null){if (urls.Length != savePaths.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}int completedNum = 0;string[] filePaths = new string[savePaths.Length];for (int i = 0; i < urls.Length; i++){DownloadImageAndSave_FilePath(urls[i], savePaths[i], path =>{filePaths[completedNum] = path;++completedNum;if (completedNum == urls.Length){callback?.Invoke(filePaths);Debug.Log("所以图片下载完成!");}});}}public void DownloadImagesAndSave_Texture2Ds(string[] urls, string savedFolder, string[] fileNames, Action<Texture2D[]> callback = null, bool deleteFolder = false, bool recursive = false){if (urls.Length != fileNames.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}DeleteFolder(savedFolder, deleteFolder, recursive);int completedNum = 0;Texture2D[] textures = new Texture2D[fileNames.Length];for (int i = 0; i < urls.Length; i++){DownloadImageAndSave_Texture2D(urls[i], savedFolder, fileNames[i], tex =>{textures[completedNum] = tex;++completedNum;if (completedNum == urls.Length){callback?.Invoke(textures);Debug.Log("所以图片下载完成!");}});}}public void DownloadImagesAndSave_Texture2Ds(string[] urls, string[] savePaths, Action<Texture2D[]> callback = null){if (urls.Length != savePaths.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}int completedNum = 0;Texture2D[] textures = new Texture2D[savePaths.Length];for (int i = 0; i < urls.Length; i++){DownloadImageAndSave_Texture2D(urls[i], savePaths[i], tex =>{textures[completedNum] = tex;++completedNum;if (completedNum == urls.Length){callback?.Invoke(textures);Debug.Log("所以图片下载完成!");}});}}#endregion#region download filepublic void DownloadFileAndSave(string url, string savedFolder, string fileName, Action callback = null){helper.StartCoroutine(LoadByte(url, data =>{File.WriteAllBytes(savedFolder + "/" + fileName, data);callback?.Invoke();}));}public void DownloadFileAndSave(string url, string savePath, Action callback = null){helper.StartCoroutine(LoadByte(url, data =>{File.WriteAllBytes(savePath, data);callback?.Invoke();}));}public void DownloadFileAndSave_FilePath(string url, string savedFolder, string fileName, Action<string> callback = null){helper.StartCoroutine(LoadByte(url, data =>{string path = savedFolder + "/" + fileName;File.WriteAllBytes(path, data);callback?.Invoke(path);}));}public void DownloadFileAndSave_FilePath(string url, string savePath, Action<string> callback = null){helper.StartCoroutine(LoadByte(url, data =>{File.WriteAllBytes(savePath, data);callback?.Invoke(savePath);}));}public void DownloadFileAndSave_FileData(string url, string savedFolder, string fileName, Action<byte[]> callback = null){helper.StartCoroutine(LoadByte(url, data =>{string path = savedFolder + "/" + fileName;File.WriteAllBytes(path, data);callback?.Invoke(data);}));}public void DownloadFileAndSave_FileData(string url, string savePath, Action<byte[]> callback = null){helper.StartCoroutine(LoadByte(url, data =>{File.WriteAllBytes(savePath, data);callback?.Invoke(data);}));}public void DownloadFilesAndSave(string[] urls, string savedFolder, string[] fileNames, Action completedCallback = null, bool deleteFolder = false, bool recursive = false){if (urls.Length != fileNames.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}DeleteFolder(savedFolder, deleteFolder, recursive);int completedNum = 0;for (int i = 0; i < urls.Length; i++){DownloadFileAndSave(urls[i], savedFolder, fileNames[i], () =>{++completedNum;if (completedNum == fileNames.Length){completedCallback?.Invoke();}});}}public void DownloadFilesAndSave(string[] urls, string[] savePath, Action callback = null){if (urls.Length != savePath.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}int completedNum = 0;for (int i = 0; i < urls.Length; i++){DownloadFileAndSave(urls[i], savePath[i], () =>{++completedNum;if (completedNum == savePath.Length){callback?.Invoke();}});}}public void DownloadFilesAndSave_FilePaths(string[] urls, string savedFolder, string[] fileNames, Action<string[]> completedCallback = null, bool deleteFolder = false, bool recursive = false){if (urls.Length != fileNames.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}DeleteFolder(savedFolder, deleteFolder, recursive);int completedNum = 0;string[] filePaths = new string[fileNames.Length];for (int i = 0; i < urls.Length; i++){DownloadFileAndSave_FilePath(urls[i], savedFolder, fileNames[i], path =>{filePaths[completedNum] = path;++completedNum;if (completedNum == fileNames.Length){completedCallback?.Invoke(filePaths);}});}}public void DownloadFilesAndSave_FilePaths(string[] urls, string[] savePath, Action<string[]> completedCallback = null){if (urls.Length != savePath.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}int completedNum = 0;string[] filePaths = new string[savePath.Length];for (int i = 0; i < urls.Length; i++){DownloadFileAndSave_FilePath(urls[i], savePath[i], path =>{filePaths[completedNum] = path;++completedNum;if (completedNum == savePath.Length){completedCallback?.Invoke(filePaths);}});}}public void DownloadFilesAndSave_FileDatas(string[] urls, string savedFolder, string[] fileNames, Action<List<byte[]>> completedCallback = null, bool deleteFolder = false, bool recursive = false){if (urls.Length != fileNames.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}DeleteFolder(savedFolder, deleteFolder, recursive);int completedNum = 0;List<byte[]> allDatas = new List<byte[]>(fileNames.Length);for (int i = 0; i < urls.Length; i++){DownloadFileAndSave_FileData(urls[i], savedFolder, fileNames[i], data =>{allDatas.Add(data);++completedNum;if (completedNum == fileNames.Length){completedCallback?.Invoke(allDatas);}});}}public void DownloadFilesAndSave_FileDatas(string[] urls, string[] savePath, Action<List<byte[]>> completedCallback = null){if (urls.Length != savePath.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}int completedNum = 0;List<byte[]> allDatas = new List<byte[]>(savePath.Length);for (int i = 0; i < urls.Length; i++){DownloadFileAndSave_FileData(urls[i], savePath[i], data =>{allDatas.Add(data);++completedNum;if (completedNum == savePath.Length){completedCallback?.Invoke(allDatas);}});}}#endregion#region download audiopublic void DownloadAudioAndSave_FileData(string url, string savedFolder, string fileName, Action<AudioClip> callback = null){helper.StartCoroutine(LoadAudio(url, savedFolder, fileName, callback));}public void DownloadAudioAndSave_FileData(string url, string savePath, Action<AudioClip> callback = null){helper.StartCoroutine(LoadAudio(url, savePath, callback));}public void LoadAudioClip(string url, Action<AudioClip> callback = null){helper.StartCoroutine(LoadAudio(url, callback));}#endregion}
}

相关文章:

Unity照片墙简易圆形交互效果总结

还要很多可以优化的点地方&#xff0c;有兴趣的可以做 比如对象的销毁和生成可以做成对象池&#xff0c;走到最左边后再移动到最右边循环利用 分析过程文件&#xff0c;采用Blender&#xff0c;资源已上传&#xff0c;可以播放动画看效果&#xff0c;下面截个图&#xff1a; …...

Unity2018发布安卓报错 Exception: Gradle install not valid

Unity2018发布安卓报错 Exception: Gradle install not valid Exception: Gradle install not valid UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action1[T] progress) (at <c67d1645d7ce4b76823a39080b82c1d1>:0) …...

蓝桥杯省赛刷题——题目 2656:刷题统计

刷题统计OJ链接&#xff1a;蓝桥杯2022年第十三届省赛真题-刷题统计 - C语言网 (dotcpp.com) 题目描述 小明决定从下周一开始努力刷题准备蓝桥杯竞赛。他计划周一至周五每天做 a 道题目&#xff0c;周六和周日每天做 b 道题目。请你帮小明计算&#xff0c;按照计划他将在第几…...

Python爬虫之异步爬虫

异步爬虫 一、协程的基本原理 1、案例 案例网站&#xff1a;https://www.httpbin.org/delay/5、这个服务器强制等待了5秒时间才返回响应 测试&#xff1a;用requests写一个遍历程序&#xff0c;遍历100次案例网站&#xff1a; import requests import logging import time…...

【Web】NSSCTF Round#20 Basic 个人wp

目录 前言 真亦假&#xff0c;假亦真 CSDN_To_PDF V1.2 前言 感谢17&#x1f474;没让我爆零 真亦假&#xff0c;假亦真 直接getshell不行&#xff0c;那就一波信息搜集呗&#xff0c;先开dirsearch扫一下 扫的过程中先试试常规的robots.txt,www.zip,shell.phps,.git,.sv…...

【Java笔记】实现延时队列1:JDK DelayQueue

文章目录 需求创建订单类创建延时队列优缺点 Reference JDK DelayQueue是一个无阻塞队列&#xff0c;底层是 PriorityQueue 需求 经典的订单超时取消 创建订单类 放入DelayQueue的对象需要实现Delayed接口 public interface Delayed extends Comparable<Delayed> {…...

npm淘宝镜像源切换

查询 npm config get registry注意因为淘宝的镜像域名更换&#xff0c;https://registry.npm.taobao.org域名HTTPS证书到期更换为https://registry.npmmirror.com/ 切换 npm config set registry https://registry.npmmirror.com/...

ENet——实时语义分割的深度神经网络架构与代码实现

概述 在移动设备上执行实时像素级分割任务具有重要意义。现有的基于分割的深度神经网络需要大量的浮点运算&#xff0c;并且通常需要较长时间才能投入使用。本文提出的ENet架构旨在减少潜在的计算负担。ENet在保持或提高分割精度的同时&#xff0c;相比现有的分割网络&#xf…...

游戏领域AI智能视频剪辑解决方案

游戏行业作为文化创意产业的重要组成部分&#xff0c;其发展和创新速度令人瞩目。然而&#xff0c;随着游戏内容的日益丰富和直播文化的兴起&#xff0c;传统的视频剪辑方式已难以满足玩家和观众日益增长的需求。美摄科技&#xff0c;凭借其在AI智能视频剪辑领域的深厚积累和创…...

腾讯云轻量2核2G3M云服务器优惠价格61元一年,限制200GB月流量

腾讯云轻量2核2G3M云服务器优惠价格61元一年&#xff0c;配置为轻量2核2G、3M带宽、200GB月流量、40GB SSD盘&#xff0c;腾讯云优惠活动 yunfuwuqiba.com/go/txy 活动链接打开如下图&#xff1a; 腾讯云轻量2核2G云服务器优惠价格 腾讯云&#xff1a;轻量应用服务器100%CPU性能…...

leecode 331 |验证二叉树的前序序列化 | gdb 调试找bug

计算的本质是数据的计算 数据的计算需要采用格式化的存储&#xff0c; 规则的数据结果&#xff0c;可以快速的按照指定要求存储数据 这里就不得不说二叉树了&#xff0c;二叉树应用场景真的很多 本题讲的是&#xff0c;验证二叉树的前序序列化 换言之&#xff0c;不采用建立树的…...

服务器安全事件应急响应排查方法

针对服务器操作系统的安全事件也非常多的。攻击方式主要是弱口令攻击、远程溢出攻击及其他应用漏洞攻击等。分析安全事件&#xff0c;找到入侵源&#xff0c;修复漏洞&#xff0c;总结经验&#xff0c;避免再次出现安全事件&#xff0c;以下是参考网络上文章&#xff0c;总结的…...

数码视讯Q7盒子刷armbian或emuelec的一些坑

首先&#xff0c;我手头的盒子是nand存储的&#xff0c;如果是emmc的&#xff0c;会省事很多…… 以下很多结论是我的推测&#xff0c;不一定准确。 1&#xff0c;原装安卓系统不支持SD卡或U盘启动&#xff0c;所以只能进uboot修改启动参数 2&#xff0c;原装安卓系统应该是…...

2_2.Linux中的远程登录服务

# 一.Openssh的功能 # 1.sshd服务的用途# #作用&#xff1a;可以实现通过网络在远程主机中开启安全shell的操作 Secure SHell >ssh ##客户端 Secure SHell daemon >sshd ##服务端 2.安装包# openssh-server 3.主配置文件# /etc/ssh/sshd_conf 4.…...

Spring Boot集成JPA快速入门demo

1.JPA介绍 JPA (Java Persistence API) 是 Sun 官方提出的 Java 持久化规范。它为 Java 开发人员提供了一种对象/关联映射工具来管理 Java 应用中的关系数据。他的出现主要是为了简化现有的持久化开发工作和整合 ORM 技术&#xff0c;结束现在 Hibernate&#xff0c;TopLink&am…...

深度学习理解及学习推荐(持续更新)

主推YouTuBe和Bilibili 深度学习博主推荐&#xff1a; Umar Jamil - YouTubehttps://www.youtube.com/umarjamilai StatQuest with Josh Starmer - YouTubehttps://www.youtube.com/statquest RNN Illustrated Guide to Recurrent Neural Networks: Understanding the Int…...

【C语言】贪吃蛇【附源码】

欢迎来到英杰社区https://bbs.csdn.net/topics/617804998 一、游戏说明&#xff1a; 一个基于C语言链表开发的贪吃蛇游戏&#xff1a; 1. 按方向键上下左右&#xff0c;可以实现蛇移动方向的改变。 2. 短时间长按方向键上下左右其中之一&#xff0c;可实现蛇向该方向的短时间…...

【技巧】压缩文件如何设置“自动加密”?

很多人会在压缩文件的时候&#xff0c;同时设置密码&#xff0c;以此保护私密文件。如果经常需要压缩文件并设置密码&#xff0c;不妨使用解压缩软件的“自动加密”功能&#xff0c;更省时省力。 下面介绍WinRAR解压缩软件的两种“自动加密”的方法&#xff0c;一起来看看吧&a…...

内网穿透时报错【Bad Request This combination of host and port requires TLS.】的原因

目录 前言&#xff1a;介绍一下内网穿透 1.内网直接https访问&#xff08;可以正常访问&#xff09; 程序配置的证书 2.内网穿透后,通过外网访问 3.原因 4.内网非https的Web应用&#xff0c;使用https后&#xff0c;也变成了https访问 5.题外话 感觉自己的web应用配置了…...

计算机网络:物理层 - 信道复用

计算机网络&#xff1a;物理层 - 信道复用 频分复用时分复用统计时分复用波分复用码分复用 计算机网络中&#xff0c;用户之间通过信道进行通信&#xff0c;但是信道是有限的&#xff0c;想要提高网络的效率&#xff0c;就需要提高信道的利用效率。因此计算机网络中普遍采用信道…...

【算法集训】基础算法:滑动窗口

定义一个快慢指针&#xff0c;用于截取数组中某一段信息。同时可以改变快慢指针的值来获取结果&#xff0c;这个过程比较像滑动。 1493. 删掉一个元素以后全为 1 的最长子数组 定义快慢指针快指针先走&#xff0c;如果到了第二个0上的时候。前面1的个数就是fast - slow - 1&a…...

QT 二维坐标系显示坐标点及点与点的连线-通过定时器自动添加随机数据点

QT 二维坐标系显示坐标点及点与点的连线-通过定时器自动添加随机数据点 功能介绍头文件C文件运行过程 功能介绍 上面的代码实现了一个简单的 Qt 应用程序&#xff0c;其功能包括&#xff1a; 创建一个 MainWindow 类&#xff0c;继承自 QMainWindow&#xff0c;作为应用程序的…...

C语言TCP服务器模型 : select + 多线程与双循环单线程阻塞服务器的比较

观察到的实验现象: 启动三个客户端: 使用双循环阻塞服务器:只能accept后等待收发,同时只能与一个客户端建立连接,必须等已连接的客户端多次收发 明确断开后才能与下个客户端连接 使用IO多路复用select:可以同时接收所有的连接请求,并且连接状态一直是存活的,直到客户端关闭连…...

【数字IC/FPGA】手撕代码:模3检测器(判断输入序列能否被3整除)

今天我们来手撕一个常见的笔试题&#xff0c;使用的方法是三段式Moore状态机。 题目描述&#xff1a; 输入端口是串行的1bit数据&#xff0c;每个时钟周期进来一位新数据后&#xff0c;实时检查当前序列是否能整除3&#xff0c;若能则输出1&#xff0c;否则输出0。 例如&#…...

最小可行产品需要最小可行架构——可持续架构(三)

前言 最小可行产品&#xff08;MVP&#xff09;的概念可以帮助团队专注于尽快交付他们认为对客户最有价值的东西&#xff0c;以便在投入大量时间和资源之前迅速、廉价地评估产品的市场规模。MVP不仅需要考虑产品的市场可行性&#xff0c;还需要考虑其技术可行性&#xff0c;以…...

笔记: 数据结构与算法--时间复杂度二分查找数组

算法复杂度 不依赖于环境因素事前分析法 计算最坏情况的时间复杂度每一条语句的执行时间都按照t来计算 时间复杂度 大O表示法 n 数据量 ; f(n) 实际的执行条数当存在一个n0 , 使得 n > n0,并且 c * g(n) 恒> f(n) : 渐进上界(算法最坏的情况)那么f(n)的时间复杂度 …...

AI绘画教程:Midjourney使用方法与技巧从入门到精通

文章目录 一、《AI绘画教程&#xff1a;Midjourney使用方法与技巧从入门到精通》二、内容介绍三、作者介绍&#x1f324;️粉丝福利 一、《AI绘画教程&#xff1a;Midjourney使用方法与技巧从入门到精通》 一本书读懂Midjourney绘画&#xff0c;让创意更简单&#xff0c;让设计…...

Spring-事务管理

1、事务管理 1.1、回滚方式 默认回滚方式&#xff1a;发生运行异常时异常和error时回滚&#xff0c;发生受查(编译&#xff09;异常时提交。不过&#xff0c;对于受查异常&#xff0c;程序员也可以手工设置其回滚方式 1.2、事务定义接口 1.2.1、事务隔离级别常量 这些常量…...

MySql实战--为什么我的MySQL会“抖”一下

时的工作中&#xff0c;不知道你有没有遇到过这样的场景&#xff0c;一条SQL语句&#xff0c;正常执行的时候特别快&#xff0c;但是有时也不知道怎么回事&#xff0c;它就会变得特别慢&#xff0c;并且这样的场景很难复现&#xff0c;它不只随机&#xff0c;而且持续时间还很短…...

【蓝桥杯第十三届省赛B】(部分详解)

九进制转十进制 #include <iostream> #include<math.h> using namespace std; int main() {cout << 2*pow(9,3)0*pow(9,2)2*pow(9,1)2*pow(9,0) << endl;return 0; }顺子日期 #include <iostream> using namespace std; int main() {// 请在此…...

wordpress the7主题/什么是seo站内优化

这可以通过将两个指标编码为同一进度条的主要进度和次要进度来完成.为进度条创建一个子类.public class TextProgressBar extends ProgressBar {private Paint textPaint;public TextProgressBar(Context context) {super(context);textPaint new Paint();textPaint.setColor(…...

网站设置在哪/网页制作免费模板

我的世界scpv3模组是一款超级令人喜欢的模组手机版本了&#xff0c;能够在手机里面体验到全新的内容的游戏。玩家们可以加入这款特别的像素游戏&#xff0c;加入独特的沙盒模式中挑战&#xff0c;更有趣味的沙盒内容可以来体验&#xff0c;给玩家们独特的游戏内容。我的世界scp…...

装修网站合作/百度关键词指数查询

ROS支持多机互通&#xff0c;可以设置一台主机&#xff0c;多台从机&#xff0c;主机中运行roscore&#xff0c;启动master节点&#xff0c;从机直接运行其他节点&#xff0c;在配置好的机器之间就可以互相通信了&#xff0c;就像在同一台机器上一样。 具体应该如何配置呢&…...

温州大型网站设计公司/网址收录

查看效果&#xff1a;http://keleyi.com/keleyi/phtml/html5/7.htm完整代码&#xff1a;复制代码代码如下:用html5的canvas画布绘制贝塞尔曲线原文function draw(id){var canvasdocument.getelementbyid(id);if(canvasnull)return false;var contextcanvas.getcontext(2d);cont…...

云虚拟主机 wordpress/郑州seo优化阿亮

转载自&#xff1a; 用 jQuery 和 Bootstrap 在 WordPress 中添加进度条 - 丘壑博客​bestscreenshot.com需求昨天整理了一下Genesis的系列教程的翻译进度&#xff0c;汇总成了一个页面 神级 WordPress 主题框架 Genesis 从入门到精通 。 今天突然想放一个进度条&#xff0c;可…...

wordpress 撰写设置/seo搜索引擎优化排名哪家更专业

getattr()从名字上看获取属性值&#xff0c;若属性存在&#xff0c;返回属性值&#xff0c;若属性不存在&#xff0c;则报错&#xff0c;具体的用法如下&#xff1a; class Person():age 14 Tom Person() print(getattr(Tom,age))#14 print(getattr(Tom,name))#因为name属性…...