GroupDIY
General Discussions => The Lab => Topic started by: fum on October 01, 2004, 08:34:35 PM
-
Hey there. I'm workin on a decent way to print out scales ( other than buying a full scale graphics app like Corel Draw)
I've got the shell of an application created that will save stuff out to a jpg file.
I need help with the formulas to calculate the positions in an x y coordinate system for the scale values, for a given radius, based on degree. If you can give me a rough formula, I can take it from there
For example:
Given radius of 30 , if you wanted a scale in 30 degree increments, I need to calculate x y coordinates where to place the graphic objects, given that the center of the scale will be 0,0.
Once I get this part going, I'll add on the other features to make it cool, and put it up for people to download.
Any help out there? I'm googling at present, but thought I'd ask =)
Regards
ju
-
Don't save to jpeg - that's my advice. jpeg is not a format for graphics - it's for photos.
Saving stuff in PostScript is VERY easy - you can even calculate the scales etc. in the PS code. PostScript can be imported in a lot of drawing apps, you can open it in Photoshop and you can convert is to PDF format without loosing any quality.
I can help you with PostScript programming (I could also help with jpeg stuff, but I don't like that idea :wink:).
Best regards,
Mikkel C. Simonsen
-
postscript should be fine, or perhaps a vector graphics format.
Regards
ju
-
postscript should be fine, or perhaps a vector graphics format.
PostScript is a vector graphics format - as well as a programming language :cool:
But do explain your idea a bit more detailed - what do you want to do?
I would probably make something web-based. Use a form to input values, and then spit out EPS, PDF or PNG files.
Best regards,
Mikkel C. Simonsen
-
the idea is to write a java application(will work on any platform this way) with screen divided into two panels. One to vary the parameters of the scale, and a display on the other side to show you realtime what your getting. Variable radius, degrees, editable scale values, etc.
Once you've got your scale the way you like, save it to the file format of choice, from there you can import it to your application of choice.
One good option would be HPGL, for those who use Front panel express.
I've been using Photoshop, so any format it supports gets me there.
ju
-
Darn I used to be able to convert Polar to x,y in my sleep.
:sad:
I'm thinkin tangent and unit circle.
wrong again!
X= R*cos(Theta)
Y= R*sin(Theta)
r is radius
-
I just played around a bit...
This bit of code:
/Xpos 100 def
/Ypos 100 def
/outrad 40 def
/inrad 25 def
/steps 9 def
/stepsize 300 steps div def
/deg 300 stepsize 2 div sub def
/Tegn
{
/deg deg stepsize add def
Xpos Ypos moveto
Xpos Ypos outrad deg deg arc
stroke
} def
steps {Tegn} repeat
1 setgray Xpos Ypos inrad 0 360 arc fill
showpage
Produces this scale:
(http://stiftsbogtrykkeriet.dk/~mcs/Scale.gif)
No hard math needed :green:
Best regards,
Mikkel C. Simonsen
-
ya gotta think like a computer for that one. looks stack based. =)
we'll see what I come up with once I get the chillins sleepin
=)
ju
-
Okay,
I've got something, it's gonna take me a few days to make it cool, but I've got the rough drawing mechanism worked out to so that I can print the scales on the screen.
After spending a couple hours or so working on this, I've decided that using PostScript is cheating, as it really was designed to do this kinda thing :grin: Good developers cheat :thumb:
I'm ending up using radians in some of my calculations, and I honestly didn't know what a radian was when I started.
Stay tuned
ju
-
I think it´s a great idea to make this tool. It´s definetly needed...
-
Compare your printed results with what you are after.
I have done hours of graphics only to have them mis-scaled by the printer.
That way you catch it before commiting your expesive Lazzertran or whatever medium you use.
:evil:
-
I hear ya. I always print tests to paper, and hold it up to the light with the panel behind to make sure it looks spiffy. :grin:
I'm doing panels for a pair of SSL clones at present, and I've got the words all lined up, but I want *****in scales around my knobs ( now don't be talkin about the scales around my knobs :shock: )
ju
-
okay, here's the first output as jpg ( sorry mcs, already had this part figured)
Nothin fancy, but.....
(http://shinybox.com/diy/scale.jpg)
-
I have done hours of graphics only to have them mis-scaled by the printer.
Which is why PostScript is great - the calculations are done BY the printer, so nothing gets "distorted"...
Best regards,
Mikkel C. Simonsen
-
ya gotta think like a computer for that one. looks stack based. =)
Yes, PostScript is a great mind-exercise language :wink:
How does your code work? Do you calculate the start and end coordinates for the lines? If so writing that in PS or HPGL format shouldn't be too difficult. But adding text would be much easier in PS than in HPGL...
Best regards,
Mikkel C. Simonsen
-
I would probably make something web-based. Use a form to input values, and then spit out EPS, PDF or PNG files.
I had to see how difficult it would be do make a CGI version. It wasn't difficult at all - it took half an hour... Here it is: http://stiftsbogtrykkeriet.dk/~mcs/Scale.html
EPS version only though...
Best regards,
Mikkel C. Simonsen
-
nice1 :thumb:
-
Mikkel, you are fast!
Can you implement the numbers?
-
Mikkel, you are fast!
Can you implement the numbers?
What numbers? Numbers next to the lines? I can try...
Best regards,
Mikkel C. Simonsen
-
yeah, like a DB scale...
You know, something like starting number and steps, so we get a dB scale.
Lets say -20 starting and 5db steps, in a 12 position scale would output:
-20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35 dB
Got that?
-
Something like this?
(http://stiftsbogtrykkeriet.dk/~mcs/Scale2.gif)
Best regards,
Mikkel C. Simonsen
-
I think I cracked that one also. Here's another test:
(http://stiftsbogtrykkeriet.dk/~mcs/Scale3.gif)
Still no hard math involved, but I did have to look up something in the "Blue book"...
Could this "tool" be remotely useful to anybody? If so I could add PDF or other output formats.
Best regards,
Mikkel C. Simonsen
-
completely useful.
this is the tool I'm working on building.
Here are the other features I intended:
Variable stroke size and length for the lines.
Variable scale names( the ability to create a list of titles that would appear next to the scales, so instead of 1-10, you could put in -60, -50. Or close, closer, disco, for that matter). Also the ability to vary font size for scale names. Also the ability to specify the name on the inside or outside of the scale.
The ability to specifiy a start and finish offset ( this would allow the printing of scales for the Lorlin type switches that are 2X6 or 4X3).
The ability to create sub-ticks, and specify their length.
The ability to substitue a small circle instead of a line(for either major or minor ticks)
The ability to vary the degree of tick separation.
None of these features seem like rocket science, and to me, would make my panels "dead sexy".
This is where I'm headed with this, the way it's going, you're beatin me to the punch :grin:
I did manage to figure out a way to save in PNG format from my app, as the JPG was really crap when rendered.
Regards
ju
-
You are aproaching perfection, MCS.
That´s really useful, at least for me...
It would be nice to have a downloadable .EXE version... Would this be possible? Or can I just save the web browser page and run it from my HD?
-
He'd have to provide the cmd file that's being referenced as well, in order to run it locally, which means it's likely to only work on a pc for local stuff.
regards
ju
-
This is nice! How about a smal "X" to mark the center of the scale?
Peace,
Al.
-
Yes, it would be needed for drilling.
-
Here's a small update.
Here's a new sample scale:
(http://stiftsbogtrykkeriet.dk/~mcs/Scale4.gif)
And here's the settings I used:
(http://stiftsbogtrykkeriet.dk/~mcs/ScaleSettings.gif)
As you can see I updated the webpage with the new version...
The X in the center is coming right up :green:
Best regards,
Mikkel C. Simonsen
-
a very tidy app ;)
I dont spose u have/can do a eps to hpgl convertor do ya?
-
Variable scale names( the ability to create a list of titles that would appear next to the scales, so instead of 1-10, you could put in -60, -50.
This part is done (I think).
Or close, closer, disco, for that matter).
A bit more difficult because of the text placement, but not too difficult...
Also the ability to vary font size for scale names.
No problem - any font size you want :)
The ability to specifiy a start and finish offset ( this would allow the printing of scales for the Lorlin type switches that are 2X6 or 4X3).
A start and end angle you mean? No problem - I'll work on that tomorrow...
The ability to create sub-ticks, and specify their length.
The ability to substitue a small circle instead of a line(for either major or minor ticks)
Also quite possible - but you will end up with a lot of settings...
The ability to vary the degree of tick separation.
Que?
This is where I'm headed with this, the way it's going, you're beatin me to the punch :grin:
I hope you don't mind - I'm just having a bit of fun...
Best regards,
Mikkel C. Simonsen
-
It would be nice to have a downloadable .EXE version... Would this be possible? Or can I just save the web browser page and run it from my HD?
The .cmd file is a REXX script, so you can run it on anything with a REXX interpreter (from PC-DOC to mainframes - including Macs). But since it's a CGI script, you would have to run a local webserver also...
But you don't really need the software. Most of the "software" is actually included in the file you download. If you open the file in a text editor, you'll see this bit near the top:
% User supplied settings
/outrad 70 def
/inrad 60 def
/steps 11 def
/numsz -5 def
/startnum 25 numsz sub def
/text ( Testing 1 2 3 ) def
% End user supplied settings
Just change the numbers (and text), and you have a new scale.
Best regards,
Mikkel C. Simonsen
-
As to variance of tick separation. some stepped switches vary the angle of separation between clicks. so you'll want the ability to specify how many degrees between steps ( this goes in tandem with the start and finish offset). In this fashion, you can say, I need 6 steps, with 35 degrees space at the beginning, and 12 degrees between clicks.
As to you crankin this out quicker, it doesn't bother me one bit. To me I thought it was something useful that I need in a bad way, and that the overall group could benefit from. You've either got more spare cycles, or a bigger noggin, so I'm happy either way :thumb:
So yes, what I had in mind had a lot of options, but would be very flexible. You could create anything from what is on the front of an LA2A, to any of the other projects floatin around.
Oh, and have I told you recently that you rule :!: :green: :guinness:
on question. Is the points scale completely relative in postscript?
Regards
ju
-
a very tidy app ;)
I dont spose u have/can do a eps to hpgl convertor do ya?
You can convert it to HPGL using either CorelDRAW or pstoedit - but the result isn't that great.. I'll see if it can be improved though.
Best regards,
Mikkel C. Simonsen
-
bump, we posted at the same time, want to make sure you caught that =)
-
As to variance of tick separation. some stepped switches vary the angle of separation between clicks. so you'll want the ability to specify how many degrees between steps ( this goes in tandem with the start and finish offset). In this fashion, you can say, I need 6 steps, with 35 degrees space at the beginning, and 12 degrees between clicks.
I may be a bit slow (or I had too much wine at dinner), but I don't really understand your example. Is the spacing between the 6 steps 35° or 12° (or both)?
As to you crankin this out quicker, it doesn't bother me one bit. To me I thought it was something useful that I need in a bad way, and that the overall group could benefit from. You've either got more spare cycles, or a bigger noggin, so I'm happy either way :thumb:
I have just solved a lot of strange problems in PostScript - like making invoices from an IBM S36 (meant for a matrix printer) look nice and "modern" on a colour laser...
Oh, and have I told you recently that you rule :!: :green: :guinness:
Thanks!
on question. Is the points scale completely relative in postscript?
Points are used to define positions in "user space". A point is 1/72" (if you didn't know), and 0.0 is the lower left corner.
Best regards,
Mikkel C. Simonsen
-
but the result isn't that great.. I'll see if it can be improved though.
I made some changes to the "scale drawing engine" :green:, and now the pstoedit produced HPGL file starts to look better.
This is what it looks like when imported into CorelDRAW:
(http://stiftsbogtrykkeriet.dk/~mcs/ScalePlot.gif)
Could anybody check the HPGL file in Front Panel Designer? Here it is: http://stiftsbogtrykkeriet.dk/~mcs/Scale3.plt
Best regards,
Mikkel C. Simonsen
-
Here's the result on importing hpgl into FPD:
http://notapplicable.co.uk/audiolab/mcs-scale.pdf
-
Here's the result on importing hpgl into FPD:
That looks OK to me? I have never used FPD, so I don't know what it's supposed to look like...
If it's OK, I'll add HPGL output tomorrow.
Best regards,
Mikkel C. Simonsen
-
fum wrote:
As to variance of tick separation. some stepped switches vary the angle of separation between clicks. so you'll want the ability to specify how many degrees between steps ( this goes in tandem with the start and finish offset). In this fashion, you can say, I need 6 steps, with 35 degrees space at the beginning, and 12 degrees between clicks.
mcs wrote:
I may be a bit slow (or I had too much wine at dinner), but I don't really understand your example. Is the spacing between the 6 steps 35° or 12° (or both)?
this is saying start at 35 degrees, and make 6 steps 12 degrees apart. So 35, 47, 59, etc.
regards
ju
-
Wow,
You software guys can knock it out quick...
...I'd still be greasing my hole punches at this stage in a project!
:wink:
Good work!
:guinness:
Mark
-
oh, and in my cold medicine induced stupor, I didn't look at it from all angles, and the stuff I listed above is covered if you can specify pre and post offset. :grin:
ju
-
sorry for the slightly off topic. after youve got these diagrams drawn out, how do you transfer them onto the chassis? silk screening or something?
-
oh, and in my cold medicine induced stupor, I didn't look at it from all angles, and the stuff I listed above is covered if you can specify pre and post offset. :grin:
That's why I didn't really understand what you wanted to do...
I have added the HPGL option BTW, so test away. But please be patient - it takes 10-30s to do the HPGL convertion.
The "generator" was out of order for about 10 minutes while I updated it - sorry about that...:wink:
I have also changed the text algorithm so the text gets placed more accurately (and so that text labels are possible), but I won't have time to update the script on the server with that until tomorrow.
Best regards,
Mikkel C. Simonsen
-
> the JPG was really crap when rendered.
JPG has a quality setting, from nearly uncompressed to very small and totally jaggy.
JPG compression works really well for photographs, really bad for hard line art. Setting compression to nearly-none gives good results, and files smaller than BMP, but JPG is really overkill for 2-color line art.
GIF is perfect for this. It only supports 16/256 colors, but that is plenty. Its compression is very simplistic, but works great for big areas of the same color (and poorly for photographs with lots of detail). GIF is lossless (assuming you start with less than 256 colors).
Problem with GIF is that it is a CRT format, and translation to printer is uncertain. Some browsers render GIF as 72DPI on 300DPI printers by just printing each dot 4-wide/high. This gives 4% error from what you might expect: fine for web pages, bad if you need to fit a meter or switch. Smarter browsers and image programs may do more clever things, not always what you want.
PostScript not only has an unambiguous notion of dimension on the output device (printer), it can do all the calculations for you. Of course that assumes you have a PostScript printer, that it has no bugs, etc.
PDF, PostScript's child, "should" render exactly, but the darn Acrobat PDF renderer always wants to do things its own way.
Is it now impossible to walk into an art store and find small protractors and compasses?
> since it's a CGI script, you would have to run a local webserver also...
Most CGI apps can be run at the command line, redirecting output to a file. Oh wait: command lines are obsolete, aren't they?
-
> the JPG was really crap when rendered.
JPG has a quality setting, from nearly uncompressed to very small and totally jaggy.
I was using Suns JPG codec, as included in jre 1.3 (com.sun.image.codec.jpeg.*), and had it set to :
param.setQuality(0.75f, false);
which is high quality, supposedly. Could crank it up to 1, but it matters not now, as we have this *****in postscript version thanks to Mikkel.
It's a great thing when geeks run amok :thumb:
ju < not a graphics programmer, doesn't play one on tv
-
sorry for the slightly off topic. after youve got these diagrams drawn out, how do you transfer them onto the chassis? silk screening or something?
There are many ways, depending on your budget and/or DIY'itude.
We should probably put together a meta for this info, but here's a quick rundown of possibilities ( that you would probably search the archives for and find info on):
silkscreen
laser engraving
lazertran tranfer paper
toner transfer ala SSLTech
electrochemical etch
Hope this gets you started :grin:
ju
-
We should probably put together a meta for this info, but here's a quick rundown of possibilities
Yes, that would probably be a good idea - the "transfer to panel" part is by far the most difficult...
Best regards,
Mikkel C. SImonsen
-
PostScript not only has an unambiguous notion of dimension on the output device (printer), it can do all the calculations for you. Of course that assumes you have a PostScript printer, that it has no bugs, etc.
I don't think there are too many bugs, as long as I only use simple level 1 PS.
Most CGI apps can be run at the command line, redirecting output to a file. Oh wait: command lines are obsolete, aren't they?
Yes, you can run it on the command line. But having to provide some parameters as environment variables and others in a URL-encoded string on STDIN does make it a bit user-unfriendly...
Best regards,
Mikkel C. Simonsen
-
I have also changed the text algorithm so the text gets placed more accurately (and so that text labels are possible)
I have just updated the script with the new code - I don't know if anybody will notice the difference (yet) though...
Best regards,
Mikkel C. Simonsen
-
Here are a couple of new samples:
(http://stiftsbogtrykkeriet.dk/~mcs/Scale5.gif)
(http://stiftsbogtrykkeriet.dk/~mcs/Scale6.gif)
Now with optional subticks, ugly-font support and variable start/stop angles. I will update the script with these functions soon - custom labels coming soon...
I have added PNG and PDF formats BTW.
Best regards,
Mikkel C. Simonsen
-
Shaweet! Thanks Mikkel! :thumb:
-
MCS, you are great!
-
I love this place!
-
I added the third version now - including a short manual.
Please test and report bugs :green:
Here's the URL, so you don't have to dig it up in the thread: http://stiftsbogtrykkeriet.dk/~mcs/Scale.html
Best regards,
Mikkel C. Simonsen
-
Scale-O-Matic! I love it!
darn, where were you a year ago? :twisted:
:guinness: :guinness: :guinness: :guinness:
-
yes indeed,
excellent work there Mikkel.
I'm still experimenting.
:thumb:
... :sad: however, I'm not succeeding at the moment with PDF.
IE crashed and the PDF was blank.
show us the parameters of that test print above as an example.
-
Now it´s very PRO, man!!!
:grin:
-
This is great.... sorry for being a newb, how do you guys transfer this to a chassis? Lazertran?
-
:cool:
-
Allright, this just keeps getting better. One more feature request.
Can you make the number of sub-ticks a variable, such that you could have 4 sub-ticks between steps?
I know, I know, give the people what they want, and they'll nickel and dime ya to death :grin:
take a peek:
http://shinybox.com/diy/buss-squisher/panels.jpg
Thanks Mikkel :thumb: :guinness:
ju
-
Can you make the number of sub-ticks a variable, such that you could have 4 sub-ticks between steps?
Or none, for that matter....
It would be nice, Mikkel, if it´s not a pain.
-
darn, where were you a year ago? :twisted:
Right here - or at "the other place" I guess...
... :sad: however, I'm not succeeding at the moment with PDF.
IE crashed and the PDF was blank.
Yes, IE does that a lot - I'm not really sure if the cause is the Acrobat Reader plugin or IE. When the plugin "sees" a PDF file it doesn't like (which includes many types of PDFs) it acts strange. That probably causes IE to crash. But if IE does what it's told it should give you the option of saving the PDF instead of opening it. Does it? If you save the PDF file and open it in AR afterwards you'll have no problems. The bugs are in the AR plugin, not in AR itself. AR has many other bugs, but not this one :wink:
show us the parameters of that test print above as an example.
They are here: http://stiftsbogtrykkeriet.dk/~mcs/ScaleSettings2.gif
Can you make the number of sub-ticks a variable, such that you could have 4 sub-ticks between steps?
Yes, I'll have a look at that.
Or none, for that matter....
Just select "Subticks: no", or am I misunderstanding something?
Best regards,
Mikkel C. Simonsen
-
This is very impressive. After having done scales in Corel this will make life much easier, thanks.
Would it be too time consuming/difficult to add a few features:
Tick shape: for example a dot, specifiy diameter for major tick and a different dot diameter for minor tick.
Radii in mm or inches instead of points ? - would that introduce scaling errors to postscript ?
Text instead of ticks ?
Yeh, i know, the crazy swedes are never satsified... :grin:
-
This is very impressive. After having done scales in Corel this will make life much easier, thanks.
Whenever I have needed to draw something "difficult" like this, I have often written it in PostScript. I have even done graphics for websites that way...
Tick shape: for example a dot, specifiy diameter for major tick and a different dot diameter for minor tick.
What's next? Pink elephants? :green:
Something like this:
(http://stiftsbogtrykkeriet.dk/~mcs/Scale7.gif)
Do you want dots or circles (or both)?
The subtics are half size as it is now. Either half length or half diameter. Is that OK?
Radii in mm or inches instead of points ? - would that introduce scaling errors to postscript ?
I could multiply with 2.83 to convert from mm to points. That would only cause a small error.
Text instead of ticks ?
I will probably make no ticks an option - you can still specify the text for the lables- That option isn't ready yet though...
Yeh, i know, the crazy swedes are never satsified... :grin:
I'm not easy to satsify either :wink:
Best regards,
Mikkel C. Simonsen
-
That's exactly what i had in mind, thanks.
As for the pink elephants - No thanks, i hate pink :green:
-
I updated the script a bit. Now you can select the "tick" types - lines, circles or dots.
If anybody can write a simple PostScript procedure for drawing pink elephants I will add that also :green:
Best regards,
Mikkel C. Simonsen
-
thank you
-
How about llamas?
Something like this:
(http://stiftsbogtrykkeriet.dk/~mcs/Llama1.gif)
Here's a closeup:
(http://stiftsbogtrykkeriet.dk/~mcs/Llama2.gif)
Here's the code:
/DrawLlama
{
/deg deg stepsize add def
Xpos Ypos moveto
Xpos Ypos inrad deg deg arc
currentpoint moveto
-4 -8 rmoveto
gsave
currentpoint translate
currentpoint newpath
0.15 0.15 scale
0 0.9 0 setrgbcolor
/l {lineto} def
57 3 moveto
57 4 l 58 38 l 55 44 l 51 49 l 43 52 l 36 53 l
33 56 l 33 80 l 33 99 l 28 106 l 26 109 l
22 113 l 19 114 l 13 114 l 6 109 l
5 106 l 5 78 l 0 56 l 0 42 l 3 32 l 6 26 l 9 15 l
9 4 l 12 0 l 12 6 l 14 10 l 15 16 l 19 15 l
24 15 l 24 11 l 20 2 l 21 0 l 23 2 l
24 5 l 28 9 l 29 11 l 33 16 l 40 17 l 41 11 l
45 3 l 47 3 l 47 10 l 45 13 l 45 18 l 49 20 l
51 13 l 54 4 l 55 2 l
closepath fill
0 setgray
21 108 2 0 360 arc fill
7 108 2 0 360 arc fill
0.95 setgray
20 104 moveto
7 104 l 7 101 l 8 96 l 10 92 l 14 92 l 21 98 l
closepath fill
0 0.8 0 setrgbcolor
19 101 moveto
11 100 l 11 97 l 13 96 l 15 96 l
closepath fill
grestore
} def
Feel free to send me improvement to the code :green:
Best regards,
Mikkel C. Simonsen
-
Man, I may have to use the llamas on my green pre's =)