rect

Android:Canvas中drawText的尺寸计算

女生的网名这么多〃 提交于 2020-01-23 19:19:38
主要思路:根据FontMetrica计算Text的高度,根据Rect计算Text的宽度。两者与字体,字号有关系 参考文章: http://blog.csdn.net/hursing/article/details/18703599 http://blog.csdn.net/sirnuo/article/details/21165665 1. 计算高度不应该用Rect的原因:FontMetrica与Text内容无关;Rect与Text的内容相关,用Rect计算的话会麻烦一点。paint.getTextBounds() paint.getFontMetricsInt() 2. 要正确理解FontMetrica的top,ascent,descent,bottom的含义。以上四个参数都是相对于baseLine而言的 3. 如上图:Text在Y轴的范围在:[baseLine+top,baseLine+bottom] 4. drawText(text, baseX, baseY, p aint) 中对baseX,baseY的理解:baseY即为baseLine,baseX则取决于p aint.setTextAlign(Align. LEFT )参数的设置。 5. 使用场景:Text水平,垂直都居中 package cc.makeblock.widget; import android

What's the difference between the .width and .w attribute of a Pygame Rect object?

孤者浪人 提交于 2020-01-23 03:21:13
问题 The official pygame documentation states that there are several virtual attributes which can be used to move and align a pygame.Rect instance: Until now I used myRect.w respectively myRect.h to determine the width or height of an pygame.Rect object. But to complete this graphic I came across the .width and .height attributes . The interesting thing is that both attributes seem to provide us the same date , as you can see in following code listing: >>> myRect = pygame.Rect((10, 20), (200,100))

01

