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

World: r3wp

[View] discuss view related issues

Maxim
21-Dec-2006
[6487]
doesn't Cyphre already have an AGG SVG viewer
Henrik
21-Dec-2006
[6488]
how is the tiger demo done?
Geomol
21-Dec-2006
[6489]
There is a "SVG RENDERER" group here.
Maxim
21-Dec-2006
[6490x2]
my god profiling stuff in REBOL in quite rewarding!
my latest shape compressor is now 2.5 times faster, by using a list! 
instead of a binary while accumulating values, and then converting 
it to binary!
Geomol
21-Dec-2006
[6492]
Can you try a hash!?
Maxim
21-Dec-2006
[6493]
there is no point... since I'm never accessing it... list! is the 
fastest insert series in REBOL
Geomol
21-Dec-2006
[6494]
ok. Do you preallocate space for all the entries beforehand? So it 
doesn't have to expand along the way.
Maxim
21-Dec-2006
[6495x4]
and since I'm only converting it to binary at the end, a lot of GC 
processing is alleviated.
oh, and 1000 of the above glyphs now takes 4.5 seconds to compress... 
imagine if we had rebcode !
lst: make list! 5000

rule: [
	any[
		[copy val pair! (
			insert lst val/1/x
			insert lst val/1/y
		)] |

  [copy val word! (insert  lst select [curve 130 line 131 move 132] 
  val )]
	]
]
parse draw-shape rule
bin: to-binary head lst
clear head lst

lst: head lst  ; a small quirk in list! datatype... it MUST be reset 
to head after a clear.
and 1000 glyphs takes 8.95 MB of RAM which is quite optimal IMHO 
   :-)
Ashley
21-Dec-2006
[6499]
How does that compare with:

	glyph: compress mold draw-blk
	load decompress glyph
Maxim
21-Dec-2006
[6500x4]
didn't try, I was having fun with parsing  ;-)
using compress is 2 times faster but takes up 20% more ram
(in compression)
but there is no comparison in decompression... using decompress  
is 4 times faster so far.. I could probably squeze a bit more more 
out of parse... but not much.
Jerry
21-Dec-2006
[6504x4]
Maxim, it's not "tsai", it's "yung". The meaning is some kind of 
traditional chinese musical instruments. http://www.unicode.org/cgi-bin/GetUnihanData.pl?codepoint=93DE
Henrik, it is possible to draw all the characters this way, not just 
Chinese characters. I am designing my own Text-Rendering System this 
way.
To condense the font data, there is a better way. Almost every Chinese 
character consists of many parts. if reusing the parts, a Chinese 
TTF file can be condensed from 4 MB to 100 KB. However, doing that 
would need lots of analysis of Chinese characters. That's would not 
be easy. Also needed is a part-combining engine.
For example, the left part of the "yung" Chinese character is "jin", 
meaning "gold" or "metal". The left part of any  metal-related character 
is exactually the same as the left part of "yung". There are hundreds 
of such characters. And "metal" is just an example, we also have 
"water", "fire", "soil", "bird", "dog", "hand", "human", "tree" ... 
this list goes on and one.
Graham
21-Dec-2006
[6508]
Presumably that is how it is done.  Divide into radicals, and further 
divide radicals into elemental strokes.
Jerry
21-Dec-2006
[6509]
Graham. That's not how it is done. That's why the Chinese TTF file 
is so big, that's why in two chracters with the same radical, their 
radical part are not exactually the same pixel-by-pixel. These is 
a company doing so though. http://www.hifont.com/.
Graham
21-Dec-2006
[6510x2]
but you can add a scaling factor ..
and a direction
Jerry
21-Dec-2006
[6512]
Scaling factor and direction? I am afraid I dont understand what 
you mean. Anyway, I don't really have time to do the font-compression, 
and it's not practical for me for now. I am trying to change my bitmap-based 
text-rendering REBOL/View component to a vector-based one. I hope 
the performance will not cause too much pain. Considering the complexity 
of Chinese font, the rendering performance is what I am worring about.
Cyphre
22-Dec-2006
[6513x3]
Guys, that's exactly the way I have done 'embedded font' in the quick-hack.r 
demo I reffered some time ago when talking about the fonts. Yes it 
is possible to make any kind of font that way. And yes, DRAW is really 
good as a 'optimal storage' of vectorial data ;)
Jerry, I think you can implement own 'bitmap cache' when rendering 
the text usng vectorial glyphs. The performace will be much better 
in that case.
how is the tiger demo done?
 Yes, it's just converted SVG file to DRAW dialect, nothing more.
