Skip to content
Open
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
6 changes: 6 additions & 0 deletions FosterSamples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Froggymark", "Froggymark\Fr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FosterImGui", "ImGui\FosterImGui.csproj", "{ED95B28D-2822-4F3D-B1C5-591658BB2380}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageScaling", "ImageScaling\ImageScaling.csproj", "{D657285F-BF95-4A8E-9637-4FEA829FB008}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -36,5 +38,9 @@ Global
{AA3B2D39-7BF3-4CCD-8F19-672474E71D41}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AA3B2D39-7BF3-4CCD-8F19-672474E71D41}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA3B2D39-7BF3-4CCD-8F19-672474E71D41}.Release|Any CPU.Build.0 = Release|Any CPU
{D657285F-BF95-4A8E-9637-4FEA829FB008}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D657285F-BF95-4A8E-9637-4FEA829FB008}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D657285F-BF95-4A8E-9637-4FEA829FB008}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D657285F-BF95-4A8E-9637-4FEA829FB008}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Binary file added ImageScaling/Assets/FosterLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions ImageScaling/ImageScaling.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FosterFramework" Version="0.1.11-alpha" />
</ItemGroup>

<ItemGroup>
<None Update="Assets\FosterLogo.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
23 changes: 23 additions & 0 deletions ImageScaling/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Numerics;
using Foster.Framework;

App.Register<Game>();
App.Run("Image Scaling", 960, 540);

class Game : Module
{
readonly Texture Logo = new(new Image(Path.Join("Assets", "FosterLogo.png")));
readonly Batcher Batcher = new();

static RectInt Viewport => new(0, 0, App.WidthInPixels, App.HeightInPixels);
static int Scale => Calc.Min(App.WidthInPixels / App.Width, App.HeightInPixels / App.Height);

public override void Render()
{
Graphics.Clear(0xdeb813);

Batcher.Clear();
Batcher.Image(Logo, Viewport.Center, Logo.Size / 2, Vector2.One * Scale, 0, Color.White);
Batcher.Render();
}
}
4 changes: 4 additions & 0 deletions ImageScaling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Image Scaling
![Screenshot](screenshot.png "Screenshot")

A minimal example of using Foster with simple asset loading and rendering.
Binary file added ImageScaling/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Samples Projects and Demos for the C# [Foster Framework](https://github.com/Fost

| Sample | Description | Preview |
| --- | --- | --- |
| [Image Scaling](https://github.com/FosterFramework/Samples/tree/main/ImageScaling) | A minimal example of using Foster with simple asset loading and rendering. | <img width="200" src="ImageScaling/screenshot.png"> |
| [Shapes](https://github.com/FosterFramework/Samples/tree/main/Shapes) | A small program that draws shapes to the screen without loading any assets | <img width="200" src="Shapes/screenshot.png"> |
| [Froggymark](https://github.com/FosterFramework/Samples/tree/main/Froggymark) | Performance test that draws as many quads to the screen as it can | <img width="200" src="Froggymark/screenshot.png"> |
| [ImGui](https://github.com/FosterFramework/Samples/tree/main/ImGui) | An example using ImGui.NET wrapped in Foster draw calls | <img width="200" src="ImGui/screenshot.png"> |
Expand Down