I've been digging lately to find a graphics programming language without bloating dependencies. I think I found one: Icon. You may never have heard of it.
See here: http://www.cs.arizona.edu/icon/index.htm
It's ancient in software/computer terms (1998). The earliest mention of it that I found dates back to 1979.
I downloaded the packages from the above website, compiled it with X11 headers and dropped the resulting directory with files into ~/bin and made a symlink.
Guess what: it works flawlessly. And it is rather easy to understand, even for me
Below some examples I made with the help of the excellent documentation in an hour or so. But there's lot more to Icon than this, like high level string handling and Turtle Graphics, so I'm venturing on with it.
I would have liked to attach the Icon compilation as well, but it's 1.7Mb zipped (9Mb unzipped).
BTW there's Unicon (http://unicon.sourceforge.net/faq.htm) which is a 'modernized dialect that descends from Icon", but I have not yet looked into it.
I thought you might be interested....
Code: Select all
#!/bin/icon
# fonts
link graphics
procedure main()
WOpen("size=600,200") | stop("Can't open window")
WAttrib("pos=50,150")
WAttrib("label=Icon Programming - Fonts Demonstration")
GotoXY(10,50)
ransom("The quick brown fox jumps over the lazy dog.")
WDone()
end
procedure ransom(s)
local c
static famlist, attlist, sizelist
initial
{
famlist:=["URW Chancery L","DejaVu Sans"]
attlist:=["","","bold","italic"]
sizelist:=[18,22,24,32,34]
}
every c:=!s do
{
Font(?famlist || "," || ?sizelist || "," || ?attlist)
WWrites(c)
}
return
end
Code: Select all
#!/bin/icon
#clipping
link graphics
procedure main()
local x,y
WOpen("size=600,400", "bg=yellow")
WAttrib("pos=300,100")
WAttrib("label=Icon Programming - Clipping")
Fg("red")
FillRectangle(50,50,400,300)
Fg("green")
FillRectangle(70,70,360,260)
Clip(71,71,359,259)
every 1 to 50 do
{
x:=?400+50
y:=?300+50
WAttrib("fg=black","linewidth=5")
DrawCircle(x,y,30)
WAttrib("fg=white","linewidth=3")
DrawCircle(x,y,30)
}
WDone()
end
Code: Select all
#!/bin/icon
# Sierpinsky
$define Width 400
$define Height 400
$define X1 0
$define Y1 Height
$define X2 (Width/2)
$define Y2 0
$define X3 Width
$define Y3 Height
link graphics
procedure main()
local x,y
WOpen("size=400,400", "bg=light green")
WAttrib("label=Icon Programming - Sierpinski Diagram")
Fg("red")
WWrite("Press 'q' to quit")
Fg("black")
x:=Width/2
y:=Height/2
until WQuit() do
{
case ?3 of
{
1: {
x:=(x+X1)/2
y:=(y+Y1)/2
}
2: {
x:=(x+X2)/2
y:=(y+Y2)/2
}
3: {
x:=(x+X3)/2
y:=(y+Y3)/2
}
}
DrawPoint(x,y)
}
end