落爺英雄遲暮 提交于 2020-01-23 02:56:43
Unity AssetStore中关于Node节点 编辑器相关的插件可是数不胜数, 状态机,行为树,Shader 可视化等等。 Unity自己也有 Animator的窗口使用, 还有新的Shader Graph。 现在Unity的编辑器代码已经开源了,还没有时间看。 第一部分, 创建界面 功能 在这篇博文中,我们将在Unity中创建我们自己的基于节点的编辑器。 是一个简单的节点编辑器,您可以进行改进。 我们将在这篇文章中创建这个窗口(点击查看gif的动作) 创建窗口 我们先创建一个简单的编辑器窗口。 代码的结构与我们在之前的文章中开发的控制台克隆类似:首先绘制元素,然后处理输入,并且如果由于输入事件而改变GUI,则强制窗口重绘。 using UnityEngine; using UnityEditor; using System.Collections.Generic; public class NodeBasedEditor : EditorWindow { [MenuItem("Window/Node Based Editor")] private static void OpenWindow() { NodeBasedEditor window = GetWindow<NodeBasedEditor>(); window.titleContent = new

外星人入侵实例二

自作多情 提交于 2020-01-23 02:41:38
Python编程从入门到精通:外星人入侵实例(二) 文件结构 bullet.py alinen_invasion.py settings.py game_functions.py ship.py 小结 本文中代码来自《Python编程从入门到精通》一书 本文为第二天实践结果 文件结构 外星人入侵———— —images文件夹 ——ship.bmp —bullet.py —alien_invasion.py —game_functions.py —settings.py —ship.py bullet.py import pygame from pygame . sprite import Sprite class Bullet ( Sprite ) : """一个对飞船发射的子弹进行管理的类""" def __init__ ( self , ai_settings , screen , ship ) : """在飞船所处的位置创建一个子弹对象""" super ( Bullet , self ) . __init__ ( ) self . screen = screen #在(0,0)处创建一个表示子弹的矩形,在设置正确的位置 self . rect = pygame . Rect ( 0 , 0 , ai_settings . bullet_width , ai_settings

HTML:分区响应图

不打扰是莪最后的温柔 提交于 2020-01-22 14:18:14
参考: https://www.jianshu.com/p/f877cbe7cfd9 分区响应图 含义 当超链接按钮是图片时,将图片进行划分,使得点击图片不同区域时,会有不同的反馈。 比如,点击图片的不同区域,跳转至不同的页面。 使用 <map> 、 <area> 标签 < img src = " ./1.png " usemap = " #myMap " /> < map name = " myMap " > < area href = " http://baidu.com " shape = " rect " coords = " 50,106,220,273 " /> < area href = " http://google.com " shape = " rect " coords = " 260,106,430,275 " /> < area href = " http://juejin.im " shape = " default " /> </ map > 获取坐标 当然啦,可以先利用 form 和 input 获取像素点坐标来获取区域坐标。 < form action = " " > < input type = " image " src = " ./1.png " width = " 400 " > </ form > 可在浏览器中 url 地址栏末端看到 x

Chrome插件——一键保存网页为PDF1.0

早过忘川 提交于 2020-01-22 12:42:25
Chrome插件——一键保存网页为PDF1.0 http://www.cnblogs.com/bdstjk/p/3163723.html 仿照网上的一个代码写的,地址找不到了。 将窗体,控件什么的都封装到一个类库里面了,方便以后使用。 源码下载: http://download.csdn.net/detail/bdstjk/5679651 界面效果: 窗体模板,主要是实现一个无边框窗体,并添加阴影效果。 <Style TargetType="DazzleWPF:DazzleWindow"> <Setter Property="AllowsTransparency" Value="true"/> <Setter Property="Background" Value="Transparent"/> <!--<Setter Property="ResizeMode" Value="CanResizeWithGrip"/>--> <Setter Property="WindowStyle" Value="None"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="DazzleWPF:DazzleWindow"> <Grid Margin="5"> <Rectangle Fill="

c++编程技巧

不羁岁月 提交于 2020-01-21 23:02:38
  c++庞大精深,在学习时必须有一定的代码量,写的多了,慢慢就知道c++代码怎么写了。 typedef Rect_<int> Rect2i; //typedef的使用。 typedef Rect_<float> Rect2f; typedef Rect_<double> Rect2d; typedef Rect2i Rect;    来源: https://www.cnblogs.com/Robin008/p/12227181.html

Unity 视频缩略图获取

↘锁芯ラ 提交于 2020-01-20 08:25:44
IEnumerator GetVideoThumb(string urlpath,int index) { print(index); Transform go= Instantiate(VideoPlayerPrefab); VideoPlayer tmpVp= go.gameObject.AddComponent<VideoPlayer>(); go.gameObject.AddComponent<IndexNumber>(); go.GetComponent<IndexNumber>().index = index; tmpVp.source = VideoSource.Url; tmpVp.url = urlpath; tmpVp.sendFrameReadyEvents = true; //绑定的事件会不断调用 tmpVp.frameReady += OnNewFrame; tmpVp.Play(); yield return null; //while (tmpVp.texture == null|| tmpVp.isPlaying==false) //{ // yield return new WaitForSeconds(1.5f); //} //Texture2D videoFrameTexture = new Texture2D(Screen.width,

OpenCV——银行卡识别

与世无争的帅哥 提交于 2020-01-20 00:34:50
之前写过关于车牌识别的项目,银行卡识别和车牌识别类似,也是先从待检测图片中找到银行卡号码的区域,再将号码提取出来。 银行卡识别的难点在于: 1.银行卡种类繁多,不能使用一类固定的算法识别所有的银行卡。 2.银行卡固定和银行卡号码区域的固定比较复杂,因为主要应用于手机拍摄识别,所以像素光线都会产生很大影响。 针对手机拍摄有两套方案: 1.拍摄时固定好银行卡的位置,这样我们就不需要先进行银行卡区域的提取,直接提取银行卡号码区域。 2.对于普通拍摄照片,先进行银行卡区域提取,再提取银行卡号码区域。 版本更新: CardOCR1.0 ——银行卡轮廓和数字轮廓均采用canny边缘检测算法。 CardOCR1.1 ——银行卡轮廓定位利用sobel算法替代canny算法。获取数字区域过程中采用增强对比度再利用特定阈值获取数字区域替代了之前canny算法的边缘检测。识别效果较之前有比较大的提升,鲁棒性也更好了。下一阶段是关于银行卡轮廓的偏斜扭正,和利用人工神经网络识别数字。 这里我们先采用第二种方案,如果后续识别效果不理想我们再采用第一种。 大概流程: 1.提取银行卡轮廓 2.偏斜扭正 3.获取数字区域 4.数字识别 我这里刚开始采用农业银行的银行卡做为研究,后期再推及其他银行卡。 原图:(来自百度) (1)提取银行卡轮廓 高斯模糊-》灰度化-》Canny边缘检测-》二值化-》找轮廓-》轮廓判断

svg蒙版mask

戏子无情 提交于 2020-01-19 13:10:11
mask的形状,fill黑色可见,白色不可见。 <svg width="400" height="300"> <defs> <mask id="small-rect"> <rect x="0" y="0" width="400" height="300" fill="white"></rect> <rect width="100" height="100" fill="black" x="200" y="100"></rect> </mask> </defs> <rect id="back" x="0" y="0" width="400" height="300" fill="#d4fcff"></rect> <rect id="front" x="0" y="0" width="400" height="300" fill="#fcd3db" mask="url(#small-rect)"></rect> </svg> 来源: https://www.cnblogs.com/-outman/p/12213181.html