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

World: r3wp

[View] discuss view related issues

Jerry
20-Dec-2006
[6443x2]
According to the DRAW Document, the shape is closed automatically, 
i.e. as a polygon, unless you specify a move command at the end of 
the shape block. However, the following example is different. why?


view layout [ box 300x300 black effect [draw [anti-alias on pen red 
fill-pen none shape [move 35x12 curve 35x12 line 53x96 curve 53x96 
54x101 57x104 61x104 line 61x108 line 37x108 line 37x104 curve 37x104 
42x104 44x103 44x101 curve 44x101 44x100 44x98 44x97 line 38x72 line 
19x72 line 14x98 line 14x100 curve 14x100 14x102 16x104 20x104 line 
20x108 line 3x108 line 3x104 curve 3x104 7x104 9x102 10x99 line 29x14 
move 20x68 curve 20x68 line 37x68 line 29x29]]]]
Never mind my previous question, I've just realized what was wrong.
Gregg
20-Dec-2006
[6445]
What was it?
Anton
20-Dec-2006
[6446]
Jerry, you can also optimize the line segments a bit by replacing, 
eg:
	line 10x10 line 20x20
with
	line 10x10 20x20
I think this should be more speedy.
Jerry
20-Dec-2006
[6447]
Anton, the shape dialect was generated by my REBOL script. So it's 
not easy to optimize it. I wrote a C# program, which get all the 
glyph data of Chinese characters. I put these data in this format 
: x y type x y type ... where type is the type of the point. My REBOL 
script loads the glyph data, and generates a Shape dialect for every 
character.
Anton
20-Dec-2006
[6448]
>> blk: [line 10x10 line 20x20 curve 20x20 line 30x30 line 40x40]
== [line 10x10 line 20x20 curve 20x20 line 30x30 line 40x40]

