CGGeometry -CGGeometry.h

Geometry.h的一些方法 这些是在CGGeometry.h里的 CGPoint、CGSize、CGRect、CGRectEdge实际上都是结构体 struct CGPoint {   CGFloat x;   CGFloat y; }; typedef struct CGPoint CGPoint;  struct CGSize {   CGFloat width;   CGFloat h 阅读详情

CGGeometry

CGGeometry.h


变换
  1. CGRectOffset 返回一个原点在原矩形上进行了偏移的矩形.
     CGRect CGRectOffset(
     CGRect rect,
     CGFloat dx,
     CGFloat dy
     )
  2. CGRectInset 返回一个与原矩形共中心的,或大些或小些的新矩形
     CGRect CGRectInset(
     CGRect rect,
     CGFloat dx,
     CGFloat dy
     )
    矩形将围绕它的中心点进行缩放,左右分别增减dx(总共2 x dx),上下分别增减 dy(总共 2 x dy)。
  3. CGRectIntegral 返回包围源矩形的最小整数矩形。
     CGRect CGRectIntegral(
     CGRect rect
     )
    CGRectIntegral 将表示原点的值向下取整,表示大小的值向上取整,这样就保证了你的绘制代码平整地对齐到像素边界。
取值辅助函数
  1. CGRectGet[Min|Mid|Max][X|Y]

    • CGRectGetMinX
    • CGRectGetMinY
    • CGRectGetMidX
    • CGRectGetMidY
    • CGRectGetMaxX
    • CGRectGetMaxY
      返回矩形x或y的最小、中间或最大值
      用这些函数代替诸如frame.origin.x + frame.size.width之类的代码将更加清晰、语义上更为生动的(特别是用取中间和取最大函数)。
  2. CGRectGet[Width|Height] 返回矩形的高度

  3. CGRectGetWidth: 返回矩形的宽度
常量
CGRectZero, CGRectNull,和 CGRectInfinite
  • const CGRect CGRectZero: 一个原点在(0, 0),且长宽均为 0 的常数矩形。这个零矩形与 CGRectMake(0.0f, 0.0f, 0.0f, 0.0f) 是等价的。
  • const CGRect CGRectNull: 空矩形。这个会在,比如说,求两个不相交的矩形的相交部分时返回。注意,空矩形不是零矩形。
  • const CGRect CGRectInfinite: 无穷大矩形。
    CGRectZero 可能是所有这些特殊矩形中最有用的了。当初始化一个视图时,它们的边框通常设置为CGRectZero,把布局放到 -layoutSubviews中。
CGRectDivide
void CGRectDivide(
  CGRect rect,
  CGRect *slice,
  CGRect *remainder,
  CGFloat amount,
  CGRectEdge edge
)
CGRectDivide 用以下方式将矩形分割为两部分:
  • 传入一个矩形并选择一条edge(上,下,左,右)
  • 平行那个边在矩形里量出amount的长度
  • 从edge 到量出的amount区域都保存到slice 参数中
  • 剩余的部分保存到remainder 参数中
其中 edge 参数是一个CGRectEdge 枚举类型:
enum CGRectEdge {
   CGRectMinXEdge,
   CGRectMinYEdge,
   CGRectMaxXEdge,
   CGRectMaxYEdge
}

CGRectDivide is perfect for dividing up available space among several views (call it on subsequent remainder amounts to accommodate more than two views). Give it a try next time you're manually laying-out a UITableViewCell.



1,NSDivideRect(NSRect inRect, NSRect *slice, NSRect *rem, CGFloat amount, NSRectEdge edge); 的意思是把按amount把inRect分成两块。直接看代码结果

    NSRect aRect = [sender frame];

    NSRect popUpRect, textRect;

    NSDivideRect(aRect, &popUpRect, &textRect, 30, NSMinXEdge);

    NSString *popUpRectString = NSStringFromRect(popUpRect);

    NSString *textRectString = NSStringFromRect(textRect);

    NSString *aRectString = NSStringFromRect(aRect);

    NSLog(@"popUpRectString -> %@", popUpRectString);popUpRectString -> {{207, 25}, {30, 32}}

    NSLog(@"textRectString -> %@", textRectString);textRectString -> {{237, 25}, {52, 32}}

    NSLog(@"aRectString -> %@", aRectString); aRectString -> {{207, 25}, {82, 32}}


2,NSRect NSInsetRect(NSRect aRect, CGFloat dX, CGFloat dY);

    aRect = [sender frame];

    NSRect bRect = NSInsetRect(aRect, 10, 10);

    NSString *bRectString = NSStringFromRect(bRect);

    NSLog(@"bRectString -> %@", bRectString);bRectString -> {{217, 35}, {62, 12}}

hGeometry:HGeometry 立即下载

相关推荐

GD32F303定时器配置:实现两路互补PWM输出与相位控制

本文详细解析了基于GD32F303定时器实现两路互补PWM输出与精确相位控制的方法。通过配置TIMER2的中间对齐模式,结合REMAP功能解决引脚复用问题,从硬件层面稳定生成相位差180度的互补PWM信号,适用于电机驱动、开关电源等对时序要求苛刻的应用场景。

weixin_29182481的博客 304

Error:The document “xxx” could not be saved. You don’t have permission. - iOS

在项目中新增了一些业务处理后再次编译工程启动,频繁弹出如下异常提示内容: The document “CGGeometry.h” could not be saved. You don’t have permission. 解决办法 首先,打开 Xcode 的设置 Preferences,找到 Locations 菜单下的 Derived Data 处; 其次,点击下面的地址指向的箭...

survivorsfyh的博客 9650

交叉熵损失函数基本概念及公式

对于二分类问题,模型的输出通常是一个标量,表示样本属于正类的概率。因此,在二分类的交叉熵损失函数中,我们只需要考虑一个概率值,即模型预测为正类的概率。具体来说,当真实标签为1时,我们关注模型预测为正类的概率;当真实标签为0时,我们关注模型预测为负类的概率。因此,二分类的交叉熵损失函数可以表示为:其中,y 表示真实标签,取值为 0 或 1;p 表示模型预测为正类的概率。而对于多分类问题,模型的输出通常是一个向量,表示样本属于各个类别的概率。因此,在多分类的交叉熵损失函数中,我们需要考虑所有类别的概率。

qlkaicx的博客 1万+

Xcode报错:The document “string.h” could not be saved. You don’t have permission.

1.进入perferences->locations,删掉DerivedData这个文件夹 . 2.强制关掉Xcode。 快捷键:command+option+shift+esc 或者打开应用程序->实用工具-> 活动监视器,选中Xcode,并强制退出。

qq_38253054的博客 6406

CANoe LIN一致性测试之干扰测试Test moudle_LIN Disturbance Block

注意:相邻两个显隐性不同的bit不允许干扰,例如我同时选择bit6和bit7,相邻两个同显隐性的bit允许干扰,例如当我选择bit3和bit4,项,这里我选择ID:为0x2F(PID:0x6F)的frame。需按照具体测试规范实施干扰项,帧头和数据段都可以实现干扰。最近发现一个干扰测试模块,下面是一些具体使用方法。选择干扰项:PID的奇偶校验位(一致性测试干扰测试之手动测试。一个待测试frameD。

yuanyikangkang的博客 3410

避坑指南:海康MV_CC_SetIntValue接口的7个典型报错解决方案

本文深度解析海康工业相机SDK中MV_CC_SetIntValue接口的典型报错,提供7个实战解决方案。针对MV_E_CALLORDER、MV_E_PARAMETER等高频错误码,从设备状态、参数值域、依赖关系等核心约束入手,给出清晰的诊断流程与根治代码,帮助开发者构建健壮的参数设置模块,提升开发效率。

y2z3a4b5c的博客 1078

Error:The document “xxx” could not be saved. You don’t have permission. - iOS/Mac

在开发IOS/Mac的时候,有时候会遇到“Error:The document “xxx” could not be saved. You don’t have permission.” 主要的原因是我们在修改代码的时候不小心修改了属于系统的源码(大部分情况下是没有修改权限)。 正确的做法,找到对应的文件,有个小tip,随便一个文件中,import指定出错的那个头文件,点进去,还原到最初的状态即可。 ...

mingming12m的专栏 2038

【AI智能体】Codex 插件从使用到项目开发实战操作详解

Codex 插件从使用到项目开发实战操作详解

congge 7636

douglas peucker递归分治

vs2015 c++11 standard or later 1. geometry.h #ifndef GEOMERTY_H_ #define GEOMETRY_H_ #include union Point { struct { float x, y; }; float compo[2]; }; typedef std::deque PointList; #e

qq_34581491的博客 592

swl安装无法与服务器建立链接,如何解决?

🏆本文收录于《全栈Bug调优(实战版)》专栏,主要记录项目实战过程中所遇到的Bug或因后果及提供真实有效的解决方案,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家关注&&收藏&&订阅!持续更新中,up!up!up!! 备注:部分问题/疑难杂症搜集于互联网。

**My Coding Family** 2075

反应动力学仿真软件:CHEMKIN_(12).CHEMKIN与其他软件的接口

通过上述介绍,我们详细探讨了如何将 CHEMKIN 与 MATLAB、Python、COMSOL、Aspen Plus 和 Ansys Fluent 等软件工具进行接口配置和数据交互。这些接口不仅能够显著提升 CHEMKIN 在反应动力学仿真中的应用效果,还能充分利用其他软件工具的强大功能,实现更复杂的数据处理和分析。希望这些内容对您在化学反应动力学仿真中的工作有所帮助。

kkchenjj的博客 1138

CGGeometry.h详解

这些是在CGGeometry.h里的 CGPoint、CGSize、CGRect、CGRectEdge实际上都是结构体 struct CGPoint {   CGFloat x;   CGFloat y; }; typedef struct CGPoint CGPoint;  struct CGSize {   CGFloat

承影 5330

银河麒麟操作系统最佳实践专栏介绍

本专栏聚焦国产银河麒麟操作系统(桌面版/服务器版)的实战应用,提供系统安装、配置优化、应用部署、故障排查等实用指南。内容基于真实操作场景,涵盖Linux通用技术(如RAID配置、环境变量管理)、服务器系统专项(如数据库迁移、驱动安装、安全加固)及桌面系统技巧(如PXE安装、镜像封装)。面向IT运维、开发者和国产化转型人员,突出实战性和差异化,帮助用户规避常见问题,提升系统管理效率。所有教程均配有详细步骤和截图,确保可操作性,并持续更新适配新版系统。

信创运维工程师 · 银河麒麟 & 容器实战 | 金融生产环境迁移·等保加固 | 142篇原创·17万+阅读 532

IOS开发几何类方法 CGGeometry.h文件

CGGeometry.h文件是用C语言实现的一个封装了许多常用几何方法的文件。 一、几个常用结构体 structCGPoint { CGFloatx; CGFloaty; }; 定义一个点,设置x坐标和y坐标 structCGSize { CGFloatwidth; CGFloatheight; }; 定义一个尺寸,设置宽度和高度 stru...

weixin_30624825的博客 112

深度学习工具包 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")

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

CGGeometry.h

/* Points. */ struct CGPoint { CGFloat x; CGFloat y; }; typedef struct CGPoint CGPoint; /* Sizes. */ struct CGSize { CGFloat width; CGFloat height; }; typedef struct CGSize CGSize; /* Rect

leonpengweicn的专栏 1315

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

OC-CoreGraphics - CGGeometry.h详解

/* CoreGraphics - CGGeometry.h    Copyright (c) 1998-2011 Apple Inc.    All rights reserved. */ #ifndef CGGEOMETRY_H_ #define CGGEOMETRY_H_ #include #include #include #include #includ

juyufeng_HuaZhu的博客 934

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

CGGeometry.h(转)

这些是在CGGeometry.h里的 CGPoint、CGSize、CGRect、CGRectEdge实际上都是结构体 struct CGPoint { CGFloat x; CGFloat y; }; typedef struct CGPoint CGPoint; struct CGSize { CGFloat width; CGFloat ...

weixin_30912051的博客 88

IOS(CGGeometry)几何类方法总结

摘要 CGGeometry.h文件中封装了一些常用的几何方法。 IOS Object-c 几何方法 CGRect 目录[-] IOS开发几何类方法总结 一、几个常用结构体 二、几个系统定义的量 三、一些常用方法 IOS开发几何类方法总结 CGGeometry.h文件是用C语言实现的一个封装了许多常用几何方法的文件。 一、几个常用

Flying_in_the_world的专栏 352

iOS-CoreGraphics(CGGeometry.h--解读)

IOS开发几何类方法总结 CGGeometry.h文件是用C语言实现的一个封装了许多常用几何方法的文件。 一、几个常用结构体 struct CGPoint {   CGFloat x;   CGFloat y; }; 定义一个点,设置x坐标和y坐标 struct CGSize {   CGFloat width;   CGFloat he

。 588

CGGeometry

IOS开发几何类方法总结CGGeometry.h文件是用C语言实现的一个封装了许多常用几何方法的文件。 一、几个常用结构体struct CGPoint {CGFloat x;CGFloat y;};定义一个点,设置x坐标和y坐标struct CGSize {CGFloat width;CGFloat height;};定义一个尺寸,设置宽度和高度struct CGVector {CGFloat d

KevinQueen的专栏 458
上一篇: OBject-C捕获异常,常用的异常处理方法
下一篇: CAlayer层的属性
zdpyly21
博客等级 码龄12年 2粉丝 5原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值