本文整理汇总了C#中Android.Graphics.Canvas.DrawLine方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.DrawLine方法的具体用法?C# Canvas.DrawLine怎么用?C# Canvas.DrawLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.Canvas
的用法示例。
在下文中一共展示了Canvas.DrawLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: draw
public void draw(Canvas canvas) {
pathA.getPointOnLine(parameter, coordsA);
pathB.getPointOnLine(parameter, coordsB);
if (rounded) insetPointsForRoundCaps();
canvas.DrawLine(coordsA[0], coordsA[1], coordsB[0], coordsB[1], linePaint);
}
示例2: DispatchDraw
protected override void DispatchDraw(Canvas canvas)
{
base.DispatchDraw(canvas);
var row = (ViewGroup) GetChildAt(1);
int top = row.Top;
int bottom = Bottom;
//Left side border.
int left = row.GetChildAt(0).Left + Left;
canvas.DrawLine(left + _floatFudge, top, left + _floatFudge, bottom, _dividerPaint);
//Each cell's right-side border.
for (int c = 0; c < 7; c++) {
float x = left + row.GetChildAt(c).Right - _floatFudge;
canvas.DrawLine(x, top, x, bottom, _dividerPaint);
}
}
示例3: Draw
internal void Draw(Canvas canvas)
{
canvas.DrawCircle(_cells.Last().X, _cells.Last().Y, 3, this);
for (int p = _cells.Count - 1; p > 0; p--)
{
canvas.DrawLine(_cells[p].X, _cells[p].Y, _cells[p - 1].X, _cells[p - 1].Y, this);
}
}
示例4: CreateBitmap
public static Bitmap CreateBitmap()
{
var bitmap = Bitmap.CreateBitmap(200, 200, Bitmap.Config.Argb4444);
var canvas = new Canvas(bitmap);
canvas.DrawLine(0, 0, 100, 100, new Paint { Color = new Color(255, 0, 0) });
return bitmap;
}
示例5: OnDrawOver
public override void OnDrawOver(Canvas cValue, RecyclerView parent, RecyclerView.State state)
{
var childCount = parent.ChildCount;
for (int i = 0; i < childCount; i++) {
var child = parent.GetChildAt (i);
if (child.Visibility != Android.Views.ViewStates.Visible)
continue;
var left = child.Left;
var right = child.Right;
var top = child.Top + child.PaddingTop + child.TranslationY;
var bottom = child.Bottom;
cValue.DrawLine (left + .5f, top, left + .5f, bottom, lightPaint);
cValue.DrawLine (right - .5f, top, right - .5f, bottom, darkPaint);
}
}
示例6: DrawChild
protected override bool DrawChild(Canvas canvas, Android.Views.View child, long drawingTime)
{
bool isInvalidated = base.DrawChild(canvas, child, drawingTime);
//Draw a bottom border
int bottom = child.Bottom - 1;
canvas.DrawLine(child.Left, bottom, child.Right - 2, bottom, _dividerPaint);
return isInvalidated;
}
示例7: parse
public static void parse(SVGProperties pSVGProperties, Canvas pCanvas, SVGPaint pSVGPaint) {
float x1 = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_X1, 0f);
float x2 = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_X2, 0f);
float y1 = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_Y1, 0f);
float y2 = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_Y2, 0f);
if (pSVGPaint.setStroke(pSVGProperties)) {
pSVGPaint.ensureComputedBoundsInclude(x1, y1);
pSVGPaint.ensureComputedBoundsInclude(x2, y2);
pCanvas.DrawLine(x1, y1, x2, y2, pSVGPaint.getPaint());
}
}
示例8: OnDraw
protected override void OnDraw (Canvas canvas)
{
int count = LineCount;
for (int i = 0; i < count; i++) {
int baseline = GetLineBounds (i, rect);
canvas.DrawLine (rect.Left, baseline + 1, rect.Right, baseline + 1, paint);
}
base.OnDraw (canvas);
}
示例9: Draw
public override void Draw(Canvas canvas)
{
Rect rectangle = new Rect();
GetDrawingRect(rectangle);
Paint paint = new Paint();
paint.AntiAlias = true;
paint.Color = Color.Gray;
paint.SetStyle(Paint.Style.Stroke);
canvas.DrawLine(rectangle.Left, rectangle.Bottom - 2, rectangle.Right, rectangle.Bottom, paint);
paint.Dispose();
base.Draw(canvas);
}
示例10: OnDraw
protected override void OnDraw(Canvas canvas)
{
int height = Height;
int tabCount = ChildCount;
int dividerHeightPx = (int)(Math.Min(Math.Max(0f, mDividerHeight), 1f) * height);
SlidingTabScrollView1.TabColorizer tabColorizer = mCustomTabColorizer != null ? mCustomTabColorizer : mDefaultTabColorizer;
//Thick colored underline below the current selection
if (tabCount > 0)
{
View selectedTitle = GetChildAt(mSelectedPosition);
int left = selectedTitle.Left;
int right = selectedTitle.Right;
int color = tabColorizer.GetIndicatorColor(mSelectedPosition);
if (mSelectionOffset > 0f && mSelectedPosition < (tabCount - 1))
{
int nextColor = tabColorizer.GetIndicatorColor(mSelectedPosition + 1);
if (color != nextColor)
{
color = blendColor(nextColor, color, mSelectionOffset);
}
View nextTitle = GetChildAt(mSelectedPosition + 1);
left = (int)(mSelectionOffset * nextTitle.Left + (1.0f - mSelectionOffset) * left);
right = (int)(mSelectionOffset * nextTitle.Right + (1.0f - mSelectionOffset) * right);
}
mSelectedIndicatorPaint.Color = GetColorFromInteger(color);
canvas.DrawRect(left, height - mSelectedIndicatorThickness, right, height, mSelectedIndicatorPaint);
//Creat vertical dividers between tabs
int separatorTop = (height - dividerHeightPx) / 2;
for (int i = 0; i < ChildCount; i++)
{
View child = GetChildAt(i);
mDividerPaint.Color = GetColorFromInteger(tabColorizer.GetDividerColor(i));
canvas.DrawLine(child.Right, separatorTop, child.Right, separatorTop + dividerHeightPx, mDividerPaint);
}
canvas.DrawRect(0, height - mBottomBorderThickness, Width, height, mBottomBorderPaint);
}
}
示例11: OnDraw
protected override void OnDraw(Canvas canvas)
{
int height = Height;
int tabCount = ChildCount;
int dividerHeightPx = (int)(Math.Min(Math.Max(0f, mDividerHeight), 1f) * height); // wielkosc robaczka w pixelach
SlidingTabScrollView.TabColorizer tabColorizer = mCustomTabColorizer != null ? mCustomTabColorizer : mDefaultTabColorizer; //sprawdza kolor jesli nie jest ustalony z gory zmienia sie na podstawowy
// zmiana koloru pod aktualnym "oknem"
if (tabCount > 0) {
View selectedTitle = GetChildAt(mSelectedPosition);
int left = selectedTitle.Left;
int right = selectedTitle.Right;
int color = tabColorizer.GetIndicatorColor(mSelectedPosition);
if (mSelectionOffset > 0f && mSelectedPosition < (tabCount - 1)) //sprawdza pozycje jesli jestesmy na ostatniej zak³adce nie pojdzie nigdzie dalej
{
int nextColor = tabColorizer.GetIndicatorColor(mSelectedPosition + 1);
if (color!=nextColor)
{
color = blendColor(nextColor, color, mSelectionOffset);
}
View nextTitle = GetChildAt(mSelectedPosition + 1);
left = (int)(mSelectionOffset * nextTitle.Left + (1.0f - mSelectionOffset) * left);
right = (int)(mSelectionOffset * nextTitle.Right + (1.0f - mSelectionOffset) * right); // miejsca przeciec zak³adek przez robaczka
}
mSelectedIndicatorPaint.Color = GetColorFromIntiger(color);
canvas.DrawRect(left, height - mSelectedIndicatorThickness, right, height, mSelectedIndicatorPaint);
//create vertical dividers between tabs
int separatorTop = (height - dividerHeightPx) / 2;
for (int i = 0; i < ChildCount; i++)
{
View child = GetChildAt(i);
mDividerPaint.Color = GetColorFromIntiger(tabColorizer.GetDividerColor(i));
canvas.DrawLine(child.Right, separatorTop, child.Right, separatorTop + dividerHeightPx, mDividerPaint);
}
canvas.DrawRect(0, height - mBottomBorderThickness, Width, height, mBottomBorderPaint);
}
}
示例12: OnDraw
//Actual Draw of analogue niddle in Canvas which will show in watch surface
public override void OnDraw(Canvas canvas, Rect bounds)
{
time.SetToNow ();
int width = bounds.Width ();
int height = bounds.Height ();
// Draw the background, scaled to fit.
if (backgroundScaledBitmap == null
|| backgroundScaledBitmap.Width != width
|| backgroundScaledBitmap.Height != height) {
backgroundScaledBitmap = Bitmap.CreateScaledBitmap (backgroundBitmap,
width, height, true /* filter */);
}
canvas.DrawColor (Color.Black);
canvas.DrawBitmap (backgroundScaledBitmap, 0, 0, null);
float centerX = width / 2.0f;
float centerY = height / 2.0f;
// Draw the ticks.
float innerTickRadius = centerX - 10;
float outerTickRadius = centerX;
for (int tickIndex = 0; tickIndex < 12; tickIndex++) {
float tickRot = (float)(tickIndex * Math.PI * 2 / 12);
float innerX = (float)Math.Sin (tickRot) * innerTickRadius;
float innerY = (float)-Math.Cos (tickRot) * innerTickRadius;
float outerX = (float)Math.Sin (tickRot) * outerTickRadius;
float outerY = (float)-Math.Cos (tickRot) * outerTickRadius;
canvas.DrawLine (centerX + innerX, centerY + innerY,
centerX + outerX, centerY + outerY, tickPaint);
}
float secRot = time.Second / 30f * (float)Math.PI;
int minutes = time.Minute;
float minRot = minutes / 30f * (float)Math.PI;
float hrRot = ((time.Hour + (minutes / 60f)) / 6f) * (float)Math.PI;
float secLength = centerX - 20;
float minLength = centerX - 40;
float hrLength = centerX - 80;
if (!IsInAmbientMode) {
float secX = (float)Math.Sin (secRot) * secLength;
float secY = (float)-Math.Cos (secRot) * secLength;
canvas.DrawLine (centerX, centerY, centerX + secX, centerY + secY, secondPaint);
}
float minX = (float)Math.Sin (minRot) * minLength;
float minY = (float)-Math.Cos (minRot) * minLength;
canvas.DrawLine (centerX, centerY, centerX + minX, centerY + minY, minutePaint);
float hrX = (float)Math.Sin (hrRot) * hrLength;
float hrY = (float)-Math.Cos (hrRot) * hrLength;
canvas.DrawLine (centerX, centerY, centerX + hrX, centerY + hrY, hourPaint);
}
示例13: OnDraw
protected override void OnDraw(Canvas canvas)
{
base.OnDraw(canvas);
if(null == _viewPager) return;
var count = _viewPager.Adapter.Count;
if(count == 0) return;
if(_currentPage >= count)
{
CurrentItem = count - 1;
return;
}
var lineWidthAndGap = LineWidth + GapWidth;
var indicatorWidth = (count * lineWidthAndGap) - GapWidth;
var verticalOffset = PaddingTop + ((Height - PaddingTop - PaddingBottom) / 2.0f);
float horizontalOffset = PaddingLeft;
if(_centered)
horizontalOffset += ((Width - PaddingLeft - PaddingRight) / 2.0f) - (indicatorWidth / 2.0f);
//Draw stroked circles
for(var i = 0; i < count; i++)
{
var dx1 = horizontalOffset + (i * lineWidthAndGap);
var dx2 = dx1 + LineWidth;
canvas.DrawLine(dx1, verticalOffset, dx2, verticalOffset, (i == _currentPage) ? _paintSelected : _paintUnSelected);
}
}
示例14: OnDraw
public override void OnDraw(Canvas canvas, Rect bounds)
{
if (Log.IsLoggable (Tag, LogPriority.Debug)) {
Log.Debug (Tag, "onDraw");
}
long now = Java.Lang.JavaSystem.CurrentTimeMillis ();
time.Set (now);
int milliseconds = (int)(now % 1000);
int width = bounds.Width ();
int height = bounds.Height ();
// Draw the background, scaled to fit.
if (backgroundScaledBitmap == null
|| backgroundScaledBitmap.Width != width
|| backgroundScaledBitmap.Height != height) {
backgroundScaledBitmap = Bitmap.CreateScaledBitmap (backgroundBitmap,
width, height, true /* filter */);
}
canvas.DrawColor (Color.Black);
canvas.DrawBitmap (backgroundScaledBitmap, 0, 0, null);
float centerX = width / 2.0f;
float centerY = height / 2.0f;
// Draw the ticks.
float innerTickRadius = centerX - 10;
float outerTickRadius = centerX;
for (int tickIndex = 0; tickIndex < 12; tickIndex++) {
float tickRot = (float)(tickIndex * Math.PI * 2 / 12);
float innerX = (float)Math.Sin (tickRot) * innerTickRadius;
float innerY = (float)-Math.Cos (tickRot) * innerTickRadius;
float outerX = (float)Math.Sin (tickRot) * outerTickRadius;
float outerY = (float)-Math.Cos (tickRot) * outerTickRadius;
canvas.DrawLine (centerX + innerX, centerY + innerY,
centerX + outerX, centerY + outerY, tickPaint);
}
float seconds = time.Second + milliseconds / 1000f;
float secRot = seconds / 30f * (float)Math.PI;
int minutes = time.Minute;
float minRot = minutes / 30f * (float)Math.PI;
float hrRot = ((time.Hour + (minutes / 60f)) / 6f) * (float)Math.PI;
float secLength = centerX - 20;
float minLength = centerX - 40;
float hrLength = centerX - 80;
if (!IsInAmbientMode) {
float secX = (float)Math.Sin (secRot) * secLength;
float secY = (float)-Math.Cos (secRot) * secLength;
canvas.DrawLine (centerX, centerY, centerX + secX, centerY + secY, secondPaint);
}
float minX = (float)Math.Sin (minRot) * minLength;
float minY = (float)-Math.Cos (minRot) * minLength;
canvas.DrawLine (centerX, centerY, centerX + minX, centerY + minY, minutePaint);
float hrX = (float)Math.Sin (hrRot) * hrLength;
float hrY = (float)-Math.Cos (hrRot) * hrLength;
canvas.DrawLine (centerX, centerY, centerX + hrX, centerY + hrY, hourPaint);
if (IsVisible && !IsInAmbientMode) {
Invalidate ();
}
}
示例15: OnDraw
protected override void OnDraw(Canvas canvas)
{
base.OnDraw(canvas);
if (Border == false)
{
return;
}
float width = this.Width - (paint.StrokeWidth);
float height = this.Height - (paint.StrokeWidth);
canvas.DrawLine(0, 0, width, 0, paint);
canvas.DrawLine(width, 0, width, height, paint);
canvas.DrawLine(0, height, width, height, paint);
canvas.DrawLine(0, 0, 0, height, paint);
}