83 lines
3.2 KiB
C#
83 lines
3.2 KiB
C#
|
using TimelapseApi;
|
||
|
using System;
|
||
|
using SixLabors.ImageSharp;
|
||
|
using SixLabors.ImageSharp.PixelFormats;
|
||
|
using SixLabors.ImageSharp.Processing;
|
||
|
using SixLabors.ImageSharp.Drawing;
|
||
|
using SixLabors.ImageSharp.Drawing.Processing;
|
||
|
|
||
|
namespace TestPattern
|
||
|
{
|
||
|
public class TestPattern : TimelapseExtension
|
||
|
{
|
||
|
public override string Name => "Test Pattern";
|
||
|
public override Guid Id => Guid.Parse("{d918ac89-c07a-4ce4-a94b-c3e6c6f7a7e3}"); //https://duckduckgo.com/?q=guid&t=ffab&ia=answer
|
||
|
|
||
|
|
||
|
|
||
|
protected override void OnCreate(ExtensionFeatures features)
|
||
|
{
|
||
|
|
||
|
features.RegisterFrameHandler((e)=>{
|
||
|
if(Instance == null)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
if(Instance.HasCamera)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
int colW=e.Width / 7;
|
||
|
int widthtotalBottom = (int)(colW* 3.80);
|
||
|
int colH=(int)(e.Height * 0.70);
|
||
|
int bottomY=(int)(e.Height*0.80);
|
||
|
int bottomW = widthtotalBottom/3;
|
||
|
|
||
|
Action<Color,int,IImageProcessingContext> draw=(color,i,ipc)=>{
|
||
|
ipc.FillPolygon(color,new PointF(0+(colW*i),0),new PointF(colW + (colW*i),0),new PointF(colW + (colW*i),colH),new PointF(0+(colW*i),colH),new PointF(0+(colW*i),0));
|
||
|
};
|
||
|
Action<Color,int,IImageProcessingContext> draw_middle = (color,i,ipc)=>{
|
||
|
ipc.FillPolygon(color,new PointF(0+(colW*i),colH),new PointF(colW + (colW*i),colH),new PointF(colW + (colW*i),bottomY),new PointF(0+(colW*i),bottomY),new PointF(0+(colW*i),0));
|
||
|
|
||
|
};
|
||
|
Action<Color,int,IImageProcessingContext> draw_bottom = (color,i,ipc)=>{
|
||
|
ipc.FillPolygon(color,new PointF(0+(bottomW*i),bottomY),new PointF(bottomW + (bottomW*i),bottomY),new PointF(bottomW + (bottomW*i),e.Height),new PointF(0+(bottomW*i),e.Height),new PointF(0+(bottomW*i),bottomY));
|
||
|
};
|
||
|
|
||
|
e.Mutate((e)=>{
|
||
|
var white=Color.White;
|
||
|
var yellow = Color.Yellow;
|
||
|
var aqua = Color.Aqua;
|
||
|
|
||
|
var magenta =Color.Magenta;
|
||
|
var red=Color.Red;
|
||
|
var blue = Color.Blue;
|
||
|
var black=Color.Black;
|
||
|
var navy=Color.Navy;
|
||
|
var lime=Color.Lime;
|
||
|
draw(white,0,e);
|
||
|
draw(yellow,1,e);
|
||
|
draw(aqua,2,e);
|
||
|
draw(lime,3,e);
|
||
|
draw(magenta,4,e);
|
||
|
draw(red,5,e);
|
||
|
draw(blue,6,e);
|
||
|
draw_middle(red,2,e);
|
||
|
draw_middle(blue,1,e);
|
||
|
draw_middle(magenta,3,e);
|
||
|
draw_middle(lime,4,e);
|
||
|
draw_middle(aqua,5,e);
|
||
|
draw_middle(yellow,6,e);
|
||
|
draw_bottom(navy,0,e);
|
||
|
draw_bottom(white,1,e);
|
||
|
draw_bottom(navy,2,e);
|
||
|
});
|
||
|
|
||
|
|
||
|
return true;
|
||
|
},"Test Pattern",0);
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|