Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
pls...help me in this program

Posted by michelle_miss (michelle_miss), 24 January 2005
hello everyone....can anyone help me in prorammin Tcl/Tk...?this is a new language for me to program....and iam findin it difficult to do the above program in TCL/TK...pls...help me...
michelle

PROGRAM QUESTION: Design a program capable of digitizing circles.  The system should start with a single window containing a grid of 20x20 points.All points should start out grey.  The user can then click to place the center of a circle, and then drag to set it's radius, similar to various graphics programs.  The circle should be drawn on the screen.When the user releases the mouse button, the program should highlight the points (make them blue) that correspond to the edge of the circle, in a way such that the points could be connected to reconstruct the circle.Then, two additional circles should be created corresponding to the largest and smallest radius of the highlighted points.

Posted by admin (Graham Ellis), 24 January 2005
I really don't think that I would be helping you very much if I provided anything approaching a complete answer - see http://www.wellho.net/forum/Assistance/Posting-FAQ.html, points 3 in the first section and five in the third.

As a starter, try generating and displaying a widget (have you been able to work out what type?) to give you the grey background ...

Posted by michelle_miss (michelle_miss), 25 January 2005
hello Mr.admin,
iam new to this group...anywayz....i clearly understood the posting rules...
regarding the program...
i created the grid with 20x20 points with grey color....
i generated a circle in two methods...one by giving manual points and the other by automatically dragging the point as giving the following codes......

bind .c <ButtonPress-1> {oval_create %W %x %y}
bind .c <B1-Motion> {oval_move %W %x %y}
bind .c <ButtonRelease-1> {oval_end %W %x %y}
#click
proc oval_create {win x y} {
    global oval
    set oval(x0) $x
    set oval(y0) $y
    set oval(id) [$win create oval $x $y $x $y]
}

#drag
proc oval_move {win x y} {
    global oval
$win coords $oval(id) $oval(x0) $oval(y0) $x $y
}

#drop
proc oval_end {win x y} {
    global oval
    oval_move $win $x $y
    $win itemconfigure $oval(id) -fill "" -tags circle
}


But i couldnt able to get the overlapping points...ie..coloring the grids which touches the circle indexes...and also generating a circle above and below the original circle....so i hope now u can help me in solving the problem....
thanks and regards
Michelle

Posted by admin (Graham Ellis), 25 January 2005
The code sample you've provided looks good.   I think the following stage for generating the extra circles would be to use some expr calculations based on the existing centre and circumference points, then draw the extra ovals.

By background, I'm a graphics programmer but I'm not finding it easy to understand the specification exactly - I suspect that it's been translated from another language and it may have lost something in the translation; wish I could be more help.

Oh - have you come across the -outline option which may help with the border?

Posted by michelle_miss (michelle_miss), 25 January 2005
Dear Mr.Admin,
Thanks for ur reply.....i didnt get anyother information except what i have provided to you in the above program......i have 2 mail questions...

1.how to highlight the points in the grid in blue color to which the circle edges overlapps

2.How to get the index values for circle i have created using the mouse...coz if i know this value i can jus increment and decrement this values to get two circles above and below the main circle as mention in the problem.....

Anywayz...thankz for your help...
Michelle

Posted by neo (The Architect), 26 January 2005
Just Off topic: Is it advisable to do graphics and related high processing stuff using a scripting language?

Posted by admin (Graham Ellis), 30 January 2005
Very often, if you generate graphics using built in libraries from a scripting language, it's very efficient.   The scripting language is really not doing a great deal of the work iteself and so isn't an efficiency problem; the graphics work is done by the library - usually written in C, and usually something that the library author has spent a great deal of time and expersise writing to run reliably and efficiently.   Examples of libraries that I include in this category are:
* Tk from Tcl
* The Imagexxx routines in PHP
* Qt, Wx and Tkinter in Python

However - please do NOT try to use a scripting language to generate low level graphics directly using and and or operations in the scripting language and a frame buffer set up in a scripting language variable. That would run slower than a snail!



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho