Processing is a wonderful environment for those who like to experiment
with design and graphics and sound
It has been created by artists for artists.
float posx = 250;
float posy = 250;
int numstars = 36;
Star[] p = new Star[numstars];
class Star {
float x;
float y;
Star(float _x, float _y) {
x = _x;
y = _y;
}
void moveTo(float _x,float _y){
x = _x;
y=_y;
for (float i=0; i<360 ;i+=4){
stroke(random(255)+245,random(255)+245,random(12)+245,random(30));
line(x,y,random(40)*cos(i)+x,random(40)*sin(i)+y);
}
}
}
void setup(){
size(800,800);
smooth();
noStroke();
for (int i=0; i<numstars; i++){
p[i] = new Star(100,100);
}
}
void draw(){
background(0,0,30);
for (int i=0; i<numstars; i++){
posx = random(width);
posy=random(height);
p[i].moveTo(posx,posy);
}
}
Thursday, May 29, 2008
Wednesday, April 2, 2008
HTA-Python : BarGraph
<html>
<head>
<style type='text/css'>
body
{
color : #fff;
}
</style>
<script language="Python">
def getDiv(div):
return document.getElementById(div)
def graphBar(data=[],largeur=10,hauteur=400,bgcolor="#00FFFF"):
table = "<table><tr>"
maxdata = max(data,key=lambda liste : liste[1])[1]
coeffmul = 1.0*hauteur/maxdata
for item in data:
haut = item[1]*coeffmul
stl = """style=background-color:%s;padding:4px;font-weight:bold;height:%spx;"""%(bgcolor,haut)
col = """<td valign='bottom' width='%s'><div %s>%s</div></td>"""%(largeur,stl,item[0])
table += col
table += "</tr></table>"
return table
def test():
graphdiv = getDiv('graph')
data = [('11',32),('12',16),
('13',8),('14',78),
('21',15),('22',45),
('23',65),('24',34),
('31',55),('32',34),
('33',67),('34',45),
('41',15),('42',45),
('43',65),('44',34)]
g = graphBar(data,bgcolor='#FF5700',largeur=0,hauteur=200)
graphdiv.innerHTML = "<div style='border:2px solid #797979;width:1px;'>%s</div>"%g
def init():
test()
</script>
</head>
<body onload='init()'>
<center>
<div id='graph'></div>
</center>
</body>
</html>
Thursday, March 27, 2008
Simple Tree : Python
I needed a simple example on using list in Python for
a Python tutorial :
This sample shows a way to diplay a hierachical list
a Python tutorial :
This sample shows a way to diplay a hierachical list
tree=["Serveurs",
["Dakar",
["System",
"Banque",
"Reseaux",
['R1',
'R2']],
"Dublin",
"Denver",
"Douala",
["Queue"]]]
hidedNodes = []
def displayTree(tree,n=0):
ident = " "
nextitem = None
for item in tree:
if not isinstance(item,list):
try:
nextitem = tree[tree.index(item)+1]
except:
pass
if isinstance(nextitem, list):
print n*ident+"+" + item
if item in hidedNodes:
if nextitem[0] != 'x':
nextitem.insert(0,'x')
else:
try:
nextitem.remove('x')
except:
pass
else:
print n*ident+" "+ item
else:
if not nextitem[0] == 'x':
n = n + 1
displayTree(nextitem,n)
n = n -1
def hideNode(node):
hidedNodes.append(node)
def showNode(node):
hidedNodes.remove(node)
def test():
print "TEST 1 : Display all"
displayTree(tree)
print ""
print "TEST 2 : Hiding Douala,Dakar"
map(hideNode,['Dakar','Douala'])
displayTree(tree)
print ""
print "TEST 3 : Showing Dakar"
showNode('Dakar')
displayTree(tree)
print ""
print "TEST 4: Hide Reseaux"
hideNode('Reseaux')
displayTree(tree)
if __name__ == "__main__":
test()
Tuesday, March 11, 2008
Writing an ActiveX control in C#
Imran Nathani's article explains how to create and embed an ActiveX control in a html page.
http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx
http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx
Blogged with the Flock Browser
Sunday, March 9, 2008
Développer une console MMC 3.0 avec .NET
Cet article montre la façon de développer une mmc en C#
http://vincentlaine.developpez.com/tuto/dotnet/mmc/
http://vincentlaine.developpez.com/tuto/dotnet/mmc/
Tuesday, March 4, 2008
Learning F# - List Concatenation
My first attempt with lists in F# :-)
let lofl = [[1;2];[3;4];[5;6]]
let rec concat ll =
match ll with
| [] -> []
| h :: t -> h @ concat t
printf "%A" (concat lofl)
read_line()
let lofl = [[1;2];[3;4];[5;6]]
let rec concat ll =
match ll with
| [] -> []
| h :: t -> h @ concat t
printf "%A" (concat lofl)
read_line()
Sunday, March 2, 2008
Embed Win32 resources in C# programs
This article explains all ...
http://www.codeproject.com/KB/cs/embedwin32resources.aspx
http://www.codeproject.com/KB/cs/embedwin32resources.aspx
Subscribe to:
Posts (Atom)