本文整理汇总了C#中Android.Graphics.Canvas.Concat方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.Concat方法的具体用法?C# Canvas.Concat怎么用?C# Canvas.Concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.Canvas
的用法示例。
在下文中一共展示了Canvas.Concat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DispatchDraw
protected override void DispatchDraw(Canvas canvas)
{
if (!_isFoldPrepared || FloatNearlyEqual(_foldFactor, 0))
{
base.DispatchDraw(canvas);
return;
}
if (!_shouldDraw)
return;
for (var x = 0; x < _numberOfFolds; x++)
{
var src = _foldRectArray[x];
canvas.Save();
canvas.Concat(_matrix[x]);
if (Build.VERSION.SdkInt == BuildVersionCodes.JellyBeanMr2)
{
_dstRect.Set(0, 0, src.Width(), src.Height());
canvas.DrawBitmap(_fullBitmap, src, _dstRect, null);
}
else
{
canvas.ClipRect(0, 0, src.Right - src.Left, src.Bottom - src.Top);
if (_isHorizontal)
canvas.Translate(-src.Left, 0);
else
canvas.Translate(0, -src.Top);
base.DispatchDraw(canvas);
if (_isHorizontal)
canvas.Translate(src.Left, 0);
else
canvas.Translate(0, src.Top);
}
canvas.DrawRect(0, 0, _foldDrawWidth, _foldDrawHeight, x % 2 == 0 ? _solidShadow : _gradientShadow);
canvas.Restore();
}
}
示例2: DispatchDraw
protected override void DispatchDraw(Canvas canvas)
{
// do zoom
zoom = Lerp(Bias(zoom, smoothZoom, 0.05f), smoothZoom, 0.2f);
smoothZoomX = Clamp(0.5f * Width / smoothZoom, smoothZoomX, Width - 0.5f * Width / smoothZoom);
smoothZoomY = Clamp(0.5f * Height / smoothZoom, smoothZoomY, Height - 0.5f * Height / smoothZoom);
zoomX = Lerp(Bias(zoomX, smoothZoomX, 0.1f), smoothZoomX, 0.35f);
zoomY = Lerp(Bias(zoomY, smoothZoomY, 0.1f), smoothZoomY, 0.35f);
if (zoom != smoothZoom && listener != null)
{
listener.onZooming(zoom, zoomX, zoomY);
}
bool animating = Math.Abs(zoom - smoothZoom) > 0.0000001f
|| Math.Abs(zoomX - smoothZoomX) > 0.0000001f || Math.Abs(zoomY - smoothZoomY) > 0.0000001f;
// nothing to draw
if (ChildCount == 0)
{
return;
}
// prepare matrix
matrix.SetTranslate(0.5f * Width, 0.5f * Height);
matrix.PreScale(zoom, zoom);
matrix.PreTranslate(-Clamp(0.5f * Width / zoom, zoomX, Width - 0.5f * Width / zoom),
-Clamp(0.5f * Height / zoom, zoomY, Height - 0.5f * Height / zoom));
// get view
View v = GetChildAt(0);
matrix.PreTranslate(v.Left, v.Top);
// get drawing cache if available
if (animating && ch == null)
{
v.SetLayerType(LayerType.Hardware, paint);
v.DrawingCacheEnabled = true;
ch = v.DrawingCache;
}
// draw using cache while animating
if (animating && ch != null && !ch.IsRecycled)
{
paint.Color = new Color(unchecked((int)0xffffffff));
canvas.DrawBitmap(ch, matrix, paint);
}
else
{ // zoomed or cache unavailable
ch = null;
canvas.Save();
canvas.Concat(matrix);
v.Draw(canvas);
canvas.Restore();
}
// draw minimap
if (ShowMiniMap)
{
if (Map.Height < 0)
{
Map.Height = Height / 4;
}
canvas.Translate(10.0f, 10.0f);
paint.Color = new Color((int)(0x80000000 | 0x00ffffff & Map.Color));
float w = Map.Height * (float)Width / Height;
float h = Map.Height;
canvas.DrawRect(0.0f, 0.0f, w, h, paint);
if (!string.IsNullOrEmpty(Map.Caption))
{
paint.TextSize = Map.CaptionSize;
paint.Color = Map.CaptionColor;
paint.AntiAlias = true;
canvas.DrawText(Map.Caption, 10.0f, 10.0f + Map.CaptionSize, paint);
paint.AntiAlias = false;
}
paint.Color = new Color((int)(0x80000000 | 0x00ffffff & Map.CaptionColor));
float dx = w * zoomX / Width;
float dy = h * zoomY / Height;
canvas.DrawRect(dx - 0.5f * w / zoom, dy - 0.5f * h / zoom, dx + 0.5f * w / zoom, dy + 0.5f * h / zoom, paint);
canvas.Translate(-10.0f, -10.0f);
}
// redraw
if (animating)
{
RootView.Invalidate();
Invalidate();
}
}