rect

Detect if one rect can be put into another rect

北慕城南 提交于 2019-12-04 17:48:26
问题 This problem is different from testing if one rect is in another rect. Known information is the sides length of two rects. How to calculate if one rect can be put into another rect? 回答1: This is a great question! If and only if one of these conditions is satisfied does a smaller rectangle with sides p and q ( p >= q ) fit completely into a larger rectangle with sides a and b ( a >= b ): or See this for reference. So if we had variables a , b , p , q , we could check if such a rectangle

C++ 虚析构函数

天涯浪子 提交于 2019-12-04 16:27:13
防止内存泄露 子类继承父类后,在子类构造函数里,通过new 来生成一个对象实例 在析构函数里执行释放内存操作,如果父类不加上virtual 关键词 则子类执行的是父类的析构函数,不执行自己的析构函数。 父类不加virtual 子类继承后,并执行析构函数: #include <iostream> /** * C++多态 虚析构函数 (防止内存泄露) */ using namespace std; //形状 class Shape { public: Shape(); ~Shape(); virtual double calcArea(); }; class Coordinate { public: Coordinate(int x, int y); ~Coordinate(); protected: int m_iX; int m_iY; }; //Circle继承Shape class Circle : public Shape { public: Circle(double r); ~Circle(); double calcArea(); protected: double m_dR; Coordinate *coordinate; protected: string m_strName; }; //Rect继承Shape class Rect : public Shape {

C++ 虚函数

北战南征 提交于 2019-12-04 16:24:52
父类函数不加virtual关键词,子类继承后,当父类指针指向子类指针,同样的函数,会执行父类的函数。子类的函数实际是被隐藏了,如果用子类的指针指向自己的话,是能够执行的。 #include <iostream> /** * C++多态 虚函数 */ using namespace std; class Shape { public: Shape(); ~Shape(); double calcArea(); }; class Circle : public Shape { public: Circle(double r); ~Circle(); double calcArea(); protected: double m_dR; protected: string m_strName; }; class Rect : public Shape { public: Rect(double width, double height); ~Rect(); double calcArea(); protected: double m_dWidth; double m_dHeight; }; Rect::Rect(double width, double height) { m_dHeight = height; m_dWidth = width; cout << "Rect::Rect()

QT学习之绘图的总结

一笑奈何 提交于 2019-12-04 15:36:57
1、绘图的事件 QBitmap ----> QPixmap QBitmap继承于Qpixmap 两者的区别在于QBitmap用于画黑白图-------->优点:资源消耗小 而QPixmap在于画彩色图--------->缺点:资源消耗大 主要的过程:1、要有画家 2、和画图设备 在qt中为我们准备了三个类QPainter、QPaintEngine、QPaintDevice 我们通常只用到第一个和第三个 中间的一个在绘图过程中就已经被实现了------------->具体的详情等以后学通了在深究(一般只有qt设计人员会用到) 现在开始绘图: 1、首先重写绘图事件: protected: void paintEvent(QPaintEvent*); //虚函数 注意事项:如果在窗口绘图,必须在绘图事件中实现 绘图事件内部自动调用,窗口需要重绘的时候(状态改变)----------->可能不理解,先接着往下看 2、画图片 QPainter p; p.begin(this); //p.drawPixmap(0,0,width(),height(),QPixmap("../325724.jpg")); //在这里来解释一下自动调用的意思,当我们改变窗口的大小时, width(),height()都会自动的获取新窗口的大小 p.drawPixmap(rect(),QPixmap("..

go接口

邮差的信 提交于 2019-12-04 12:11:48
## 自己总结的接口的由来:## 先定义两个结构体A、B,===> 给A、B分别定义两个结构体方法A.area、A.perim、B.area、B.perim ===> 正巧,这两个结构体有相同的方法,就把这些方法提出来,构造成## 一个结构体:type some_name(自定义的结构体名称 ) interfaces(固定关键字) {  area() float64 perim() float64}===> 调用接口,给接口传入不同的结构体实例对象,就能执行所有的结构体函数# 以下是官方实例// _接口(Interfaces)_ 是类型方法的集合。 package main import "fmt" import "math" // 这里是一个几何体的基本接口。 type geometry interface { area() float64 perim() float64 } // 在我们的例子中,我们将在类型 `rect` 和 `circle` 上实现 // 这个接口 type rect struct { width, height float64 } type circle struct { radius float64 } // 要在 Go 中实现一个接口,我们就需要实现接口中的所有 // 方法。这里我们在 `rect` 上实现了 `geometry` 接口。 func

Looking for a non “brute force” algorithm to remove intersecting areas of a collection of Rects

