Drawing Rectangles(绘制矩形)

C++运行时类型识别:dynamic_cast、typeid与自定义RTTI实战指南 在面向对象编程中,多态性允许基类指针指向不同的派生类对象,这是实现代码复用和扩展性的核心机制。其原理依赖于虚函数表和动态绑定,使得程序能在运行时根据对象实际类型调用正确的方法。这一技术价值在于提升了代码的抽象层次和可维护性。然而,在工程实践中,如对象序列化、调试日志、与外部系统交互等场景,开发者常需确定基类指针具体指向的子类类型,这时便需要运行时类型识别技术。C++提供了dynamic_cast和typeid两种基于RTTI的标准方案,分别用于安全向下转换和类型信息获取;在禁用RTTI或追求极致性能时,可采 阅读详情

绘制过程:

    创建路径 -CGMutablePathRef  CGPathCreateMutable (void);  //CGMutablePathRef path = CGPathCreateMutable();

    设置矩形 -CGRect CGRectMake (CGFloat x,CGFloat y,CGFloat width,CGFloat height);

    将所要绘制的图形(矩形)加入路径 

        加入单个矩形 -void  CGPathAddRect (CGMutablePathRef path,const CGAffineTransform *m,CGRect rect); //第二个参数:NULL

        加入多个矩形 -void  CGPathAddRects (CGMutablePathRef path,const CGAffineTransform *m,const CGRect rects[],size_t count);

    创建上下文环境 -CGContextRef  UIGraphicsGetCurrentContext (void); //CGContextRef currentContext = UIGraphicsGetCurrentContext();

        在环境中添加路径 -void  CGContextAddPath (CGContextRef context,CGPathRef path); 

    设置相关属性 - (void)setFill  //填充颜色

               - (void)setStroke  //边界颜色

              - void  CGContextSetLineWidth (CGContextRef c,CGFloat width); //线宽

    绘制路径 -void  CGContextDrawPath (CGContextRef c,CGPathDrawingMode mode);

    释放 -void  CGPathRelease (CGPathRef path);


- (void)drawRect:(CGRect)rect{  

    /* Create the path */

   CGMutablePathRef path = CGPathCreateMutable();

    

   CGRect rectangle = CGRectMake(10.0f,30.0f,200.0f,300.0f);

   CGPathAddRect(path, NULL,rectangle);

    

   // CGRect rectangle1 = CGRectMake(10.0f,30.0f,200.0f,300.0f);

   // CGRect rectangle2 = CGRectMake(40.0f,100.0f,90.0f,300.0f);

   // CGRect rectangles[2] = {rectangle1, rectangle2};

   // CGPathAddRects(path,NULL,(const CGRect *)&rectangles,2);


    /* Get the handle to the current context */

    CGContextRef currentContext = UIGraphicsGetCurrentContext();

    

    /* Add the path to the context */

   CGContextAddPath(currentContext, path);

    

    /* Set the fill color to cornflower blue */

    [[UIColor colorWithRed:0.20f

                     green:0.60f

                      blue:0.80f

                     alpha:1.0f]setFill];

    

    /* Set the stroke color to brown */

    [[UIColor brownColor]setStroke];

    

    /* Set the line width (for the stroke) to 5 */

   CGContextSetLineWidth(currentContext,5.0f);

    

    /* Stroke and fill the path on the context */

   CGContextDrawPath(currentContext,kCGPathFillStroke);

    

    /* Dispose of the path */

   CGPathRelease(path);

    

}



MH2457开发板实战:FreeRTOS+LVGL嵌入式GUI方案解析 嵌入式实时操作系统(RTOS)是资源受限环境下实现复杂应用的基础技术,其核心原理是通过任务调度和资源管理确保系统实时性。FreeRTOS作为开源RTOS代表,凭借其轻量级内核和可配置性,在MCU环境中广泛应用。结合LVGL图形库,开发者能够在嵌入式设备上构建流畅的图形界面,这一技术组合显著提升了人机交互体验。在工业控制、智能家居面板等场景中,嵌入式GUI方案需要平衡成本、性能和开发效率。MH2457开发板基于T113处理器,集成7寸电容触摸屏,通过FreeRTOS与LVGL的深度融合,为开发者提供了开箱即用 阅读详情

相关推荐

element的el-cascader组件动态加载,以及报错处理问题

Blocked aria-hidden on an element because its descendant retained focus. The focus must not be hidden from assistive technology users. 报错处理

weixin_56527169的博客 1264

Graphics.DrawRectangle 方法

Graphics.DrawRectangle 方法

haier123888的博客 1万+

B站李沐讲论文笔记AlexNet

B站李沐讲论文笔记AlexNet

夏知识不进脑子薇的博客 789

C#编程-132:DrawRectangle绘制矩形_彭世瑜_新浪博客

usingSystem; usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing; usingSystem.Linq; usingSystem.Text; usingSystem.Windows...

彭世瑜的博客 2562

