Skip to content

Instantly share code, notes, and snippets.

@VisualMelon
VisualMelon / testing.cs
Last active September 20, 2017 17:05
SVG Text Rendering Testing
var model = new PlotModel { Title = "SVG Text Rendering" };
model.Axes.Add(new LinearAxis { Position = AxisPosition.Left });
model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom });
model.Annotations.Add(new OxyPlot.Annotations.TextAnnotation()
{
    Text = "A",
    TextPosition = new DataPoint(10, 80),
    TextVerticalAlignment = VerticalAlignment.Bottom,
});
var model = new PlotModel { Title = "PNG Rendering" };
model.Axes.Add(new LinearAxis { Position = AxisPosition.Left });
model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom });
model.Series.Add(new FunctionSeries(x => x * x, 0, 1, 1000));
// export as PNG
var pngExporter = new OxyPlot.WindowsForms.PngExporter();
using (var fs = System.IO.File.Open("test.png", System.IO.FileMode.Create))
public static Rectangle GetBrightestRectangle(this Bitmap bitmap, int width, int height)
{
// Each rectangle's value is its average pixel color.
var rectangles = new Dictionary<Rectangle, float>();
// Iterate through all possible rectangle points.
for (var x = 0; x < bitmap.Width - width; x++)
for (var y = 0; y < bitmap.Height - height; y++)
{
var brightnesses = new List<float>();
// this would be a shape/concept/whatever, not an interfae
interface ICommutativeOrdinalThing<T>
{
/// <summary>
/// Commutative addition of things
/// </summary>
T Add(T a, T b); // with proposal, might pick up +
/// <summary>
/// Comparision of the strictly orderable things
using System;
using System.Text;
using System.Threading.Tasks;
using System.Net.Sockets;
namespace NetTest
{
    class Program
    {
        static void Main(string[] args)
@VisualMelon
VisualMelon / NoTransition_snip.cs
Created August 27, 2022 09:33
Avalonia immediate transition
public class NoTransition : IPageTransition
{
public Task Start(Visual from, Visual to, bool forward, CancellationToken cancellationToken)
{
if (from is not null)
{
from.IsVisible = false;
}
if (to is not null)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NAudio" Version="1.10.0" />