[Monkey] Tiefpassfilter für AccelX()
Übersicht Andere Programmiersprachen Codearchiv & Module
RaymondBetreff: Tiefpassfilter für AccelX() |
Do, Okt 15, 2015 17:10 Antworten mit Zitat |
|
---|---|---|
Code: [AUSKLAPPEN] Import mojo2
Class MyApp Extends App Field canvas:Canvas Field image:Image Field icanvas:Canvas Global GNormal:Image Global GTief:Image Global Filter_X:Float[11] Global Tiefpass:Int = 10 Function tFilter_X:Float(Wert_X:Float) Local Count:Int ' alle einen nach links schieben For Count = 2 To Tiefpass Filter_X[Count - 1] = Filter_X[Count] Next ' wert befüllen Filter_X[Tiefpass] = Wert_X Local Sum_X:Float ' und den Mittelwert bilden For Count = 1 To Tiefpass Sum_X = Sum_X + Filter_X[Count] Next Return Sum_X / Tiefpass End Method OnCreate() canvas = New Canvas ' ---- Grafik Normal erstellen ---- GNormal = New Image(100, 100) icanvas = New Canvas(GNormal) icanvas.Clear 1, 1, 1 icanvas.SetColor 0, 0, 1 icanvas.DrawLine 0, 100, 50, 0 icanvas.DrawLine 50, 0, 100, 100 icanvas.Flush ' ---- Grafik Tiefpassfilter erstellen ---- GTief = New Image(100, 100) icanvas = New Canvas(GTief) icanvas.Clear 1, 1, 1 icanvas.SetColor 1, 0, 0 icanvas.DrawLine 0, 100, 50, 0 icanvas.DrawLine 50, 0, 100, 100 icanvas.Flush End Method OnUpdate() End Method OnRender() Local w:Int = DeviceWidth, h:Int = DeviceHeight canvas.Clear 1, 1, 1 Local Rot:Float Local x:Int = w / 2 Rot = AccelX() * 90 canvas.DrawImage GNormal, x - 150, h / 2, Rot, 2, 2 Rot = tFilter_X(AccelX() * 90) canvas.DrawImage GTief, x + 150, h / 2, Rot, 2, 2 canvas.Flush End End Function Main() New MyApp End |
||
Übersicht Andere Programmiersprachen Codearchiv & Module
Powered by phpBB © 2001 - 2006, phpBB Group