File tree Expand file tree Collapse file tree 4 files changed +51
-5
lines changed Expand file tree Collapse file tree 4 files changed +51
-5
lines changed Original file line number Diff line number Diff line change 1
- using System . Drawing ;
1
+ using SkiaSharp ;
2
+ using System . Drawing ;
2
3
using static Layered2D . Interop . UnsafeNativeMethods ;
3
4
4
5
namespace Layered2D
@@ -14,5 +15,15 @@ public static RawPoint ToRawPoint(this Point point)
14
15
{
15
16
return new RawPoint ( point . X , point . Y ) ;
16
17
}
18
+
19
+ public static RawSize ToRawSize ( this SKSize size )
20
+ {
21
+ return new RawSize ( ( int ) size . Width , ( int ) size . Height ) ;
22
+ }
23
+
24
+ public static RawPoint ToRawPoint ( this SKPoint point )
25
+ {
26
+ return new RawPoint ( ( int ) point . X , ( int ) point . Y ) ;
27
+ }
17
28
}
18
29
}
Original file line number Diff line number Diff line change 2
2
<package >
3
3
<metadata >
4
4
<id >Layered2D</id >
5
- <version >0.0.1 </version >
5
+ <version >0.1.0 </version >
6
6
<title >Layered2D</title >
7
7
<authors >Steal</authors >
8
8
<owners >Steal</owners >
9
- <licenseUrl >https://github.com/steai/layered2d </licenseUrl >
10
- <projectUrl >https://github.com/steai/layered2d </projectUrl >
11
- <iconUrl ></iconUrl >
9
+ <licenseUrl >https://github.com/Layered2D/Layered2D/blob/master/LICENSE </licenseUrl >
10
+ <projectUrl >https://github.com/Layered2D/Layered2D </projectUrl >
11
+ <iconUrl >https://raw.githubusercontent.com/Layered2D/Layered2D/master/Logo/512x512.png </iconUrl >
12
12
<requireLicenseAcceptance >false</requireLicenseAcceptance >
13
13
<description >Layered 2D Rendering with SkiaSharp.</description >
14
14
<releaseNotes >Simple layered rendering with SkiaSharp.</releaseNotes >
Original file line number Diff line number Diff line change 5
5
using SkiaSharp ;
6
6
7
7
using WS = Layered2D . Interop . UnsafeNativeMethods . WindowStyles ;
8
+ using System . Threading ;
9
+ using SkiaSharp . Views . Desktop ;
8
10
9
11
namespace Layered2D . Windows
10
12
{
@@ -69,6 +71,12 @@ public Size NativeSize
69
71
}
70
72
}
71
73
74
+ public new SKPoint Location
75
+ {
76
+ get { return base . Location . ToSKPoint ( ) ; }
77
+ set { base . Location = new Point ( ( int ) value . X , ( int ) value . Y ) ; }
78
+ }
79
+
72
80
private bool isLoaded = false ;
73
81
public bool IsLoaded
74
82
{
@@ -90,6 +98,20 @@ public bool HitVisible
90
98
UpdateHitVisible ( ) ;
91
99
}
92
100
}
101
+
102
+ int fixedFrame = 60 ;
103
+ public int FixedFrame
104
+ {
105
+ get
106
+ {
107
+ return fixedFrame ;
108
+ }
109
+ set
110
+ {
111
+ fixedFrame = value ;
112
+ frameAccurate = 1000d / ( value + 0.5d ) ;
113
+ }
114
+ }
93
115
#endregion
94
116
95
117
#region [ Resources ]
@@ -100,6 +122,9 @@ public bool HitVisible
100
122
LayeredContext context ;
101
123
102
124
SKSize resolution = new SKSize ( - 1 , - 1 ) ;
125
+
126
+ double frameAccurate = 1000d / 60 ;
127
+ DateTime frameTime ;
103
128
#endregion
104
129
105
130
#region [ Initializer ]
@@ -146,6 +171,8 @@ protected override void CreateHandle()
146
171
147
172
// ready
148
173
isLoaded = true ;
174
+
175
+ frameTime = DateTime . Now ;
149
176
}
150
177
151
178
#endregion
@@ -209,6 +236,14 @@ private void SetResolutionCore()
209
236
#region [ Render ]
210
237
public void Render ( )
211
238
{
239
+ if ( FixedFrame > 0 )
240
+ {
241
+ if ( frameTime > DateTime . Now )
242
+ return ;
243
+
244
+ frameTime = frameTime . Add ( TimeSpan . FromMilliseconds ( frameAccurate ) ) ;
245
+ }
246
+
212
247
context . Clear ( ) ;
213
248
214
249
OnRender ( context ) ;
You can’t perform that action at this time.
0 commit comments