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

World: r3wp

[AGG] to discus new Rebol/View with AGG

Cyphre
18-May-2006
[801x3]
view layout [
	origin 0
	bx: box 400x400 black effect [
		draw [
			translate 0x400
			scale 1 -1
			pen red
			line 50x50 350x50
			pen blue
			line 50x50 50x350
			pen yellow
			line 50x50 100x200 200x150 300x250 350x225
		]
	]
]
but this won't work with text though because it would be reversed 
in Y axis too.
Another solution is to apply own translation function on the dialect 
block or generate the dialect block with translated coords from scratch. 
(this shouldn't be a rocket science and would work with text too)
Volker
18-May-2006
[804x3]
Regarding text, maybe Graham is right and a graphics-only reverse 
would help? for diagrams. The current way is a bit complicated, until 
one gets the trick.
means "apply own translation function on the dialect block". And 
now that little reversion-math, y: high - y .
now -> know
Pekr
18-May-2006
[807]
that would require one step above parser to draw dialect, no?
Cyphre
19-May-2006
[808x2]
It's really easy:
translate-draw: func [
	height [integer!]
	blk [block!]
	/local dr p
][

 parse blk [some ['draw set dr block! (parse dr [some [p: pair! (p/1: 
 as-pair p/1/x height - p/1/y) | skip]]) | skip]]
	blk
]

view layout [
	origin 0
	bx: box 400x400 black effect translate-draw 400 [
		draw [
			pen red
			line 50x50 350x50
			pen blue
			line 50x50 50x350
			pen yellow
			line 50x50 100x200 200x150 300x250 350x225
			pen white
			text aliased 10x350 "Y axis"
			text aliased 320x40 "X axis"
		]
	]
]
Volker
19-May-2006
[810]
Looks like magic :) But should not be required to draw a line through 
some data?
Graham
5-Jun-2006
[811x2]
rotate says it sets the clockwise rotation for draw commands.
So, why does the text move across the page ?

view/new layout [
		b: box 400x400 black effect [ draw []]
]

for i 0 90 5 [

 b/effect: compose/deep [ draw [ rotate (i) text vectorial "This is 
 a string of text 1" 300x75 ]]
	show b
	wait .2
]
Henrik
5-Jun-2006
[813]
because the text rotates around 0x0 rather than around itself
Graham
5-Jun-2006
[814]
should this be changed?
Henrik
5-Jun-2006
[815x2]
which is what I figured you wanted to do. you need to make the text 
at 0x0, rotate it and then translate it to the position you want
e.g. translate 100x100 rotate 30 text "something"
Graham
5-Jun-2006
[817]
or set up a straight line "spline" for the text ...
Henrik
5-Jun-2006
[818]
possibly
Graham
5-Jun-2006
[819]
Well, seems to me it should be changed.
Henrik
5-Jun-2006
[820]
changed in AGG or in the code?
Graham
5-Jun-2006
[821x5]
Text should rotate at the point where it is being drawn
in AGG.
boxes don't rotate around 0x0
why should text?
or do they ??
Henrik
5-Jun-2006
[826x2]
well, if you did that, how would you rotate around another point? 
I won't argue for one solution or the other, but this approach seems 
natural enough to me.
I think they do
Graham
5-Jun-2006
[828]
which approach?
Henrik
5-Jun-2006
[829x3]
1. first you draw
2. then you rotate
3. then you translate

in classic REBOL order
which means start at 3. :-)
speaking of which, it could be fun to see a LOGO like dialect for 
DRAW. fun for the kids.
Graham
5-Jun-2006
[832]
Gregg has one.
Henrik
5-Jun-2006
[833]
that's good. I don't have to do it then.
Graham
5-Jun-2006
[834]
do you have to create the kids first?
Henrik
5-Jun-2006
[835]
got plenty of those around, not mine though. I don't know how interested 
they would be in it yet. I spent countless hours in COMAL80 when 
I was a kid drawing with the "turtle".
Graham
5-Jun-2006
[836x2]
Comal80 - a Danish product?
I remember I had a Comal80 interpreter for my C64.
Henrik
5-Jun-2006
[838x3]
I don't remember what it was. I think it was for several platforms 
but I used it for my C64.
I think it was a great drawing tool. very straight forward approach 
to drawing.
then I got an Amiga and was exposed to the horror that was Amiga 
Basic.
Graham
5-Jun-2006
[841x3]
I've got my graphing utility written now in my postscript dialect
just labelling the y-axis is a problem because of the way AGG does 
the rotate vs PostScript rotate command
and there's no way to save a graphic state in AGG.
Henrik
5-Jun-2006
[844]
ah, yeah that could be a problem
Anton
5-Jun-2006
[845x4]
Graham, AGG rotation: that's just an effect of the way AGG does its 
transformations which apply to the whole image. The rotate command 
is just a shortcut method of specifying just the rotation angle of 
a transformation.
transform (origin) (angle) (scale-x) (scale-y) (translate)
What you want to do is set the origin to the centre of your object, 
then change the angle and translate as you wish.
I agree that it is a bit uncomfortable at first. I was also expecting 
something simpler like in flash, but I suppose this way is more powerful.
Cyphre
5-Jun-2006
[849x2]
Anton is right. DRAW works on lower level than FACE so there is only 
one tranformation matrix per DRAW block (ie. it is applied on all 
rendered primitives). OTOH you have relatively wide range of commands 
how to control the transformation matrix or even use the mtrick stack 
to push/pop different trnasformation states to apply  nested transfromations.
(Note that due this lower-level approach the drawing is also faster.)