r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[View] discuss view related issues

james_nak
30-Aug-2005
[2376]
Very nice. Looks like dpaint.
Henrik
30-Aug-2005
[2377]
Generic newbie-like question: I was spying on source request-dir 
and am baffled as to how it works? There are many function names, 
I can't seem to access directly, such as F-LIST and DIROUT. Where 
do they come from?

request-dir: func [
    "Requests a directory using a popup list."
    /title "Change heading on request." title-line
    /dir "Set starting directory" where [file!]
    /keep "Keep previous directory path"
    /offset xy
][
    if block? dirout [
        dirout: layout dirout
        max-dirs: to-integer f-list/size/y - 4 / f-txt/size/y
        center-face dirout
    ]
    set-face f-title any [title-line "Select a directory:"]
    if not all [keep path] [
        path: copy either where [clean-path where] [what-dir]
    ]

    if all [not empty? path slash = last path] [remove back tail path]
    last-path: path
    result: none
    show-dir
    either offset [inform/offset dirout xy] [inform dirout]
    result
]
Pekr
30-Aug-2005
[2378]
... as for request-dir - today I saw another native one dialog. Dunno 
programmers do have to produce one themselves or not. It was with 
mySQL installation procedure. I looked like typical Windows request-file 
requestor, but it had set filter to "directory". Could anyone check 
on that, please? I really do not like that inconsistency in rebol 
...
Chris
30-Aug-2005
[2379x2]
probe req-dir
I imagine 'request-dir is bound to this context.
Henrik
30-Aug-2005
[2381x4]
thanks
REBOL [
  title: "Multi-File Search"
  author: "Henrik Mikael Kristensen"
]

search-function: func [/local files results] [
  results: copy []
  status/color: red
  show status
  nof-files: length? files: read to-file get-face search-dir
  forall files [
    if not dir? first files [
      data: read/lines first files
      status/text: join "Searching: " first files
      set-face status-progress divide index? files nof-files  
      show [status status-progress]
      forall data [
        if found? find/any first data get-face search-string [

          insert tail results reduce [first files index? data first data]
        ]
      ]
    ]
  ]
  status/color: gray
  results-list/data: results
  status/text: reform ["Results:" length? results "found"]
  show [results-list status]
]

main: layout [
  style header button 100x20 gray edge [size: 1x1]
  backdrop effect [gradient 0x1 200.200.200 180.180.180]
  across space 2 origin 8

  label white gray 300x20 "Search Multiple Files" font [align: 'center 
  size: 14] return
  search-string: field (as-pair 228 22) btn 70 "Search" [
    if not empty? search-string/text [search-function]
  ] return

  search-dir: field (as-pair 228 22) btn 70 "Directory..." [set-face 
  search-dir request-dir] return

  status: label white gray 300x20 "Results" font [align: 'center size: 
  14] return
  space 0x0

  header "File" header 50 "Line" header 132 "Text" box gray 18x20 return
  results-list: text-list 300x200 data [] [print "test"] return
  status-progress: progress gray white 300x10
]

set-face search-dir %.

inform center-face main
crude prototype, but it helped me find the file I had been looking 
for :-) I don't know how  to do actual multi columns with the internal 
text-list. the plan was to allow scrolling (I can't get that working) 
and when you click on a search result, the file pops up in the viewtop 
editor. feel free to perfect it...
(and post it here again!)
Geomol
30-Aug-2005
[2385x4]
AGG used in the draw dialect is very good at anti-aliasing. But then 
some (maybe) unexpected results occur, when anti-alias is turned 
off:
view layout [i: image black effect [draw [anti-alias off circle 50x50 
20 line 20x20 80x20 20x80 20x20]] image (i/size * 5) (to-image i)]
It's interesting, that a translate 0.5 0.5 will give a more 'even' 
result:
view layout [i: image black effect [draw [translate 0.5 0.5 anti-alias 
off circle 50x50 20 line 20x20 80x20 20x80 20x20]] image (i/size 
* 5) (to-image i)]
Anton
31-Aug-2005
[2389]
Yes, normally you think of a pixel offset (say, 0x0) is at the centre 
of the pixel. But it's not, it's at the top left of the pixel. If 
you zoom in, logically 0x0 should be at the top left of the square 
that represents the zoomed-in pixel.
Geomol
31-Aug-2005
[2390x6]
But shouldn't that be the case with end-points of lines too?
To illustrate it:
view layout [i: image black effect [draw [line-width 4 line-cap round 
pen white line 30x20 80x20 pen none fill-pen white circle 20x20 2 
pen white line 30x40 80x40 translate 0.5 0.5 pen none fill-pen white 
circle 20x40 2]] image (i/size * 5) (to-image i)]
Top looks wrong, bottom is correct (and need translate).
Even easier to see with a line-width of 2:
(Maybe I should report it to RAMBO? Is it a bug?)
view layout [i: image black effect [draw [line-width 2 line-cap round 
pen white line 30x20 80x20 pen none fill-pen white circle 20x20 1 
pen white line 30x40 80x40 translate 0.5 0.5 pen none fill-pen white 
circle 20x40 1]] image (i/size * 5) (to-image i)]
Anton
31-Aug-2005
[2396x2]
I agree, that seems to be an inconsistency. Cyphre is probably aware 
of it, but worth a bug report. If you have some time maybe compare 
with other commands, too.
It is arguable which one is wrong, though, the line or the circle.
Geomol
31-Aug-2005
[2398]
Bug report sent.


I'm spending the day making a DPaint kind of program in REBOL. Will 
release the work so far later today.
Rebolek
31-Aug-2005
[2399]
Geomol that's great! Will it support animation? ;)
Henrik
31-Aug-2005
[2400]
and animbrushes?
Geomol
31-Aug-2005
[2401x2]
One step at a time! :-)
My DPaint clone "Canvas" version 0.1. It's a few hours of work, around 
150 lines of code. Only REBOL makes it possible! :-) There's some 
way to a full DPaint clone, but it's a good start.


