久久久久久久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 度開始?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

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

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;

最終的結(jié)果是在右下角繪制了一個餅圖.圓弧的第一個點在 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?

推薦答案

此圖片直接來自 文檔.

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

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

討論
此方法添加從當(dāng)前點開始的指定弧.創(chuàng)建的圓弧位于指定圓的周長上.在默認坐標(biāo)系中繪制時,起點和終點角度以圖1中所示的單位圓為基準(zhǔn).例如,指定起始角為 0 弧度,結(jié)束角為 π 弧度,并將順時針參數(shù)設(shè)置為 YES 繪制圓的下半部分.但是,指定相同的開始和結(jié)束角度但將 順時針 參數(shù)設(shè)置為 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.

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

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

相關(guān)文檔推薦

How to have a circular, center-cropped imageView, without creating a new bitmap?(如何在不創(chuàng)建新位圖的情況下?lián)碛袌A形、中心裁剪的 imageView?)
How to draw stars using Quartz Core?(如何使用 Quartz Core 繪制星星?)
Android Catch Notes App Like Circle Menu(Android Catch Notes 應(yīng)用程序,如圓形菜單)
No such acos function exists(不存在這樣的 acos 函數(shù))
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的地圖視圖上繪制一定半徑的圓)
主站蜘蛛池模板: 国产美女在线观看 | 久久精品一级 | 91视频网| 欧美精品在线播放 | 精精国产xxxx视频在线播放 | 可以在线看的黄色网址 | 久久中文字幕一区 | 91精品久久久久久久久中文字幕 | www.青青草| 亚洲欧美成人 | 久久小视频 | 天天草天天干天天 | 国产亚洲成av人在线观看导航 | 成人福利网 | 天天射美女 | 国产欧美久久精品 | 亚洲精品国产第一综合99久久 | 久久一久久 | 欧美日本亚洲 | 国精产品一区一区三区免费完 | 久久激情网 | 国产免费av在线 | 亚洲一区二区三区视频免费观看 | 久久69精品久久久久久久电影好 | 欧美激情一区二区三区 | 91福利网 | 久久国产婷婷国产香蕉 | 国产精品久久久久久久久久久久 | 欧美精品成人一区二区三区四区 | 欧美日韩国产在线观看 | 99精品久久久久久 | 日本在线一区二区 | 久久久999成人| 国产精品久久久久久久久久久久久 | 成人在线播放网站 | 999久久久久久久久6666 | 日韩精品一区中文字幕 | 黄色视频a级毛片 | 久久综合狠狠综合久久 | 国产精品久久av | 国产综合精品一区二区三区 |