Skip to content

First Preview #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
</PropertyGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
<ItemGroup>
<Compile Include="SimplePrimitives\BouncingBalls.cs" />
<Compile Include="SimplePrimitives\ColourGradient.cs" />
<Compile Include="SimplePrimitives\Colours.cs" />
<Compile Include="SimplePrimitives\Extensions.cs" />
<Compile Include="SimplePrimitives\InformationBar.cs" />
<Compile Include="SimplePrimitives\RandomClipping.cs" />
<Compile Include="SimplePrimitives\PagedText.cs" />
<Compile Include="SimplePrimitives\MatrixRain.cs" />
<Compile Include="PandaGif.cs" />
<Compile Include="Program.cs" />
Expand All @@ -30,18 +34,18 @@
<DependentUpon>Resource.resx</DependentUpon>
</Compile>
<Compile Include="SimplePrimitives\FontExamples.cs" />
<Compile Include="SimplePrimitives\RandomEllipses.cs" />
<Compile Include="SimplePrimitives\RandomDrawLine.cs" />
<Compile Include="SimplePrimitives\RandomRectangles.cs" />
<Compile Include="SimplePrimitives\RandomEllipsesAndClipping.cs" />
<Compile Include="SimplePrimitives\RotateImage.cs" />
<Compile Include="SimplePrimitives\SetPixels.cs" />
<Compile Include="SimplePrimitives\SliceScaling9.cs" />
<Compile Include="SimplePrimitives\StretchImage.cs" />
<Compile Include="SimplePrimitives\TileImage.cs" />
<Compile Include="Untitled.cs" />
<Compile Include="WaterFallJpg.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Resources\comicsansms16.tinyfnt" />
<None Include="Resources\courierregular10.tinyfnt" />
Expand All @@ -57,34 +61,45 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib, Version=1.5.1.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.CoreLibrary.1.5.1-preview.1\lib\mscorlib.dll</HintPath>
<Reference Include="mscorlib, Version=1.7.2.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.CoreLibrary.1.7.2-preview.7\lib\mscorlib.dll</HintPath>
<Private>True</Private>
<SpecificVersion>True</SpecificVersion>
</Reference>
<Reference Include="nanoFramework.Graphics.Wpf">
<HintPath>..\..\..\..\..\lib-nanoFramework.Graphics.Wpf\source\nanoFramework.Graphics.Wpf\bin\Debug\nanoFramework.Graphics.Wpf.dll</HintPath>
<Reference Include="nanoFramework.Graphics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>packages\nanoFramework.Graphics.1.0.0-preview.1\lib\nanoFramework.Graphics.dll</HintPath>
<Private>True</Private>
<SpecificVersion>True</SpecificVersion>
</Reference>
<Reference Include="nanoFramework.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.ResourceManager.1.0.0-preview.4\lib\nanoFramework.ResourceManager.dll</HintPath>
<HintPath>..\packages\nanoFramework.ResourceManager.1.0.0-preview.14\lib\nanoFramework.ResourceManager.dll</HintPath>
<Private>True</Private>
<SpecificVersion>True</SpecificVersion>
</Reference>
<Reference Include="nanoFramework.Runtime.Events, Version=1.4.1.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.Runtime.Events.1.4.1-preview.3\lib\nanoFramework.Runtime.Events.dll</HintPath>
<Reference Include="nanoFramework.Runtime.Events, Version=1.4.2.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.Runtime.Events.1.4.2-preview.7\lib\nanoFramework.Runtime.Events.dll</HintPath>
<Private>True</Private>
<SpecificVersion>True</SpecificVersion>
</Reference>
<Reference Include="nanoFramework.Runtime.Native, Version=1.2.0.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.Runtime.Native.1.2.0-preview.7\lib\nanoFramework.Runtime.Native.dll</HintPath>
<Reference Include="nanoFramework.Runtime.Native, Version=1.2.1.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.Runtime.Native.1.2.1-preview.1\lib\nanoFramework.Runtime.Native.dll</HintPath>
<Private>True</Private>
<SpecificVersion>True</SpecificVersion>
</Reference>
<Reference Include="nanoFramework.System.Collections, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.System.Collections.1.0.0-preview.6\lib\nanoFramework.System.Collections.dll</HintPath>
<Reference Include="nanoFramework.System.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.System.Collections.1.0.1-preview.6\lib\nanoFramework.System.Collections.dll</HintPath>
<Private>True</Private>
<SpecificVersion>True</SpecificVersion>
</Reference>
<Reference Include="System.Math, Version=1.2.0.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>packages\nanoFramework.System.Math.1.2.0-preview.16\lib\System.Math.dll</HintPath>
<Private>True</Private>
<SpecificVersion>True</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="Resources\SoccerBall.gif" />
<Content Include="Resources\waterfall_costa_rica.jpg" />
</ItemGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
<ProjectExtensions>
Expand Down
27 changes: 27 additions & 0 deletions samples/Graphics/Primitives/Primitives.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30011.22
MinimumVisualStudioVersion = 10.0.40219.1
Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "Primitives", "Primitives.nfproj", "{3CB7ECF3-F8C0-4B5C-ACFF-9950F330277C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3CB7ECF3-F8C0-4B5C-ACFF-9950F330277C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3CB7ECF3-F8C0-4B5C-ACFF-9950F330277C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CB7ECF3-F8C0-4B5C-ACFF-9950F330277C}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{3CB7ECF3-F8C0-4B5C-ACFF-9950F330277C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CB7ECF3-F8C0-4B5C-ACFF-9950F330277C}.Release|Any CPU.Build.0 = Release|Any CPU
{3CB7ECF3-F8C0-4B5C-ACFF-9950F330277C}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {26C3D99A-F38D-49F8-82D1-4B2C1CC359EA}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Threading;
using System.Threading;
using nanoFramework.UI;
using Primitives.SimplePrimitives;