Geomol
22-Dec-2006
[6516]
Jerry, what about splitting each chinese character up in strokes. 
Each stroke should just be a number of points giving the position 
of the middle of the stroke from one end to the other. Like when 
a person draw the character with a pen. You start each stroke at 
one point, then you move your hand, sometimes fast, sometimes slow, 
until that stroke is finished. Then the next stroke and so on. The 
rendering engine can then calculate the thickness of the stroke at 
any time from the distance from point to point.
Gabriele
22-Dec-2006
[6517x2]
Geomol, you're describing the first version of Knuth's METAFONT :)
afaik it was then changed to just used bezier primitives (like draw) 
instead.
Maxim
22-Dec-2006
[6519x5]
if pieces of the glyphs are the same, then why not just assemble 
them within several draw shapes? and then just draw more than one 
single shape?  the memory tradeoff would be significant, yet the 
speed would likely be almost identical
and there is no "tricks" involved.  no recomputation of the way things 
are drawn.
in any case, a way to automate this is pretty easy IMHO. just do 
drawing and measure the amount of pixels which overlap wrt previously 
defined recurring shapes.  generate a view app which shows the highest 
matches in order and then a simple yes/no to confirm.
in a short amount of time you surely will have a sizeable amount 
of the glyphs reduced to a few recurring shapes!
since draw can reduce words on the fly, this also reduces the actual 
draw blocks used to express the glyphs... again, a sizeable memory 
saver.
Jerry
22-Dec-2006
[6524x3]
Cyphre, the bitmap cache is done. It improves the performance a lot, 
like you said.
Maxim, my idea is just the same as yours. I might just do that after 
what I doing is done.
And even better, I have collected the Chung-Jay code for every Chinese 
character. Chung-Jay can tell us what parts are in a character. I 
plan to use both Chung-Jay code and the pixel-matching method to 
speed up the analysis process.
Graham
22-Dec-2006
[6527x2]
In the VID area widget, what's the right mouse click used for?  Can 
that be used to trigger an action block?
I want to bring up a context sensitive menu
Geomol
23-Dec-2006
[6529x4]
Graham, sure:

view main: layout [b: box 200x200 [b/color: red show b] [append main/pane 
layout [origin 0 box beige "Context Menu"] show main]]
Graham, ups. I didn't notice, you meant AREA.
New version with AREA:

view main: layout [b: area 200x200 feel [engage: func [f a e] [if 
a = 'alt-down [append main/pane layout [origin 0 box beige "Context 
Menu"] show main]]]]
I ruined the AREA engage function. You have to implement the original 
also. The source can be reached with:
layout [a: area]
e: get in a/feel 'engage
source e
Graham
23-Dec-2006
[6533]
Thanks .. I can work with that.
Jerry
23-Dec-2006
[6534x3]
When drawing, I would like to translate the X to 0 and Y to ( Y + 
28 ). What the Matrix should be? Thanks.
I mean using the Matrix command in Draw, like MATRIX [a b c d e f]. 
The Matrix command would premultiply the current transformation matrix 
with the given block. What should I assign this block to translate 
the X to 0 and Y to ( Y + 28 )?
Forget about my previous question, I am not going to use matrix in 
this case.


For rendering cahracter images, I thought that relative-positioning 
could be a good idea. After drawing a character image, then shift 
(translate) to the next position, and the next character would be 
in the right position. So I made my draw block some thing like [ 
image char1-img translate rp1 image char2-img translate rp2 ]


It worked, but the rendering performance was slow, way too slow. 
So I go back to my good old absolute positioning. [ image char1-img 
ap1 image char2-img ap2 ]. No more "translate", no more matrix.