>> parse blk [any ['line pair! here: 'line (remove here) :here | 
skip]]
== true
>> blk
== [line 10x10 20x20 curve 20x20 line 30x30 40x40]
Jerry
20-Dec-2006
[6449]
Gregg, there was a MOVE command, that's why. that was my mistake.
Anton
20-Dec-2006
[6450x2]
I look for 'line followed by a pair! and another 'line, then I remove 
the second one.
Actually, here is a better one:
parse blk [any [pos: 'line some pair! here: 'line (remove here) :pos 
| skip]]
Jerry
20-Dec-2006
[6452x3]
Anton, thank you. Maybe I should prevent this situation during the 
code-gen, that could save some time. BTW, according to my observation, 
the situation is not common though. Most Chinese character glyphs 
are extremely complex, it's not frequent to see one LINE command, 
not mention two LINE commands together.
For you to have a taste of how complicated the glyphs of a Chinese 
Character can be, The following example shows the last character 
in my Chinese name. there are 238 CURVE commands and 7 LINE commands.
REBOL[] view layout [ box 128x128 black effect [draw [anti-alias 
on pen white fill-pen white shape [move 32x19 curve 32x19 33x19 34x19 
35x20 curve 35x20 38x22 40x24 40x25 curve 40x25 40x26 39x27 39x28 
curve 39x28 38x29 38x31 37x33 curve 37x33 35x38 32x43 28x50 curve 
28x50 24x58 19x65 14x70 curve 14x70 9x75 6x77 4x77 curve 4x77 3x77 
3x77 3x76 curve 3x76 3x76 3x76 4x75 curve 4x75 8x71 13x64 19x55 curve 
19x55 23x48 26x40 29x33 curve 29x33 30x30 31x26 31x22 curve 31x22 
31x20 31x19 32x19 move 36x27 curve 36x27 36x27 37x27 38x27 curve 
38x27 40x28 43x29 45x30 curve 45x30 48x32 50x33 51x34 curve 51x34 
51x36 52x37 52x38 curve 52x38 52x39 52x40 51x41 curve 51x41 51x42 
50x43 49x43 curve 49x43 49x43 48x42 47x42 curve 47x42 46x41 44x39 
42x36 curve 42x36 40x33 38x31 37x30 curve 37x30 36x29 35x28 35x28 
curve 35x28 35x27 35x27 36x27 move 42x51 curve 42x51 43x51 44x52 
46x52 curve 46x52 48x53 50x54 50x54 curve 50x54 50x55 48x56 46x56 
curve 46x56 44x56 43x57 41x57 curve 41x57 40x57 38x58 33x59 curve 
33x59 31x59 29x59 28x59 curve 28x59 27x59 25x59 24x59 curve 24x59 
23x58 22x58 22x57 curve 22x57 22x56 23x56 26x56 curve 26x56 31x55 
35x53 40x52 curve 40x52 41x52 42x51 42x51 move 44x66 curve 44x66 
45x66 46x66 49x67 curve 49x67 51x67 52x68 52x69 curve 52x69 52x70 
51x70 48x71 curve 48x71 46x71 43x72 42x72 curve 42x72 40x72 36x73 
30x74 curve 30x74 27x75 24x75 23x75 curve 23x75 21x75 20x75 19x75 
curve 19x75 17x74 16x74 16x73 curve 16x73 16x72 17x71 20x71 curve 
20x71 27x70 34x69 41x67 curve 41x67 42x66 44x66 44x66 move 31x57 
curve 31x57 33x57 34x57 37x58 curve 37x58 38x59 39x60 39x61 curve 
39x61 39x61 39x62 39x63 curve 39x63 38x64 38x65 38x66 line 37x96 
line 32x96 line 31x64 curve 31x64 31x63 31x62 30x60 curve 30x60 29x60 
29x59 29x59 curve 29x59 29x58 30x57 31x57 move 18x82 curve 18x82 
18x82 19x82 20x82 curve 20x82 23x83 25x84 26x85 curve 26x85 27x86 
28x87 28x89 curve 28x89 28x92 27x93 25x93 curve 25x93 24x93 23x93 
23x92 curve 23x92 21x91 19x88 17x83 curve 17x83 17x83 16x83 16x82 
curve 16x82 17x82 17x82 18x82 move 46x76 curve 46x76 46x76 48x76 
49x77 curve 49x77 51x79 52x80 52x80 curve 52x80 52x81 52x81 51x81 
curve 51x81 49x83 46x86 42x89 curve 42x89 41x89 41x89 41x89 curve 
41x89 40x89 40x89 40x89 curve 40x89 40x88 40x88 40x88 curve 40x88 
42x86 43x84 43x82 curve 43x82 44x80 45x78 45x76 curve 45x76 46x76 
46x76 46x76 move 10x97 curve 10x97 11x97 12x98 13x98 curve 13x98 
15x98 16x98 16x98 curve 16x98 17x98 19x98 21x97 curve 21x97 33x94 
41x92 45x90 curve 45x90 46x90 47x89 48x89 curve 48x89 50x89 51x90 
51x91 curve 51x91 51x92 50x93 48x94 curve 48x94 35x99 28x101 28x102 
curve 28x102 26x103 23x104 21x105 curve 21x105 20x106 19x107 18x107 
curve 18x107 17x107 15x106 12x104 curve 12x104 10x101 9x100 9x99 
curve 9x99 9x98 9x97 10x97 move 75x12 curve 75x12 75x12 76x12 77x12 
curve 77x12 79x12 81x13 83x14 curve 83x14 86x15 87x16 88x17 curve 
88x17 89x18 89x19 89x20 curve 89x20 89x21 89x23 88x25 curve 88x25 
87x26 86x27 85x27 curve 85x27 84x27 84x27 83x26 curve 83x26 82x25 
81x24 80x21 curve 80x21 78x18 76x16 75x14 curve 75x14 75x14 74x13 
74x13 curve 74x13 74x12 74x12 75x12 move 104x22 curve 104x22 104x22 
106x23 108x23 curve 108x23 110x25 112x26 112x27 curve 112x27 111x28 
110x28 108x29 curve 108x29 101x29 93x29 85x31 curve 85x31 80x31 73x33 
65x35 curve 65x35 63x35 63x35 62x35 curve 62x35 61x35 59x35 57x34 
curve 57x34 55x33 55x32 55x32 curve 55x32 55x31 55x31 57x31 curve 
57x31 73x28 86x26 97x24 curve 97x24 101x23 103x22 104x22 move 59x32 
curve 59x32 59x32 61x32 64x32 curve 64x32 66x33 67x34 67x35 curve 
67x35 66x37 66x38 66x38 curve 66x38 65x54 63x67 61x77 curve 61x77 
59x86 57x93 54x100 curve 54x100 51x106 47x111 44x114 curve 44x114 
43x115 43x115 42x115 curve 42x115 42x115 42x115 42x115 curve 42x115 
45x110 47x104 49x99 curve 49x99 53x89 55x79 57x69 curve 57x69 58x60 
59x50 59x40 curve 59x40 59x39 59x37 58x36 curve 58x36 57x35 57x34 
57x33 curve 57x33 57x33 58x32 59x32 move 102x35 curve 102x35 104x35 
106x36 109x38 curve 109x38 110x39 111x40 111x40 curve 111x40 111x41 
111x42 110x43 curve 110x43 109x44 109x46 108x47 curve 108x47 106x55 
105x59 105x60 curve 105x60 104x63 102x64 101x64 curve 101x64 100x64 
99x63 99x62 curve 99x62 98x61 98x60 98x59 curve 98x59 98x59 98x58 
98x57 curve 98x57 99x56 100x53 100x49 curve 100x49 101x47 101x45 
101x43 curve 101x43 101x42 100x41 99x41 curve 99x41 97x41 95x41 91x42 
curve 91x42 82x44 77x45 75x45 curve 75x45 73x45 72x45 71x44 curve 
71x44 70x44 70x43 70x43 curve 70x43 70x42 71x41 73x41 curve 73x41 
78x41 86x39 97x36 curve 97x36 100x35 102x35 102x35 move 113x46 curve 
113x46 113x46 115x46 117x47 curve 117x47 119x49 121x50 121x51 curve 
121x51 120x52 119x52 117x52 curve 117x52 110x52 103x53 94x54 curve 
94x54 89x54 83x56 75x57 curve 75x57 73x58 72x58 72x58 curve 72x58 
70x58 68x57 67x56 curve 67x56 65x56 64x55 64x54 curve 64x54 64x54 
65x54 66x53 curve 66x53 82x51 96x49 106x47 curve 106x47 110x46 112x46 
113x46 move 99x60 curve 99x60 100x60 101x60 102x61 curve 102x61 104x62 
106x63 106x64 curve 106x64 105x64 104x65 103x65 curve 103x65 98x65 
94x65 88x66 curve 88x66 85x66 81x67 76x68 curve 76x68 75x68 74x68 
74x68 curve 74x68 73x68 72x68 70x67 curve 70x67 69x67 68x66 68x66 
curve 68x66 68x65 69x65 70x65 curve 70x65 80x63 88x62 95x61 curve 
95x61 97x60 99x60 99x60 move 65x75 curve 65x75 66x75 68x75 70x76 
curve 70x76 72x77 73x77 73x78 curve 73x78 73x79 73x79 73x80 curve 
73x80 72x80 72x82 72x84 curve 72x84 72x89 72x94 71x98 curve 71x98 
70x102 69x106 68x109 curve 68x109 66x112 65x114 63x116 curve 63x116 
61x118 60x119 60x119 curve 60x119 60x119 59x118 59x118 curve 59x118 
59x118 59x118 60x117 curve 60x117 61x114 62x111 63x108 curve 63x108 
64x104 65x100 65x96 curve 65x96 66x92 66x88 66x84 curve 66x84 66x81 
66x79 65x78 curve 65x78 64x77 64x77 64x76 curve 64x76 64x75 64x75 
65x75 move 105x70 curve 105x70 105x70 107x71 110x72 curve 110x72 
113x74 114x75 114x76 curve 114x76 114x77 113x77 113x78 curve 113x78 
112x81 111x85 111x92 curve 111x92 111x96 111x99 111x101 curve 111x101 
112x102 112x104 112x106 curve 112x106 112x111 111x115 109x118 curve 
109x118 107x121 105x123 103x123 line 100x111 curve 100x111 101x111 
102x110 103x110 curve 103x110 104x108 105x103 105x96 curve 105x96 
105x91 104x86 104x79 curve 104x79 104x77 104x77 103x76 curve 103x76 
103x76 102x76 101x76 curve 101x76 100x76 97x76 92x77 curve 92x77 
84x78 79x79 75x79 curve 75x79 74x80 73x80 72x80 curve 72x80 71x80 
70x80 69x79 curve 69x79 68x78 68x77 68x77 curve 68x77 68x77 69x76 
70x76 curve 70x76 75x76 82x75 89x74 curve 89x74 94x72 99x71 101x70 
curve 101x70 103x70 105x70 105x70 move 93x109 curve 93x109 93x109 
93x109 94x109 curve 94x109 97x110 99x111 100x111 line 103x123 curve 
103x123 102x123 102x122 101x121 curve 101x121 98x117 96x114 93x111 
curve 93x111 92x110 92x110 92x110 curve 92x110 92x109 92x109 93x109 
move 98x83 curve 98x83 98x83 100x83 102x83 curve 102x83 104x84 105x84 
105x85 curve 105x85 105x86 103x86 101x87 curve 101x87 99x87 97x87 
95x88 curve 95x88 94x88 90x89 84x90 curve 84x90 80x90 78x91 77x91 
curve 77x91 75x91 74x91 73x90 curve 73x90 72x90 71x89 71x89 curve 
71x89 71x88 72x87 74x87 curve 74x87 81x86 88x85 95x83 curve 95x83 
97x83 98x83 98x83 move 97x94 curve 97x94 98x94 99x94 101x94 curve 
101x94 103x95 104x95 104x96 curve 104x96 104x97 103x97 101x98 curve 
101x98 98x98 96x98 94x99 curve 94x99 93x99 89x99 83x100 curve 83x100 
79x101 77x101 75x101 curve 75x101 74x101 73x101 72x101 curve 72x101 
70x100 70x100 70x99 curve 70x99 70x98 71x98 73x98 curve 73x98 80x97 
87x96 94x94 curve 94x94 96x94 97x94 97x94 move 83x32 curve 83x32 
84x32 85x32 88x33 curve 88x33 90x34 91x35 91x36 curve 91x36 91x37 
91x37 90x39 curve 90x39 90x42 89x45 89x49 line 89x90 curve 89x90 
89x98 88x105 87x111 curve 87x111 86x115 86x117 85x117 curve 85x117 
84x117 83x116 83x113 curve 83x113 83x108 83x102 83x94 line 83x43 
curve 83x43 83x40 82x37 82x35 curve 82x35 81x34 81x33 81x33 curve 
81x33 81x32 82x32 83x32]]]]
Maxim
21-Dec-2006
[6455]
wow ! makes a nice glyph output though.   so this equates to  "Tsai" 
 ?