namespace Primitives
{
public class Program
Expand All @@ -12,48 +12,56 @@ public static void Main()
DisplayControl dc = new DisplayControl();
int height = dc.ShorterSide;
int width = dc.LongerSide;
int bpp = dc.BitsPerPixel;
int delayBetween = 3000;
int delayBetween = 1100;
DisplayOrientation orientation = (DisplayOrientation)dc.Orientation;

Bitmap fullScreenBitmap = new Bitmap(width, height); // Use this bitmap as our output to the screen.
Bitmap fullScreenBitmap = new Bitmap(width, height); // Use this bitmap as our buffered output to the screen.
fullScreenBitmap.Clear();
fullScreenBitmap.Flush();
DisplayOrientation orientation = (DisplayOrientation)dc.Orientation;

Font DisplayFont = Resource.GetFont(Resource.FontResources.SegoeUIRegular12);

while (true)
{
SetPixels sp = new SetPixels(fullScreenBitmap, DisplayFont);
RandomDrawLine rdlt = new RandomDrawLine(fullScreenBitmap, DisplayFont);
Thread.Sleep(delayBetween);

FontExamples fe = new FontExamples(fullScreenBitmap);
RotateImage ri = new RotateImage(fullScreenBitmap, DisplayFont);
Thread.Sleep(delayBetween);

StretchImage si = new StretchImage(fullScreenBitmap, DisplayFont);
ColourGradient colourGradient = new ColourGradient(fullScreenBitmap, DisplayFont);
Thread.Sleep(delayBetween);

RandomDrawLine rdlt = new RandomDrawLine(fullScreenBitmap, DisplayFont);
Colours ColourExample = new Colours(fullScreenBitmap, DisplayFont);
Thread.Sleep(delayBetween);

TileImage ti = new TileImage(fullScreenBitmap, DisplayFont);
PagedText pt = new PagedText(fullScreenBitmap, DisplayFont);
Thread.Sleep(delayBetween);

RandomEllipses re = new RandomEllipses(fullScreenBitmap, DisplayFont);
BouncingBalls bb = new BouncingBalls(fullScreenBitmap, DisplayFont);
Thread.Sleep(delayBetween);

RandomRectangles rr = new RandomRectangles(fullScreenBitmap, DisplayFont);
TileImage ti = new TileImage(fullScreenBitmap, DisplayFont);
Thread.Sleep(delayBetween);

SliceScaling9 ss = new SliceScaling9(fullScreenBitmap, DisplayFont);
StretchImage si = new StretchImage(fullScreenBitmap, DisplayFont);
Thread.Sleep(delayBetween);

RotateImage ri = new RotateImage(fullScreenBitmap, DisplayFont);

SetPixels sp = new SetPixels(fullScreenBitmap, DisplayFont);
Thread.Sleep(delayBetween);

FontExamples fe = new FontExamples(fullScreenBitmap);
Thread.Sleep(delayBetween);

RandomRectangles rr = new RandomRectangles(fullScreenBitmap, DisplayFont);
Thread.Sleep(delayBetween);

SliceScaling9 ss = new SliceScaling9(fullScreenBitmap, DisplayFont);
Thread.Sleep(delayBetween);

RandomClipping rc = new RandomClipping(fullScreenBitmap, DisplayFont);
RandomClipping rc = new RandomClipping(fullScreenBitmap, DisplayFont);
Thread.Sleep(delayBetween);

MatrixRain mr = new MatrixRain(fullScreenBitmap, DisplayFont);
MatrixRain mr = new MatrixRain(fullScreenBitmap);
Thread.Sleep(Timeout.Infinite);
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 127 additions & 0 deletions samples/Graphics/Primitives/SimplePrimitives/BouncingBalls.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
using nanoFramework.Presentation.Media;
using nanoFramework.UI;
using System;

namespace Primitives.SimplePrimitives
{
public class BouncingBalls
{
struct Rectangle
{
public int X;
public int Y;
public int Width;
public int Height;
public Rectangle(int x, int y, int width, int height)
{
this.X = x;
this.Y = y;
this.Width = width;
this.Height = height;
}
}
struct Point { public int X; public int Y; };
private Rectangle[] BallLocation;
private Point[] BallVelocity;
private Bitmap ScreenBitmap { get; set; }

public BouncingBalls(Bitmap fullScreenBitmap, Font DisplayFont)
{
ScreenBitmap = fullScreenBitmap;
SetupBalls();

for (int iCount = 0; iCount < 180; iCount++)
{
MoveBalls();
DrawBalls();
}

}
private void SetupBalls()
{
Random rand = new Random();
const int num_balls = 12;
int vx = 0;
int vy = 0;

BallLocation = new Rectangle[num_balls];
BallVelocity = new Point[num_balls];

for (int iBall = 0; iBall < num_balls; iBall++)
{
int width = rand.Next(3, 50);
BallLocation[iBall] = new Rectangle
{
X = rand.Next(0, ScreenBitmap.Width - 2 * width),
Y = rand.Next(0, ScreenBitmap.Height - 2 * width),
Width = width,
Height = width
};
// Setup 1/2 the balls with different speeds
if (iBall % 2 == 0)
{
vx = rand.Next(2, 10);
vy = rand.Next(2, 10);
}
else
{
vx = rand.Next(12, 25);
vy = rand.Next(12, 25);
}

// Setup random directions
if (rand.Next(0, 2) == 0) vx = -vx;
if (rand.Next(0, 2) == 0) vy = -vy;
BallVelocity[iBall] = new Point { X = vx, Y = vy };
}
}

private void MoveBalls()
{
for (int ball_num = 0;
ball_num < BallLocation.Length;
ball_num++)
{
// Move the ball.
int new_x = BallLocation[ball_num].X +
BallVelocity[ball_num].X;
int new_y = BallLocation[ball_num].Y +
BallVelocity[ball_num].Y;
if (new_x < 0)
{
BallVelocity[ball_num].X = -BallVelocity[ball_num].X;
}
else if (new_x + BallLocation[ball_num].Width > ScreenBitmap.Width)
{
BallVelocity[ball_num].X = -BallVelocity[ball_num].X;
}
if (new_y < 0)
{
BallVelocity[ball_num].Y = -BallVelocity[ball_num].Y;
}
else if (new_y + BallLocation[ball_num].Height > ScreenBitmap.Height)
{
BallVelocity[ball_num].Y = -BallVelocity[ball_num].Y;
}

BallLocation[ball_num] = new Rectangle(new_x, new_y,
BallLocation[ball_num].Width,
BallLocation[ball_num].Height);
}
}


private void DrawBalls()
{
ScreenBitmap.Clear();
for (int i = 0; i < BallLocation.Length; i++)
{
ScreenBitmap.DrawEllipse(Color.Yellow, 1, BallLocation[i].X, BallLocation[i].Y, BallLocation[i].Width, BallLocation[i].Height,
0, 0, 0, 0, 0, 0, Bitmap.OpacityOpaque);
}
ScreenBitmap.Flush();
}
}
}


25 changes: 25 additions & 0 deletions samples/Graphics/Primitives/SimplePrimitives/ColourGradient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using nanoFramework.Presentation.Media;
using nanoFramework.UI;
using System;

namespace Primitives.SimplePrimitives
{
public class ColourGradient
{
public ColourGradient(Bitmap fullScreenBitmap, Font DisplayFont)
{
fullScreenBitmap.DrawRectangle(Color.White, // outline color
1, // outline thickness
100, 100, // x and y of top left corner
200, 100, // width and height
0, 0, // x and y corner radius
Color.White, // gradient start color
100, 100, // gradient start coordinates
Color.Black, // gradient end color
100 + 200, 100 + 100, // gradient end coordinates
Bitmap.OpacityOpaque); // opacity
fullScreenBitmap.Flush();

}
}
}
Loading