Skip to content

Instantly share code, notes, and snippets.

View bradmartin333's full-sized avatar

Brad Martin bradmartin333

View GitHub Profile
For row = 1 To 8
For col = 1 To 8
Dim bmp As Bitmap = New Bitmap(1100, 1100)
For i = 100 To 1000 Step 200
For j = 100 To 1000 Step 200
If Rnd() > 0.5 Then
For k = j To j + 100 Step 10
Using g As Graphics = Graphics.FromImage(bmp)
g.FillRectangle(New SolidBrush(Color.Black), New Rectangle(i, k, 100, 5))
End Using
@bradmartin333
bradmartin333 / Colorizer.cs
Created April 9, 2021 17:05
Adaptation of geekymonkey's color RGB to HSL
using System;
using System.Drawing;
namespace Test
{
static class Colorizer
{
private static double _RainbowIDX;
public static Color GetNextRainbowColor()
let MakeIDs (ax:float, ay:float,
bx:float, by:float,
cx:float, cy:float,
apx:float, apy:float,
bpx:float, bpy:float,
cpx:float, cpy:float,
ox:float, oy:float,
device:bool, nullRegion:bool) : ID[] =
[|
for n in 0. .. cy-1. do
using System;
using System.Drawing;
using System.Threading;
using System.Runtime.InteropServices;
namespace ConsoleApp1
{
class Program
{
[DllImport("user32.dll", SetLastError = true)]
@bradmartin333
bradmartin333 / ToggleNetworkCard.cs
Created June 23, 2021 10:55
Toggle GigE Network Card
// Components.cs //
public static void Initiliaze()
{
try
{
Components.Cam = new Camera();
OpenCamera();
}
catch (Exception)
from PIL import Image, ImageFont, ImageDraw, ExifTags
import pathlib
import os
imageExtensions = ['.png', '.jpg', '.jpeg', '.tiff', '.bmp', '.gif']
basewidth = 600 # Adjust output file size
# Make output dir
if not os.path.exists('watermark'):
os.makedirs('watermark')
using System;
using System.Drawing;
using System.IO;
namespace XYZmanipulator
{
class Program
{
static void Main()
{
@bradmartin333
bradmartin333 / PiePrep.cs
Last active August 5, 2021 14:27
Generate linear scan coordinates for a circular area
using System;
using System.Collections.Generic;
using System.Drawing;
namespace PiePrep
{
class Program
{
static void Main(string[] args)
{
@bradmartin333
bradmartin333 / RotateZoomClick.cs
Created August 16, 2021 16:37
Get click pos on rotated image in PictureBox with zoom type view
public static Point ZoomMousePos(Point click)
{
PictureBox pbx = Components.Vision;
float BackgroundImageAspect = pbx.BackgroundImage.Width / (float)pbx.BackgroundImage.Height;
float controlAspect = pbx.Width / (float)pbx.Height;
PointF pos = new PointF(click.X, click.Y);
if (BackgroundImageAspect > controlAspect)
{
float ratioWidth = pbx.BackgroundImage.Width / (float)pbx.Width;
pos.X *= ratioWidth;
public static void OpenWithDefaultProgram(string path)
{
using (Process fileopener = new Process())
{
fileopener.StartInfo.FileName = "explorer";
fileopener.StartInfo.Arguments = "\"" + path + "\"";
fileopener.Start();
}
}