james_nak
21-Dec-2006
[6456]
That's cool!
Gregg
21-Dec-2006
[6457]
Wow, indeed! That's very cool Jerry.
Maxim
21-Dec-2006
[6458]
I immediately saw a very easy way to condense all of that for in 
ram memory reduction... I'd use a dialect to convert to/from binary 
byte code... it would greatly compress the data... probably a 5 to 
1 ratio !
Henrik
21-Dec-2006
[6459]
what about storing differences instead of absolute coordinates?
Maxim
21-Dec-2006
[6460x2]
I don't that is even needed.
since all values are within one byte.
Henrik
21-Dec-2006
[6462]
it could probably be done, but it's not worth it without slowing 
it down a lot. I wonder how coords are stored in fonts normally.
Maxim
21-Dec-2006
[6463]
that depends how much ram he is using... at some point the GC slows 
down soooo much that speed exponentially decreases.
Henrik
21-Dec-2006
[6464]
I wasn't following how the data block is generated. was that with 
a C# program?
Maxim
21-Dec-2006
[6465]
Anton, the shape dialect was generated by my REBOL script. So it's 
not easy to optimize it. I wrote a C# program, which get all the 
glyph data of Chinese characters. I put these data in this format 
: x y type x y type ... where type is the type of the point. My REBOL 
script loads the glyph data, and generates a Shape dialect for every 
character.
Geomol
21-Dec-2006
[6466]
Chinese! :-) Cool! To better see the character, you can make it larger 
with this:

