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

World: r3wp

[View] discuss view related issues

Graham
22-Apr-2008
[7697]
To crop the right and left edges I think we can just rotate the image 
90 deg, crop it with the existing routines and then rotate it back 
again
Reichart
22-Apr-2008
[7698]
Smart...
Anton
22-Apr-2008
[7699x2]
I was going to say that modifying the code to support horizontal 
cropping should be pretty easy. But that method is even easier !
(if a bit hackish.)
Graham
22-Apr-2008
[7701]
Seems to work ... but I have to rotate 270 deg and not -90 to get 
the original orientation back.  Does effect not take a negative rotation?
Geomol
22-Apr-2008
[7702]
Seems to only do 0, 90, 180 and 270:
http://www.rebol.com/docs/view-system.html#section-9.5
Graham
22-Apr-2008
[7703]
Ahh.. that's no fun.  So, I can't use this to deskew.
Geomol
22-Apr-2008
[7704]
Do you know, how to use DRAW to do image transformations?
Graham
22-Apr-2008
[7705x2]
nope
I usually learn enough about view to do something I need and then 
promptly forget it :(
Geomol
22-Apr-2008
[7707]
You can rotate an image in DRAW like this:


view layout [box effect [draw [translate 40x0 rotate 60 image logo.gif]]]
Graham
22-Apr-2008
[7708x3]
that's how I'm doing the rotation now.
uhmm.. maybe not.
I'll try that out :)
Anton
23-Apr-2008
[7711]
( yes,  effect [draw [rotate]]  is different than  effect [rotate] 
)
Pekr
3-May-2008
[7712x2]
Here's small challenge. I created following script which is surely 
full of junk. I am not good View coder :-) Now who helps me to simplify 
it and to get the movement smoother? :-)
screen-size: system/view/screen-face/size
news-bottom-offset: 0x100
news-height: 0x100

message: "This is short news scroller. Who makes me smooth? ..."

;--- style for draw dialect
bold64: make face/font [style: 'bold size: 64 color: white]


;--- But how to calculate text size for draw? Here's a workaround 
...
txt: make face compose [size: 2000X200 text: (message)]
txt/font: make face/font [style: 'bold size: 64 color: white]
text-size: size-text txt


view/offset/options layout/size [
  backcolor green

  ;--- we start behind the screen ....
  at (to-pair reduce [screen-size/x 10])

  t: box (to-pair reduce [2000 news-height/y]) ;--- box size ...
       effect compose/deep [
         draw [
           font bold64
           text (message)
         ]
        ] 
       rate 50
       feel [
         engage: func [f a e][
           if a = 'time [
             ;--- zde nastavujeme rychlost posuvu
             f/offset: f/offset - 3x0

             if (f/offset/x + (first text-size)) < 0 [f/offset/x: screen-size/x]
             show f  
         ]
        ]
      ]

] (to-pair reduce [screen-size/x news-height/y])(to-pair reduce [0 
(screen-size/y - news-bottom-offset/y - news-height/y)])[no-border 
no-title]
Anton
3-May-2008
[7714]
I don't think you can make it 100% smooth without knowing when the 
screen refreshes.

You have two faces (which you might need long term), but you could 
probably achieve the same text scrolling effect with just one face 
by modifying its para/offset.
Anton
4-May-2008
[7715x5]
No, you can't :) Of course, the window/text goes to the title-bar.
(so to get text in a window you always need at least one subface.)
Yes, you can :) but it's using Draw dialect text.
view/new window: make face [
	size: 800x150
	font: make face/font [size: 40]

 effect: compose/deep [draw [font (font) text 100x50 "Hello there"]]
	rate: 50
]
window/feel: make window/feel [
	engage: func [face action event][
		if action = 'time [
			window/effect/draw/text/x: window/effect/draw/text/x - 1
			show window
		]
	]
]
do-events
i
Anyway, it doesn't fix the basic problem.
Brock
4-May-2008
[7720]
Is it possible that 'jitter' that occures in Pekrs nice example sharing 
the same root cause as the 'heart-beat' that Geomol mentioned in 
a previous post?
Pekr
4-May-2008
[7721x2]
not sure. HeartBeat might be TCP related. On my Core 2 duo I am not 
observing jitter, just not smooth animation. Now remember that Amiga 
with 7MHz CPU was able to provide us with absolutly smooth scrolling. 
But Win32API lacks vertical blanking period synchronisation, so I 
wonder if without DirectX or OpenGL we are able to actually make 
our situation better ...
Some time ago Carl told us, that View uses double buffering, but 
apparently it is not enough ....
TimW
8-May-2008
[7723]
Is there a way to have a face receive mouse input that is recieved 
via layouts in the faces pane?  This sounds weird, but when building 
components, if there is a generic face object that they all share, 
then on top of that face you add a layout with certain styles.  Is 
there a way(without adding a handler in the layout) to have the face 
receive the message as well?
Gregg
8-May-2008
[7724x2]
Have you tried DETECT? http://www.rebol.com/how-to/feel.html#sect6.
I rarely use detect, but use insert-event-func quite often.
TimW
11-May-2008
[7726x4]
That might be what I need.  Messing with it seemed to overwrite some 
other handlers.  Suppose you have this:  my-face: make face [
			offset: offs
			size: sz
			color: 0.0.0

   text: win-title ;rejoin[window-counter ":" name] ;should this be 
   copy name?
			plugid: plug-id
			id: window-counter
			pane: copy []]
