Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Create Graphiz image from Dot file using DotNet

This is from http://vv.cs.byu.edu/cs312-003/archives/2005/01/graph_visualiza.html. Go there for more info.
 private void button2_Click(object sender, System.EventArgs e) {

string strCmdLine1 = "-Tsvg -o c:\\tmp\\foo.xml c:\\tmp\\ER.dot";
string strCmdLine2 = "-Tsvg -o c:\\tmp\\foo.xml c:\\tmp\\Heawood.dot";
System.Diagnostics.Process p = new System.Diagnostics.Process();

p.StartInfo.FileName = "\"C:\\Program Files\\ATT\\Graphviz\\bin\\dot.exe\"";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
if (graphIndex == 0)
p.StartInfo.Arguments = strCmdLine2;
else
p.StartInfo.Arguments = strCmdLine1;

p.Start();
p.WaitForExit();

axSVGCtl1.reload();
graphIndex = (graphIndex + 1) % 2;
}

Sine wave interference patterns

A nice visualization from Simon Wittber's recipe
from appuifw import *
import e32, random
from math import *

app.body = c = Canvas()
width, height =  c.size
freq = random.choice([25., 50., 100., 200., 400.])

for y in range(height):
    for x in range(width):
        z1 = sin(x/freq*1.7*pi)
        z2 = sin((x/3+y)/freq*1.5*pi)
        z3 = sin(y/freq*0.1*pi)

        z = abs(z1+z2+z3)*255
        c.point((x,y), (z,z/4,z*4))
c.text((5, height-12), u'Freq = %d' %freq, 0xffffff)

e32.ao_sleep(5)    # wait 5 sec then quit

See a screenshot here.
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS