?? pffalleffect.cs.svn-base
字號:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Aspecto.PocketFrog;
using System.Drawing;
using System.Collections;
namespace Aspecto.FlowFX
{
public class PfFallEffect : PocketFrogEffect
{
public override void Swap(FlowForm lastForm, FlowForm nextForm, bool opening)
{
base.Swap(lastForm, nextForm, opening);
int multiplier = opening ? -1 : 1;
Surface surface = TakeScreenShot(-lastForm.Bounds.Y);
Surface scaleBuffer = new Surface(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Surface surface2 = surface.Clone();
//clear the form so it looks like a blank one
Rect gr = new Rect(0, lastForm.Bounds.Y, surface2.Width, lastForm.Bounds.Y + lastForm.Height);
Rasterizer surface2R = new Rasterizer(surface2);
surface2R.FillRect(gr, PFUtility.RGB(nextForm.BackColor));
int frame = 0;
//scaleBuffer.SetClipper(0, 0, surface.Width, surface.Height);
display.GetBackBuffer();
display.SetClipping(new Rect(0, 0, display.GetWidth(), display.GetHeight()));
while (frame < surface.Height)// halfwidth )
{
display.GetBackBuffer();
if (opening)
{
display.Blit(0, 0, surface2);
FallDown(frame, scaleBuffer, surface, display);
frame += Math.Max(1, (int)(Math.Abs(frame) * 0.4));
}
else
{
display.Blit(0, 0,surface);
FallDown(surface.Height - frame, scaleBuffer, surface2, display);
frame += Math.Max(1, (int)(Math.Abs(surface.Height - frame) * 0.4));
}
display.Update();
}
surface.Dispose();
scaleBuffer.Dispose();
surface2.Dispose();
DrawStartBar();
}
private void FallDown(int frame, Surface scaleBuffer, Surface surface, Display buffer)
{
Rect rect_dest;
Rect rect_src;
System.Drawing.Point[] staticTopPath = lineSimple2(0, 0, surface.Width * 2, surface.Height);
System.Drawing.Point[] currLine = lineSimple2(staticTopPath[frame].X, staticTopPath[frame].Y, 0, surface.Height); // draws from left diagonal line going off page left to bottom left corner of screen
rect_dest = new Rect(0, 0, surface.Width, surface.Height + frame); // shrinks by 2
rect_src = new Rect(0, 0, surface.Width, surface.Height);
Rasterizer scaleBufferR = new Rasterizer(scaleBuffer);
scaleBufferR.BlitStretch( rect_dest, surface, rect_src);
for (int i = 0; i < currLine.Length - 1; i++)
{
rect_dest = new Rect(-currLine[i].X, currLine[i].Y, surface.Width + currLine[i].X, currLine[i].Y + 1);
rect_src = new Rect(0, i, surface.Width, i + 1);
buffer.BlitStretch(rect_dest, scaleBuffer, rect_src);
}
}
/// <summary>
/// this just flips the coords since there is a bug in lineSimple when dx = 0
/// </summary>
/// <param name="x0"></param>
/// <param name="y0"></param>
/// <param name="x1"></param>
/// <param name="y1"></param>
/// <returns></returns>
public System.Drawing.Point[] lineSimple2(int x0, int y0, int x1, int y1)
{
System.Drawing.Point[] p = lineSimple(y0, x0, y1, x1);
for (int i = 0; i < p.Length; i++)
{
int x = p[i].X;
p[i].X = p[i].Y;
p[i].Y = x;
}
return p;
}
public System.Drawing.Point[] lineSimple(int x0, int y0, int x1, int y1)
{
ArrayList points = new ArrayList();
int dx = x1 - x0;
int dy = y1 - y0;
points.Add(new System.Drawing.Point(x0, y0));
if (dx != 0)
{
float m = (float)dy / (float)dx;
float b = y0 - m * x0;
dx = (x1 > x0) ? 1 : -1;
while (x0 != x1)
{
x0 += dx;
y0 = (int)Math.Round(m * x0 + b);
points.Add(new System.Drawing.Point(x0, y0));
}
}
return (System.Drawing.Point[])points.ToArray(typeof(System.Drawing.Point));
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -