本文整理汇总了C#中Android.Graphics.Canvas.ClipRect方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.ClipRect方法的具体用法?C# Canvas.ClipRect怎么用?C# Canvas.ClipRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.Canvas
的用法示例。
在下文中一共展示了Canvas.ClipRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DispatchDraw
protected override void DispatchDraw(Canvas canvas)
{
if (ShouldClip) {
canvas.ClipRect (new Rect (Left, Top, Right, Bottom + Offset));
}
base.DispatchDraw (canvas);
}
示例2: ShowPath
private void ShowPath(Canvas canvas, int x, int y, Path.FillType ft, Paint paint)
{
canvas.Save();
canvas.Translate(x, y);
canvas.ClipRect(0, 0, 120, 120);
canvas.DrawColor(Color.White);
mPath.SetFillType(ft);
canvas.DrawPath(mPath, paint);
canvas.Restore();
}
示例3: drawSelector
public void drawSelector(View content, Canvas canvas, float openPercent)
{
if (!mSelectorEnabled) return;
if (mSelectorDrawable != null && mSelectedView != null)
{
string tag = (string)mSelectedView.GetTag(Resource.Id.selected_view);
if (tag.Equals(TAG + "SelectedView"))
{
canvas.Save();
int left, right, offset;
offset = (int)(mSelectorDrawable.Width * openPercent);
if (mMode == SlidingMenuMode.LEFT)
{
right = content.Left;
left = right - offset;
canvas.ClipRect(left, 0, right, Height);
canvas.DrawBitmap(mSelectorDrawable, left, getSelectorTop(), null);
}
else if (mMode == SlidingMenuMode.RIGHT)
{
left = content.Right;
right = left + offset;
canvas.ClipRect(left, 0, right, Height);
canvas.DrawBitmap(mSelectorDrawable, right - mSelectorDrawable.Width, getSelectorTop(), null);
}
canvas.Restore();
}
}
}
示例4: DrawStickyHeader
private void DrawStickyHeader(Canvas canvas)
{
var headerHeight = GetHeaderHeight();
var top = m_HeaderBottomPosition - headerHeight;
//clip the headers drawing area
m_ClippingRect.Left = PaddingLeft;
m_ClippingRect.Right = Width - PaddingRight;
m_ClippingRect.Bottom = top + headerHeight;
m_ClippingRect.Top = m_ClippingToPadding ? PaddingTop : 0;
canvas.Save();
canvas.ClipRect(m_ClippingRect);
canvas.Translate(PaddingLeft, top);
m_Header.Draw(canvas);
canvas.Restore();
}
示例5: DispatchDraw
protected override void DispatchDraw(Canvas canvas)
{
if ((int)Build.VERSION.SdkInt < 8) //froyo
{
ScrollChanged(FirstVisiblePosition);
}
PositionSelectorRect();
if (!AreHeadersSticky || m_Header == null)
{
base.DispatchDraw(canvas);
return;
}
if (!IsDrawingListUnderStickyHeader)
{
m_ClippingRect.Set(0, m_HeaderBottomPosition, Width, Height);
canvas.Save();
canvas.ClipRect(m_ClippingRect);
}
base.DispatchDraw(canvas);
if (!IsDrawingListUnderStickyHeader)
{
canvas.Restore();
}
DrawStickyHeader(canvas);
}
示例6: DispatchDraw
protected override void DispatchDraw (Canvas canvas)
{
base.DispatchDraw (canvas);
if (mPinnedSection != null) {
// prepare variables
int pLeft = ListPaddingLeft;
int pTop = ListPaddingTop;
View view = mPinnedSection.view;
// draw child
canvas.Save();
int clipHeight = view.Height +
(mShadowDrawable == null ? 0 : Math.Min(mShadowHeight, mSectionsDistanceY));
canvas.ClipRect(pLeft, pTop, pLeft + view.Width, pTop + clipHeight);
canvas.Translate(pLeft, pTop + mTranslateY);
DrawChild(canvas, mPinnedSection.view, DrawingTime);
if (mShadowDrawable != null && mSectionsDistanceY > 0) {
mShadowDrawable.SetBounds(mPinnedSection.view.Left,
mPinnedSection.view.Bottom,
mPinnedSection.view.Right,
mPinnedSection.view.Bottom + mShadowHeight);
mShadowDrawable.Draw(canvas);
}
canvas.Restore();
}
}
示例7: Draw
public override void Draw(Canvas canvas)
{
_bounds = Bounds;
canvas.ClipRect(_bounds);
if (_reversed)
{
canvas.Translate(_bounds.Width(), 0);
canvas.Scale(-1, 1);
}
DrawStrokes(canvas);
}
示例8: 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();
}
}
示例9: OnDraw
protected override void OnDraw (Canvas canvas)
{
_rect = canvas.ClipBounds;
_rect.Inset(0, -_height / 2);
canvas.ClipRect(_rect, Region.Op.Replace);
if (!_isUserTouching) {
if (DeltaY > -_maxCurvature && DeltaY < _maxCurvature) Curvature = DeltaY * 2;
TopCellPath(OneFifthWidth, FourFifthWith, Curvature);
BottomCellPath(FourFifthWith, OneFifthWidth, _height + Curvature);
} else {
float Curvatured = _isSelectedView?-Curvature:Curvature;
TopCellPath(_fingerX,_fingerX,Curvatured);
Curvatured = _isSelectedView?_height-Curvatured:_height;
BottomCellPath(_fingerX,_fingerX,Curvatured);
}
canvas.DrawPath(_path, _paint);
}
示例10: DrawBubbles
// This drawing routine assume all columns have equal heights, don't use while animating wave
void DrawBubbles(Canvas canvas, int columnWidth)
{
const int Range = 200;
const int MinRadius = 2;
const int FadeStartLevel = 50;
var level = u1 [0];
var maxRadius = ((columnWidth >> 1) * 8) / 10;
var maxHeight = height >> 2;
canvas.Save ();
canvas.ClipRect (0, height - level, width, height);
int alphaDecrement = (int)((1 - Math.Min (FadeStartLevel, MaxWavyLevel - level) / ((float)FadeStartLevel)) * 255);
for (int i = 0; i < Count; i++) {
var dispersion = ((float)Math.Sin (i * ((4 * Math.PI) / Count)) + 1) * Range;
var ratio = ((level + dispersion) % Range) / Range;
var alpha = (int)Math.Round (255 - ratio * 200);
alpha = Math.Max (0, alpha - alphaDecrement);
bubblePaint.Color = BlendColor (BackgroundColor, BubbleColor, alpha);
var cx = i * columnWidth + columnWidth / 2;
var cy = height - level + (1 - ratio) * (maxHeight - maxRadius);
var radius = MinRadius + ratio * (maxRadius - MinRadius);
canvas.DrawCircle (cx, cy, radius, bubblePaint);
}
canvas.Restore ();
}
示例11: DrawOn
public void DrawOn(Canvas canvas, List<IFilter> filters)
{
foreach (var filter in filters) {
filter.TransformImg (this);
}
canvas.Save ();
canvas.ClipRect (BorderRect.Left, BorderRect.Top, BorderRect.Right, BorderRect.Bottom);
Matrix.SetScale (Rect.Width / (float)Bitmap.Width, Rect.Height / (float)Bitmap.Height);
Matrix.PostTranslate (Rect.Left, Rect.Top);
Matrix.PostRotate (Rect.RotationDg, Rect.Left, Rect.Top);
canvas.DrawBitmap (Bitmap, Matrix, Paint);
canvas.Restore ();
foreach (var filter in filters) {
filter.DrawOn (canvas);
}
}
示例12: DrawPict
private void DrawPict(Canvas canvas, int x, int y, int w, int h, float sx, float sy)
{
canvas.Save ();
canvas.Translate (x, y);
canvas.ClipRect (0, 0, w, h);
canvas.Scale (0.5f, 0.5f);
canvas.Scale (sx, sy, w, h);
canvas.DrawPicture (mPicture);
canvas.Restore ();
}
示例13: draw
public void draw(Canvas canvas) {
int width = mBounds.Width ();
int height = mBounds.Height();
int cx = width / 2;
int cy = height / 2;
Boolean drawTriggerWhileFinishing = false;
int restoreCount = canvas.Save();
canvas.ClipRect(mBounds);
if (mRunning || (mFinishTime > 0)) {
long now = AnimationUtils.CurrentAnimationTimeMillis();
long elapsed = (now - mStartTime) % ANIMATION_DURATION_MS;
long iterations = (now - mStartTime) / ANIMATION_DURATION_MS;
float rawProgress = (elapsed / (ANIMATION_DURATION_MS / 100f));
// If we're not running anymore, that means we're running through
// the finish animation.
if (!mRunning) {
// If the finish animation is done, don't draw anything, and
// don't repost.
if ((now - mFinishTime) >= FINISH_ANIMATION_DURATION_MS) {
mFinishTime = 0;
return;
}
// Otherwise, use a 0 opacity alpha layer to clear the animation
// from the inside out. This layer will prevent the circles from
// drawing within its bounds.
long finishElapsed = (now - mFinishTime) % FINISH_ANIMATION_DURATION_MS;
float finishProgress = (finishElapsed / (FINISH_ANIMATION_DURATION_MS / 100f));
float pct = (finishProgress / 100f);
// Radius of the circle is half of the screen.
float clearRadius = width / 2;//* INTERPOLATOR.getInterpolation(pct);
mClipRect.Set(cx - clearRadius, 0, cx + clearRadius, height);
canvas.SaveLayerAlpha(mClipRect, 0, 0);
// Only draw the trigger if there is a space in the center of
// this refreshing view that needs to be filled in by the
// trigger. If the progress view is just still animating, let it
// continue animating.
drawTriggerWhileFinishing = true;
}
// First fill in with the last color that would have finished drawing.
if (iterations == 0) {
canvas.DrawColor (Android.Graphics.Color.Blue);
} else {
if (rawProgress >= 0 && rawProgress < 25) {
canvas.DrawColor(Android.Graphics.Color.AliceBlue);
} else if (rawProgress >= 25 && rawProgress < 50) {
canvas.DrawColor (Android.Graphics.Color.Blue);
} else if (rawProgress >= 50 && rawProgress < 75) {
canvas.DrawColor (Android.Graphics.Color.BlueViolet);
} else {
canvas.DrawColor (Android.Graphics.Color.CadetBlue);
}
}
// Then draw up to 4 overlapping concentric circles of varying radii, based on how far
// along we are in the cycle.
// progress 0-50 draw mColor2
// progress 25-75 draw mColor3
// progress 50-100 draw mColor4
// progress 75 (wrap to 25) draw mColor1
if ((rawProgress >= 0 && rawProgress <= 25)) {
float pct = (((rawProgress + 25) * 2) / 100f);
drawCircle(canvas, cx, cy, mColor1, pct);
}
if (rawProgress >= 0 && rawProgress <= 50) {
float pct = ((rawProgress * 2) / 100f);
drawCircle(canvas, cx, cy, mColor2, pct);
}
if (rawProgress >= 25 && rawProgress <= 75) {
float pct = (((rawProgress - 25) * 2) / 100f);
drawCircle(canvas, cx, cy, mColor3, pct);
}
if (rawProgress >= 50 && rawProgress <= 100) {
float pct = (((rawProgress - 50) * 2) / 100f);
drawCircle(canvas, cx, cy, mColor4, pct);
}
if ((rawProgress >= 75 && rawProgress <= 100)) {
float pct = (((rawProgress - 75) * 2) / 100f);
drawCircle(canvas, cx, cy, mColor1, pct);
}
if (mTriggerPercentage > 0 && drawTriggerWhileFinishing) {
// There is some portion of trigger to draw. Restore the canvas,
// then draw the trigger. Otherwise, the trigger does not appear
// until after the bar has finished animating and appears to
// just jump in at a larger width than expected.
canvas.RestoreToCount(restoreCount);
restoreCount = canvas.Save();
canvas.ClipRect(mBounds);
drawTrigger(canvas, cx, cy);
}
// Keep running until we finish out the last cycle.
ViewCompat.PostInvalidateOnAnimation(mParent);
} else {
// Otherwise if we're in the middle of a trigger, draw that.
if (mTriggerPercentage > 0 && mTriggerPercentage <= 1.0) {
drawTrigger(canvas, cx, cy);
}
//.........这里部分代码省略.........
示例14: Draw
public override void Draw(Canvas canvas)
{
canvas.ClipRect(canvas.ClipBounds);
base.Draw(canvas);
}
示例15: DrawSelector
public void DrawSelector(View content, Canvas canvas, float openPercent)
{
if (!SelectorEnabled) return;
if (_selectorDrawable != null && SelectedView != null)
{
var tag = (string)SelectedView.GetTag(Resource.Id.selected_view);
if (tag.Equals(Tag + "SelectedView"))
{
canvas.Save();
int left, right;
var offset = (int)(SelectorBitmap.Width * openPercent);
if (Mode == MenuMode.Left)
{
right = content.Left;
left = right - offset;
canvas.ClipRect(left, 0, right, Height);
canvas.DrawBitmap(SelectorBitmap, left, SelectorTop, null);
}
else if (Mode == MenuMode.Right)
{
left = content.Right;
right = left + offset;
canvas.ClipRect(left, 0, right, Height);
canvas.DrawBitmap(SelectorBitmap, right - SelectorBitmap.Width, SelectorTop, null);
}
canvas.Restore();
}
}
}