view layout [
	box 4 * 128x128 black effect [draw [
	scale 4.0 4.0
	anti-alias on
... followed by the rest of Jerry's program.
Henrik
21-Dec-2006
[6467]
is it possible to use any drawing this way and not only kanji/chinese 
chars?
Geomol
21-Dec-2006
[6468]
Someone should train a neural network to make calligraphy, then the 
chinese chars could maybe be made with less information.
Maxim
21-Dec-2006
[6469x2]
eeek  I'm affraid of the amount of neurons needed for such an endeavour 
especially since it would need one output for each pixel...   :-)
probably after a few years of training... it would be able to actually 
draw something ;-)
Henrik
21-Dec-2006
[6471]
I'm always thinking in generalization, creating an easy way to import 
vector drawings in rebol.
Geomol
21-Dec-2006
[6472x3]
Henrik, if info about points or whatever the drawing is made of is 
available, then I see no problem. (If I understand you correctly.)
Clipart is a good example.
What data format is used for clipart? An importer to DRAW dialect 
shouldn't be too big a problem, if the format is easily read.
Henrik
21-Dec-2006
[6475]
yes! I've always wanted to see all that kitchy clipart available 
to Windows users since Windows 3.1...
Geomol
21-Dec-2006
[6476]
There is probably a lot stored in SVG (Scalable Vector Graphics) 
format. There's been talk about that format around here, I think.
Henrik
21-Dec-2006
[6477]
would be nice to integrate this into postscript.r (wink wink) :-)
Geomol
21-Dec-2006
[6478]
yeah! :-)
Maxim
21-Dec-2006
[6479x5]
here is a draw glyph compressor  :-)

rule: [
	any[
		[copy val pair! (
			val: first val
			bignum: max bignum max val/x val/y
			append bin to-binary to-char val/x
			append bin to-binary to-char val/y
		)] |

  [copy val word! (append bin select [curve #{81} line #{82} move #{83}] 
  val )]
	]
]
the above glyph takes up 2223 bytes
oops... forgot to remove bignum check...
rule: [
	any[
		[copy val pair! (
			val: first val
			append bin to-binary to-char val/x
			append bin to-binary to-char val/y
		)] |

  [copy val word! (append bin select [curve #{81} line #{82} move #{83}] 
  val )]
	]
]
to use it:

bin: copy #{}
parse draw-shape-block rule
Geomol
21-Dec-2006
[6484x2]
W3C link to this from their SVG page: http://openclipart.org/cchost/

so there's a lot of clipart in SVG format, I guess. SVG uses XML, 
so it should be easy to import using my RebXML packet. Problem is 
to figure out content  of the format.
Hmm, it seems to be a large format, so it's not a week-end project: 
http://www.w3.org/TR/SVG11/
Henrik
21-Dec-2006
[6486]
isn't shadwolf working on something?
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!?