sorry about the comments....but just take it as a basic face. then 
you want to append my-face/pane layout[ txt: area button "blah" [txt/text: 
"something"]]
Where can I put the handler such that when the layout is clicked 
'my-face also receives a notification.  I was hoping I could put 
the feel in the face declaration, but that doesn't do anything.  
 Also, more than one layout is usually getting added to the pane. 
 I just want to the parent face to receive a message whenever one 
of them are clicked without having to add the handler in each of 
the layouts.
Nevermind.  I got detect to work for me by declaring my-pane/feel. 
 I had not been returning the events correctly.  Thanks for pointing 
me in the right direction.
Gregg
12-May-2008
[7730]
Glad you got it working!
james_nak
13-May-2008
[7731]
Graham, your 'grahamchat.r" code is just what I've been looking for. 
Thanks.
Graham
13-May-2008
[7732]
hehe .... I don't even know what that is any more!
james_nak
13-May-2008
[7733]
It has the illusive text layout like what we are looking at now in 
Altme; that is, text boxes with different heights. It's so simple 
when you see someone else do it.
Graham
13-May-2008
[7734]
oh .. I'm sure i copied it off someone else :)
amacleod
15-May-2008
[7735]
Where did you find grahamchat.r. Its not in the library.
Rebolek
21-May-2008
[7736]
The difference between random and random/secure:

img: make image! 512x512 
repeat i 512 [
	repeat j 512 [
		either i < 256 [
			if 2 = random 2 [
				img/(as-pair i - 1 j - 1): 255.255.255
			]			
		][
			if 2 = random/secure 2 [
				img/(as-pair i - 1 j - 1): 255.255.255
			]
		]
	]
]


view layout [image img across text "RANDOM" tab tab tab text "RANDOM/SECURE"]
Gregg
21-May-2008
[7737]
Awesome Rebolek! You always come up with great visualizations.
Rebolek
21-May-2008
[7738]
Thanks Gregg, actually it's not my idea, it's based on this article 
- http://www.boallen.com/random-numbers.html, I was just curious 
if there's some pattern in REBOL 'random too.
Gregg
21-May-2008
[7739]
randomize: func [
    "Reseed the random number generator."

    /with seed "date, time, and integer values are used directly; others 
    are converted."
][

    random/seed either find [date! time! integer!] type?/word seed [seed] 
    [
        to-integer checksum/secure form any [seed now/precise]
    ]
]

img: make image! 512x512 
repeat i 512 [
	randomize
	wait .001
	repeat j 512 [
		either i < 256 [
			if 2 = random 2 [
				img/(as-pair i - 1 j - 1): 255.255.255
			]			
		][
			if 2 = random/secure 2 [
				img/(as-pair i - 1 j - 1): 255.255.255
			]
		]
	]
]


view layout [image img across text "RANDOM" tab tab tab text "RANDOM/SECURE"]
Rebolek
21-May-2008
[7740]
great!
Geomol
22-May-2008
[7741]
Nice view, Rebolek!!! :-)
Anton
22-May-2008
[7742x2]
Nice! By the way, here's the fastest optimization I could come up 
with (about 30% faster):
t0: now/precise
img: make image! 512x512
i: 0
loop 512 [
	loop 256 [i: i + 1 if 2 = random 2 [poke img i 255.255.255]]

 loop 256 [i: i + 1 if 2 = random/secure 2 [poke img i 255.255.255]]
]
print difference now/precise t0
Graham
22-May-2008
[7744]
amacleod - I don't know where grahamchat.r is either .. but they 
same should be in synapsechat in the contest entries on viewtop
Graham
25-May-2008
[7745]
How does one determine how many lines there are of text in an area 
filled with text?
Rebolek
25-May-2008
[7746]
height-of-area / height-of-font ?