Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 28 May 2015, 00:22
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Engineering/Science/Simulation
rul3r v1.3
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [18 Posts]   Goto page: 1, 2 Next
Author Message
SFR


Joined: 26 Oct 2011
Posts: 1297

PostPosted: Mon 02 Mar 2015, 13:16    Post subject:  rul3r v1.3  

I needed to measure something, but didn't find a ruler, so I wrote one.
All it does is generate and display 3 rulers: Pixels, Centimeters and Inches.

The real DPI is calculated from xrandr's output and all floating-point calculations are done using awk (20 decimal places), so should be pretty accurate.

A tiny irregularities in distribution of millimeters marks may be visible, especially at lower resolutions, but I guess there's no way to avoid this, since it's impossible to convert analog (mm) to digital/discrete (px) values 100% accurately - it's just an approximation...

Requirements: xrandr, awk, cut, grep, seq, gtkdialog, xmessage.
___________

Changelog:

Version 1.1
- fixed: reading the width of the screen (thanks to MochiMoppel)

Version 1.2
- a warning window in case if obtaining the physical size of the display has failed (thanks to Jasper & mister_electronico)
- physical size of the display can be also defined manually in $HOME/.rul3r

Version 1.3
- fix in calculations for screens that have width smaller than height (thanks to MochiMoppel)

Enjoy &
Greetings!
rul3r-1.3.pet
Description 
pet

 Download 
Filename  rul3r-1.3.pet 
Filesize  2.71 KB 
Downloaded  81 Time(s) 
Screenshot.png
 Description   
 Filesize   29.19 KB
 Viewed   508 Time(s)

Screenshot.png


_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.

Last edited by SFR on Sat 07 Mar 2015, 06:29; edited 3 times in total
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 671
Location: Japan

PostPosted: Mon 02 Mar 2015, 21:59    Post subject: Re: rul3r v1.0  

SFR wrote:
I needed to measure something, but didn't find a ruler, so I wrote one.
Funny. 2 days ago I needed to measure something, but didn't find a ruler, so I made pencil marks on the edge of my monitor Laughing

What I needed was a ruler or a grid that indicates number of pixel from position 0x0. A simple 1200x1600 grid wallpaper would do the job, but I was too lazy to create one.

Your ruler looks nice, but doesn't yet work for me. I'm used to rulers that start at zero Wink
Your calculation of screen width is not correct.
Replace
Code:
SCREEN_WIDTH=`xrandr  | grep -wo '[0-9].*\*' | cut -f1 -d 'x'`

with something like
Code:
SCREEN_WIDTH=$(xwininfo -root|awk '$1=="Width:"{print $2}')
If you have to use xrandr you must extract the "current" setting from the first line of output.
ruler.png
 Description   
 Filesize   4.81 KB
 Viewed   447 Time(s)

ruler.png

Back to top
View user's profile Send private message 
Jasper


Joined: 25 Apr 2010
Posts: 1271
Location: England

PostPosted: Tue 03 Mar 2015, 00:13    Post subject: PicPick runs well in Wine  

Hi MochiMoppel,

I don't remember if you use Wine and doubtless you could make (and by now may already have made) your own superb pixel ruler.

You may know about PicPick and its functions which include a pixel ruler, but if not there is http://www.picpick.org/en/ and a couple of screen shots below.

I got my excellent free copy from http://portableapps.com/

My regards

PS I'm up late as I've been trying to recover from a hard drive wipe out that's a major disappointment rather than a catastrophe.
PicPick.png
 Description   
 Filesize   36.66 KB
 Viewed   424 Time(s)

PicPick.png

Pixel ruler.png
 Description   
 Filesize   17 KB
 Viewed   428 Time(s)

Pixel ruler.png

Back to top
View user's profile Send private message 
Geoffrey


Joined: 30 May 2010
Posts: 1752
Location: Queensland

PostPosted: Tue 03 Mar 2015, 00:20    Post subject:    

Opacity would be handy
Code:
<window title="'${APPNAME}'" resizable="false" opacity="0.5" image-name="/usr/share/pixmaps/rul3r.png">
rul3r.jpg
 Description   
 Filesize   72.67 KB
 Viewed   419 Time(s)

rul3r.jpg


_________________
Carolina: Recent Repository Additions
Create strikethrough text HERE
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1297

PostPosted: Tue 03 Mar 2015, 08:25    Post subject:  

@Mochi: Usually I use xwininfo, but in this case I needed xrandr anyways, to get real size of the physical screen, so didn't want to introduce another dependency (I think I'm becoming a coding purist with age Wink).

Anyway, could you please post your xrandr output? Perhaps it can be fixed.
Here's mine for comparison:
Code:
# xrandr
Screen 0: minimum 320 x 200, current 1366 x 768, maximum 8192 x 8192
LVDS connected 1366x768+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
   1366x768       60.0*+
   1280x720       59.9 
   1152x768       59.8 
   1024x768       59.9 
   800x600        59.9 
   848x480        59.7 
   720x480        59.7 
   640x480        59.4 
VGA-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 disconnected (normal left inverted right x axis y axis)
DisplayPort-0 disconnected (normal left inverted right x axis y axis)
#
# xrandr | grep -wo '[0-9]*mm x [0-9]*mm' | cut -f1 -d 'm'
344
#
# xrandr  | grep -wo '[0-9].*\*' | cut -f1 -d 'x'
1366
#

EDIT: will this one work for you?
Code:
xrandr  | grep -wo -m1 'current [0-9]*' | cut -f2 -d ' '

