Using javascript for custom purposes

This shows the two-way interaction between Javascript and c#. Javascript calls a c# method C# gets the result of an expression in Javascript – Type scriptType = Type.GetTypeFromCLSID(Guid.Parse(“0E59F1D5-1FBE-11D0-8FF2-00A0D10038BC”)); dynamic obj = Activator.CreateInstance(scriptType, false); obj.Language = “javascript”; obj.AddObject(“MyClass”,new JSAccessibleClass()); obj.Eval(“MyClass.MsgBox(‘Hello World’)”); //<–1 var result = obj.Eval(“3+5”); //<–2 [ComVisible(true)] public class JSAccessibleClass { public void MsgBox(string s) … Read more

Precise subpixel line drawing algorithm (rasterization algorithm)

If you need just constant color (not interpolated by used area of pixel) then use DDA: void line_DDA_subpixel(int x0,int y0,int x1,int y1,int col) // DDA subpixel -> thick { int kx,ky,c,i,xx,yy,dx,dy; x1-=x0; kx=0; if (x1>0) kx=+1; if (x1<0) { kx=-1; x1=-x1; } x1++; y1-=y0; ky=0; if (y1>0) ky=+1; if (y1<0) { ky=-1; y1=-y1; } y1++; … Read more