北城以北 提交于 2019-12-04 08:05:21
I have an n-sized collection of Rects, most of which intersect each other. I'd like to remove the intersections and reduce the intersecting Rects into smaller non-intersecting rects. I could easily brute force a solution, but I'm looking for an efficient algorithm. Here's a visualization: Original: Processed: Ideally the method signature would look like this: public static List<RectF> resolveIntersection(List<RectF> rects); the output would be greater or equal to the input, where the output resolves the above visual representation. this is a problem I solved in the past. The first thing it to

SVG-变换

此生再无相见时 提交于 2019-12-04 00:55:59
transform 变换 translate 平移 <svg width="200" height="50"> <rect x="0" y="0" width="20" height="10" fill="red "/> <rect x="0" y="0" width="20" height="10" transform="translate(10, 20)"/> </svg> See the Pen svg-example-17 by flqbestboy ( @fanlinqiang ) on CodePen . rotate 旋转 // angle 旋转角度,>0 顺时针 // [centerX, centerY] 旋转中心点 rotate(angle, [centerX, centerY]) <svg width="200" height="50"> <rect x="20" y="0" width="20" height="10" fill="red "/> <rect x="20" y="0" width="20" height="10" transform="rotate(30)" fill="green"/> <rect x="20" y="0" width="20" height="10" transform="rotate(-180, 20, 10)"/> <

SVG-概述/容器与通用属性/标签/变换/JS操作/示例

早过忘川 提交于 2019-12-04 00:11:34
参考: SVG 图像入门教程 MDN SVG SVG教程 SVG入门-踏得 工具: svg在线编辑 概述 SVG 是一种基于 XML 语法的图像格式,全称是可缩放矢量图(Scalable Vector Graphics)。其他图像格式都是基于像素处理的,SVG 则是属于对图像的形状描述,所以它本质上是文本文件,体积较小,且不管放大多少倍都不会失真。 SVG 文件可以直接插入网页,成为 DOM 的一部分,然后用 JavaScript 和 CSS 进行操作。如: <svg width="150" height="100" viewBox="0 0 3 2"> <rect width="1" height="2" x="0" fill="#008d46" /> <rect width="1" height="2" x="1" fill="#ffffff" /> <rect width="1" height="2" x="2" fill="#d2232c" /> </svg> <rect width="1" height="2" x="0" fill="#008d46" /> <rect width="1" height="2" x="1" fill="#ffffff" /> <rect width="1" height="2" x="2" fill="#d2232c" /> SVG

基于OpenCV进行文本分块切割

纵然是瞬间 提交于 2019-12-03 23:59:37
假设有如下一张图,如何把其中的文本分块切割出来,比如“华普超市朝阳门店”、“2015-07-26”就是两个文本块。 做图像切割有很多种方法,本文描述一种最直观的投影检测法。先来看看什么是投影,简单来说,投影就是在一定方向上有效像素的数量。来看个直观的图像: 这是一张水平投影图与原图的对比,从投影图上能看到多个波峰,文字多的地方,投影就长,行间的空白处,投影为0。 上个示例代码: public void HorizontalProjection() { //以灰度图方式读入源文件 string filename = "source.jpg"; var src = IplImage.FromFile(filename, LoadMode.GrayScale); //二值化,采用阈值分割法 Cv.Threshold(src, src, 0, 255, ThresholdType.BinaryInv | ThresholdType.Otsu); //存储投影值的数组 var h = new int[src.Height]; //对每一行计算投影值 for(int y = 0;y < src.Height;++y) { //遍历这一行的每一个像素,如果是有效的,累加投影值 for(int x = 0;x < src.Width;++x) { var s = Cv.Get2D(src, y,

android中简单的图形绘制

北城余情 提交于 2019-12-03 19:38:38
今天彻底的了解了画图的工具,希望能帮助各位 在我们写一个类继承view的同时,需要实现一个onDraw()的方法 Paint paint=new Paint(); paint.setAntiAlias(true); //设置画笔为无锯齿,如果不设置,可以很明显的看出来,结果不好,建议还是设置上 // paint.setStyle(Style.STROKE);//表示一个空心的圆 paint.setColor(Color.BLUE);//也就是设置笔的颜色 //如果是空心的话,要设置划线的粗细,也就是你笔的粗细,必须在canvas.drawRect()方法之上才可以 // paint.setStrokeWidth((float) 3.0); //这是画一个圆,第1.2参数表示圆心的位置,50表示圆的半径,最后一个也就是画图的工具,就是你的笔 // canvas.drawCircle(100, 100, 50, paint); //下面是一个绘制矩形的 // canvas.drawRect(80,20,160,500, paint);//前四个数字就是距离上下左右的距离,其余的不解释 //其实绘制矩形还有另一种方法,也就是把常见好的矩形往里面装 /* Rect rect=new Rect(80, 20,300, 500);// 绘制矩形 canvas.drawRect(rect,