从GWAS到单细胞:利用seismic包精准定位疾病相关的关键细胞亚群与驱动基因

本文详细介绍了如何利用seismic包将GWAS与单细胞测序数据结合,精准定位疾病相关的核心细胞亚群与驱动基因。通过创新的统计算法和实战案例,帮助研究者从遗传汇总数据中挖掘关键生物学机制,提升疾病研究的精准度和效率。

weixin_29215815的博客 441

AI安全护栏评测:TrustedExecBench如何量化评估大模型防护能力

在人工智能和机器学习领域,模型安全对齐是确保AI系统可靠、可控的核心技术。其原理是通过设计安全机制(即“护栏”)来约束模型行为,防止生成有害、偏见或越界内容。这项技术的核心价值在于平衡AI能力与风险管控,是可信AI部署的基石。应用场景广泛覆盖内容审核、对话系统、代码生成等需要人机交互的领域。本文聚焦的TrustedExecBench项目,正是针对“护栏”性能量化评估这一痛点,提供了一个标准化、自动化的开源评测框架。该工具通过构建多维度的恶意测试套件,并引入基于模型的动态评判机制,能够系统性地检验大语言模型在

weixin_42525428的博客 378

C# 在图片上标注矩形,graphics.DrawRectangle()的使用

方法在坐标 (50, 50) 处绘制了一个大小为 100x100 像素的矩形。最后,我们将结果保存到了一个名为 "rectangle.png" 的 PNG 格式图片中。是 GDI+ 绘图库中用于绘制矩形的方法。它可以在指定的位置和大小绘制一个空心的矩形。在上述代码中,我们创建了一个大小为 200x200 像素的位图对象,并从中获取了一个。类创建一个颜色为红色、线条宽度为 2 像素的画笔对象,并利用。表示用于绘制矩形边框的画笔对象;以下是一个简单的示例代码,演示了。分别表示矩形的宽度和高度。

qq_35320456的博客 2408

2026.3.13:docker compose运行了Milvus 6个月,占用磁盘近138GB的原因

Docker容器运行Milvus半年后占用138GB磁盘空间,主要原因是容器日志无限增长、容器内写入大量数据未挂载到数据卷,以及未清理临时文件。通过检查发现超大容器目录569035582ce3...占用主要空间。解决方案是使用truncate命令清空容器日志文件(*-json.log),释放磁盘空间。建议配置日志轮转机制,并将数据挂载到宿主机数据卷以避免类似问题。

拥抱具身智能,昇腾Ascend C 194

【halcon】draw_rectangle1

准备,做一个halcon函数讲解的系列文章,每篇讲解一个halcon函数。我根据自己的理解,结合实际的例子来分析,争取分析一个就懂一个。本人也是小白,过程中,也会对文章进行增删改查。聚沙成塔,集腋成裘,希望各位看官多多支持!

songhuangong123的博客 5307

Android 15.0 app进程保活白名单功能实现

在15.0的系统rom产品开发中,在某些重要的app即使进入后台,产品需求要求也不想被系统杀掉进程,需要app长时间保活,就是app进程保活白名单功能的实现, 所以需要在系统杀进程的时候不杀掉白名单的进程,接下来就看怎么样来实现这些功能

安卓兼职framework和app工程师的博客 639

FFmpeg 开发(14):Android FFmpeg + MediaCodec 实现视频硬解码

MediaCodec 是 Android 提供的用于对音视频进行编解码的类,它通过访问底层的 codec 来实现编解码的功能,是 Android media 基础框架的一部分,通常和 MediaExtractor, MediaSync, MediaMuxer, MediaCrypto, MediaDrm, Image, Surface和AudioTrack 一起使用。

字节流动 3万+

opencv学习笔记3:画线,画圆,方框,椭圆,文字

opencv学习笔记3:画线,画圆,方框,椭圆,文字 opencv学习笔记3:画线,画圆,方框,椭圆,文字 目标 参数解释 Drawing Line 画线 Drawing Rectangle 画矩形 Drawing Circle 画圆 Drawing Ellipse 画椭圆 Drawing Polygon 画多边形 图片上添加文字 画图结果显示 Additional Re...

博客 1569

VTK GPU 加速渲染技术

/ 创建颜色工具// 创建立方体数据// 创建OpenGL映射器(注意使用vtkOpenGLPolyDataMapper而不是常规的vtkPolyDataMapper)// 启用VBO(顶点缓冲对象)// 声明几何体是静态的以获得最佳性能// 创建actor// 创建渲染器、渲染窗口和交互器renderWindow->SetWindowName("VTK自定义着色器示例");// 添加actor到渲染器。

深之JohnChen的专栏 1242

java 绘制长方形_Java基础之在窗口中绘图——绘制直线和矩形(Sketcher 2 drawing lines and rectangles)...