Instructions here: http://home.tiscali.dk/john.niclasen/canvas/canvas.html
Canvas here: http://home.tiscali.dk/john.niclasen/canvas/canvas.r
Henrik
31-Aug-2005
[2403]
great stuff! but drawing is a bit slow here. would it be an idea 
to limit mouse input to a certain amount per second?
Geomol
31-Aug-2005
[2404]
Yes, that could be a solution.
Is it also slow, if you turn anti-alias off? Hit 'a'!
Henrik
31-Aug-2005
[2405]
it seems to be about the same speed
james_nak
31-Aug-2005
[2406]
That's very cool G. Works really well on my PC.
Brock
31-Aug-2005
[2407]
Works well here as well, nice job.
Cyphre
31-Aug-2005
[2408]
Geomol: regarding AGG in ALIASED mode: I'm working on improvements 
in this mode so the graphic shoudl be 'pixel precise'.
Geomol
31-Aug-2005
[2409]
Good to know, Cyphre. And thanks guys! Preciate it. I hope, this 
'little' project will turn out well. I need a DPaint program to do 
the graphics for a phone-game, I'm involved in.
DideC
1-Sep-2005
[2410]
Geomol: impressive !!!
Geomol
1-Sep-2005
[2411x2]
:-) New version uploaded with guide-lines for rectangle, circle and 
so, and 2 new drawing tools, ellipse and filled ellipse.
There seem to be a small anomaly, when doing thick circles and ellipses, 
in the right side, where the circle/ellipse starts and ends. It may 
have something to do with "line-cap round", but if that is left out, 
there will be a tiny gap, when drawing really thick circles/ellipses.

Maybe Cyphre should check it out!?
Henrik
1-Sep-2005
[2413x2]
I changed BITMAP-SIZE to 1024x768 and as I suspected it really slows 
down now...
it could be a graphics driver problem, but I also tried it on my 
linux laptop and it's also very slow there.
Geomol
1-Sep-2005
[2415]
Henrik, it must be something special with your setup, and you get 
slow console output on the
do http://www.rebol.com/speed.r

speed-test, as we talked about. You could post your speed output 
here somewhere and specify your setup. Maybe others have a solution!
Henrik
1-Sep-2005
[2416x4]
Console:   0:00:16.274 - 31 KC/S
Processor: 0:00:00.631 - 1369 RHz (REBOL-Hertz)
Memory:    0:00:01.943 - 24 MB/S
Disk/File: 0:00:01.121 - 27 MB/S
I have an ATI Radeon 9500 graphics card with the latest Catalyst 
drivers and the test is run on a Celeron 2.6 Ghz PC with 640 MB of 
PC133 memory
adding a framerate limiter in your code helps nothing
but I've always had this problem that painting large surfaces in 
REBOL takes a long time on my machine and it doesn't really matter 
what drivers I use
Geomol
1-Sep-2005
[2420]
I get:
Console:   0:00:01.703 - 297 KC/S
Processor: 0:00:00.406 - 2128 RHz (REBOL-Hertz)
Memory:    0:00:01.344 - 35 MB/S
Disk/File: 0:00:00.203 - 150 MB/S

on a 2.4GHz Pentium 4, 512 MB ram (not sure about speed, it's an 
ASUS P4P800 board), ATi Radeon 9600, not the newest drivers.
Henrik
1-Sep-2005
[2421x3]
ok, I take back the part of the framerate limiter :-)
try this: http://hmkdesign.dk/rebol/canvas.r
ah... it's dangerous, because it misses events on my slow laptop 
now, but drawing is much speedier on my "broken" PC
Geomol
1-Sep-2005
[2424]
Well, it's a work-around, if you have slow graphics.
Henrik
1-Sep-2005
[2425]
I've put a limiter on SHOW so that it only shows every interval, 
but doesn't miss as many position samples. so even though the framerate 
appears slow, it's actually very responsive. it's SHOW that's the 
killer.