Thanks.
___________

@Geoffrey: Hmm, not a bad idea, but requires an environment that supports real transparency (like XFCE, which I assume is in your case?).
On the other hand, I wrote this app to measure objects from the real world, not those on the desktop (since it would allow to measure only items that are parallel to the x-axis), although a concept for another app is crystallizing as we speak, so maybe later. Wink

Thanks guys &
Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 671
Location: Japan

PostPosted: Tue 03 Mar 2015, 10:33    Post subject:  

SFR wrote:
I think I'm becoming a coding purist with age Wink).
You are already a purist. I like your code. Looks like a well crafted poem ...well, almost. Laughing

Below my xrandr output, together with your fixed ruler (yes, your new code works for me).I also tinkered with this idea and rolled my own. Works pretty well, but requires ImageMagick.
Screenshot.png
 Description   
 Filesize   30.99 KB
 Viewed   364 Time(s)

Screenshot.png

Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1297

PostPosted: Tue 03 Mar 2015, 11:42    Post subject:  

Thanks Mochi Laughing

Ok, thank you for confirmation, v1.1 with the fix uploaded.

@Geoffrey et all: measur3r-1.0 is the app to measure stuff on the desktop. Cool

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
Jasper


Joined: 25 Apr 2010
Posts: 1271
Location: England

PostPosted: Tue 03 Mar 2015, 13:12    Post subject:  

Hi SFR and co-conspirators,

That's brilliant and the screen shot demonstrates that you are spot on (and so was Pythagorus).

I seem to have everything you list, except my "xmessage" seems to like "gxmessage" and, perhaps strangely, I only see pixel measurements and my output screen is a fraction too small.

My regards, thanks and congratulations.
Shot(1).png
 Description   
 Filesize   16.62 KB
 Viewed   315 Time(s)

Shot(1).png

Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1297

PostPosted: Tue 03 Mar 2015, 13:29    Post subject:  

Hi Jasper

This indicates a problem with obtaining real screen dimensions.
Could you please post the output of xrandr command?

xmessage usually is a link to gxmessage and they share most of options, but the latter looks much better.
It should automatically adjust the window size to its content, but I may add '-geometry' option in next version.

Btw, on a general note, both rul3r and measur3r won't be working in VirtualBox (and probably other VMs), because xrandr returns '0mm x 0mm' there...

Thanks for testing &
Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
Jasper


Joined: 25 Apr 2010
Posts: 1271
Location: England

PostPosted: Tue 03 Mar 2015, 13:44    Post subject:  

Hi again,

Thank for your response. Here is the requested output:

Code:
# xrandr
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 640 x 480, current 1024 x 768, maximum 1024 x 768
default connected 1024x768+0+0 0mm x 0mm
   1024x768        0.0*
   800x600         0.0 
   640x480         0.0 
#


My regards
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1297

PostPosted: Tue 03 Mar 2015, 13:51    Post subject:  

Quote:
default connected 1024x768+0+0 0mm x 0mm

And that's the problem. I don't know why doesn't it show the size in your case and I don't know any other (reliable) way to get the needed info, unfortunately.
I'm afraid you're just out of luck with this one. Sad

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
Jasper


Joined: 25 Apr 2010
Posts: 1271
Location: England

PostPosted: Tue 03 Mar 2015, 14:03    Post subject:  

Hi SFR.

No, I'm lucky to get expert help and (if desperate) I believe I could use a calculator to convert the pixel results to mm or whatever.

My regards
Back to top
View user's profile Send private message 
Jasper


Joined: 25 Apr 2010
Posts: 1271
Location: England

PostPosted: Wed 04 Mar 2015, 11:40    Post subject:  

This is a screen shot reminder about 5* Puppy measurement apps from SFR:

(1) xonclock (style, place and easily resize to suit)
(2) LFF (large files finder) There is a later version
(3) xonview (shows disk reads and writes) Full screen for graphics
(4) measur3r (in yellow) - calculates horiz/vert/diagonal distance
(5) PicPick (ruler as shown) uses Wine. SFR has issued rul3r v 1.2 as above.

My/our thanks go out to, the fiendishly clever, SFR and his co-conspirators.
Shot.png
Description 
png

 Download 
Filename  Shot.png 
Filesize  79.61 KB 
Downloaded  79 Time(s) 
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1297

PostPosted: Wed 04 Mar 2015, 13:24    Post subject:  

Thanks Jasper. Smile
Btw, since version 1.1, measur3r won't start if it's unable to determine physical size of the display (and user won't provide this info), so I have uploaded also measur3r_lite, which supports only pixel units.

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 671
Location: Japan

PostPosted: Fri 06 Mar 2015, 23:39    Post subject:  

Hi SFR,

I tried rul3r v1.2. and see 2 issues:

1) My screen is 1200px wide, but what I get is only 1040px. Not enough to measure large screen elements. Your screenshot shows 1200px, so I guess it's not a deliberate limitation.
2) The cm calculation is wrong. The 35cm on your ruler actually is only 26cm, measured with a "real" ruler. And since 26cm would be about 10 inches, inches are also not correct Crying or Very sad In other words: The ruler exaggerates. I hope you didn't use it to measure important parts Laughing
rulers.png
 Description   
 Filesize   40.19 KB
 Viewed   165 Time(s)

rulers.png

Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [18 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Engineering/Science/Simulation
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0980s ][ Queries: 12 (0.0078s) ][ GZIP on ]