控制台程序。import javax.swing.JComponent;import java.util.*;import java.awt.*;import java.awt.geom.*;@SuppressWarnings("serial")public class SketcherView extends JComponent implements Observer {public Sket...

weixin_39637363的博客 562

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Java基础之在窗口中绘图——绘制直线和矩形(Sketcher 2 drawing lines and rectangles)...

控制台程序。 1 import javax.swing.JComponent; 2 import java.util.*; 3 import java.awt.*; 4 import java.awt.geom.*; 5 6 @SuppressWarnings("serial") 7 public class SketcherView extends JCompo...

weixin_30244681的博客 228

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

[Javascript] Drawing Paths - Lines and Rectangles

<!DOCTYPE html> <html> <head> <meta name="description" content="HTML5 Canvas Graphics and Animation Video 1" /> <meta charset="utf-8"> <title>HTM...

weixin_30618985的博客 52

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

Rectangles hdu2461容斥定理

Rectangles Time Limit: 5000/4000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1259Accepted Submission(s): 661 Problem Description You are developing a softw...

weixin_34220623的博客 128

Rectangles - POJ 3695 容斥原理

Rectangles Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 3672   Accepted: 1052 Description You are developing a software for painting rectangles on the s

提比的强行AC 537

hdu2461 Rectangles-----容斥

Rectangles Time Limit: 5000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 989    Accepted Submission(s): 558 Problem Description You are developing a

Shirley 1107

checkErrorStatus parameter is not valid

arg_graphics.FillRectangles(arrBrush[i], arrRCs[i].ToArray());                         arg_graphics.FillRectangles(arrBrush[i], arrLines[i].ToArray()); 在调用Graphics函数 FillRectangles 时, 不定期会有异常 :

norsd的专栏 3316

PyGame游戏开发入门:从零构建弹跳方块与接球游戏

游戏开发是编程学习的重要实践领域,其核心在于理解游戏循环、事件处理和状态管理。游戏循环作为程序的“心脏”,通过持续的事件轮询、状态更新和画面渲染,将静态代码转化为动态交互体验。在Python生态中,PyGame作为基于SDL库的经典模块,为初学者提供了理解底层逻辑、亲手实现游戏功能的绝佳起点。它封装了跨平台的多媒体处理功能,让开发者能专注于游戏逻辑本身,如碰撞检测和精灵管理。通过构建弹跳方块和接球游戏等小项目,开发者可以掌握图像绘制、精灵系统、声音处理等关键技术,为后续学习更专业的游戏引擎打下坚实基础。

weixin_33875564的博客 421

PyQt5 5.15 float坐标兼容性问题与labelImg修复指南

在PyQt5中,坐标系统是GUI开发的基础概念,其底层原理直接影响绘图精度与程序稳定性。自5.15版本起,QRect、QPoint等几何类全面转向float坐标机制,以支持高DPI渲染和亚像素精度,但这一变更打破了大量依赖整数坐标的传统应用契约。技术价值体现在更精准的图形表达与跨平台缩放一致性,典型应用场景包括图像标注工具(如labelImg)、CAD前端、工业视觉界面等。当整数截断逻辑(如int())遭遇float坐标微小误差时,会引发矩形漂移、渲染抖动乃至Segmentation fault闪退——尤其

蓝色妖姬 340

C# 图形的绘制矩形椭圆

1.矩形框的绘制 绘制矩形框是用GDI+技术的DrawRectangle方法来实现的,它有3种语法,其语法格式如下: public void DrawRectangle (Pen pen, int x, int y, int width, int height) public void DrawRectangle (Pen pen, float x, float y,

菜鸟的博客 1万+

在图像中画矩形框(matlab)

在图像中画矩形框(matlab)

席小贱 3万+

画多个矩形c语言,C# winform开发:Graphics、pictureBox同时画多个矩形

C#的System.Drawing命名空间提供了对 GDI+ 基本图形功能的访问重点在于获取Graphics对象,例如:Graphicsg =panel1.CreateGraphics事实上CreateGraphics继承自Control, 即基本每一种控件都有这个方法Control.CreateGraphics在pannel、form上画图都一样,这里以pictureBox为例。DrawR...

weixin_33510225的博客 4157

C#中GDI+图形图像绘制(直线、矩形、圆、椭圆、圆弧、扇形、多边形)

例如,三角形是有3条边的多边形,矩形是有4条边的多边形,五边形是有5条边的多边形。调用Graphics类中的DrawLine()方法,结合Pen对象可以绘制直线。画圆就是在正方形的空间里画内接的椭圆,所以还是使用Graphics类中的DrawEllipse()方法。Graphics类中的DrawPolygon()方法用于绘制由一组Point结构定义的多边形。从x轴到弧线的起始点沿顺时针方向度量的角(以度为单位)边框的左上角的x坐标,该边框定义扇形所属的椭圆。边框的左上角的y坐标,该边框定义扇形所属的椭圆。

wenchm的博客 7287
上一篇: Constructing Paths(构建路径)
下一篇: Adding Shadows to Shapes(添加阴影)
berained
博客等级 码龄20年 14粉丝 15原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值