久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

為什么給 addArcWithCenter 一個 0 度的 startAngle 使它

Why does giving addArcWithCenter a startAngle of 0 degrees make it start at 90 degrees?(為什么給 addArcWithCenter 一個 0 度的 startAngle 使它從 90 度開始?)
本文介紹了為什么給 addArcWithCenter 一個 0 度的 startAngle 使它從 90 度開始?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在創建一個 CAShapeLayer 以用作 UIView 層的掩碼.我正在使用 UIBezierPath 來繪制形狀圖層.它工作得很好,除了我在畫畫時得到了一些奇怪的結果.幾何圖形未按預期運行.我正在嘗試在右上角繪制簡單的餅圖":

I'm creating a CAShapeLayer to use as a mask for a UIView's layer. I'm using a UIBezierPath to draw the shape layer. It's working fine, except I'm getting some odd results when I draw. The geometry is not behaving as expected. I'm trying to draw simple "pie slice" in the upper right corner:

#define degreesToRadians(x) ((x) * M_PI / 180.0)

...

// "layer" refer's to the UIView's root layer

CAShapeLayer *maskLayer = [CAShapeLayer layer];

maskLayer.frame =
    layer.presentationLayer ? 
    ((CAGradientLayer *)layer.presentationLayer).bounds : layer.bounds;
maskLayer.fillRule = kCAFillRuleEvenOdd;
maskLayer.needsDisplayOnBoundsChange = YES;

CGFloat maskLayerWidth = maskLayer.bounds.size.width;
CGFloat maskLayerHeight = maskLayer.bounds.size.height;
CGPoint maskLayerCenter = 
    CGPointMake(maskLayerWidth/2,maskLayerHeight/2);

UIBezierPath *path = [UIBezierPath bezierPath];

[path moveToPoint:maskLayerCenter];

[path addArcWithCenter:maskLayerCenter radius:(maskLayerWidth/2)
startAngle:degreesToRadians(0) endAngle:degreesToRadians(90) clockwise:YES];

[path closePath];


maskLayer.path = path.CGPath;

layer.mask = maskLayer;

最終的結果是在右下角繪制了一個餅圖.圓弧的第一個點在 90 度處繪制,然后下降到 180 度.為什么即使我使用的是 0 度角和 90 度角,它也會這樣做?

The end result is that a pie slice is drawn in the lower right corner. The first point of the arc is drawn at the 90 degrees, then down to 180. Why does it do this even though I'm using 0 and 90 degree angles?

推薦答案

此圖片直接來自 文檔.

還有一個關于它是如何工作的討論(給定默認坐標系)

And there is a discussion of how it works (given the default coordinate system)

討論
此方法添加從當前點開始的指定弧.創建的圓弧位于指定圓的周長上.在默認坐標系中繪制時,起點和終點角度以圖1中所示的單位圓為基準.例如,指定起始角為 0 弧度,結束角為 π 弧度,并將順時針參數設置為 YES 繪制圓的下半部分.但是,指定相同的開始和結束角度但將 順時針 參數設置為 NO 會繪制圓的上半部分.

Discussion
This method adds the specified arc beginning at the current point. The created arc lies on the perimeter of the specified circle. When drawn in the default coordinate system, the start and end angles are based on the unit circle shown in Figure 1. For example, specifying a start angle of 0 radians, an end angle of π radians, and setting the clockwise parameter to YES draws the bottom half of the circle. However, specifying the same start and end angles but setting the clockwise parameter set to NO draws the top half of the circle.

這就是 addArcWithCenter:radius:startAngle:endAngle:順時針: 的角度工作原理.如果這不是您所看到的,那么您計算的角度不正確.

This is how the angles work for addArcWithCenter:radius:startAngle:endAngle:clockwise:. If that isn't what you are seeing then you are calculating your angles incorrectly.

這篇關于為什么給 addArcWithCenter 一個 0 度的 startAngle 使它從 90 度開始?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to have a circular, center-cropped imageView, without creating a new bitmap?(如何在不創建新位圖的情況下擁有圓形、中心裁剪的 imageView?)
How to draw stars using Quartz Core?(如何使用 Quartz Core 繪制星星?)
Android Catch Notes App Like Circle Menu(Android Catch Notes 應用程序,如圓形菜單)
No such acos function exists(不存在這樣的 acos 函數)
Find the CGPoint on a UIView rectangle intersected by a straight line at a given angle from the center point(在與中心點成給定角度的直線相交的 UIView 矩形上找到 CGPoint)
Draw circle of certain radius on map view in Android(在Android的地圖視圖上繪制一定半徑的圓)
主站蜘蛛池模板: 日韩av成人 | 亚洲精品免费观看 | 日韩一二三区视频 | 久精品久久| 国产97在线视频 | 精品福利在线 | 激情一区二区三区 | 日韩在线h | www.国产精品 | 午夜看看| 久久久999成人 | 国产精品1区2区3区 中文字幕一区二区三区四区 | 国产一在线观看 | 欧美在线日韩 | 欧美色专区 | 精品国产一区二区三区久久影院 | 在线看免费 | 成人在线观看免费视频 | 日韩精品av一区二区三区 | www.午夜| 亚洲高清成人在线 | 亚洲欧洲国产视频 | 久久激情视频 | 一区二区三区视频 | 一区二区在线观看av | 伊人二区| 成年免费大片黄在线观看一级 | 国产日韩欧美综合 | 午夜视频网 | 国产精品欧美一区二区三区不卡 | 国产精品久久久久一区二区三区 | 美女视频. | h片在线免费看 | 亚洲人成人一区二区在线观看 | 超碰97免费在线 | 欧美不卡一区二区 | 免费的av网站 | 欧美一级在线免费 | 综合久久一区 | 玖玖国产 | 一级黄色片网站 |