Discussion:
Placement from center
Stuart Axon
2010-10-15 23:45:27 UTC
Permalink
The two transform modes we have are well and good, but it would be really useful
to have a placement mode that works like opengl, centered around the current
position.

This would mean that the following would place a large circle, with a small
circle centered on it:

fill(0.4)
ellipse(0, 0, 100, 100)
fill(0, 0, 0.4)
ellipse(0, 0, 50, 50)

I'd propose one of these to activate it:

placement(mode=CENTER)
transform(placement=CENTER)


Make sense ?
(Maybe I'm missing something here, but drawing from the center seems a bit
tricky right now)

Maybe I should make a new shoebot grammar to add the placement command though as
it's not strictly nodebox any more.

S++
Sebastian Oliva
2010-10-24 00:12:40 UTC
Permalink
Post by Stuart Axon
The two transform modes we have are well and good, but it would be really useful
to have a placement mode that works like opengl, centered around the current
position.
This would mean that the following would place a large circle, with a small
   fill(0.4)
   ellipse(0, 0, 100, 100)
   fill(0, 0, 0.4)
   ellipse(0, 0, 50, 50)
placement(mode=CENTER)
transform(placement=CENTER)
Make sense ?
(Maybe I'm missing something here, but drawing from the center seems a bit
tricky right now)
Maybe I should make a new shoebot grammar to add the placement command though as
it's not strictly nodebox any more.
 S++
I think that could only work for Ovals and Squares, how can you draw a
path from "the center"; an easier implementation would be to enhance
the Oval or Square function to draw from the center.
Stuart Axon
2010-10-24 16:14:20 UTC
Permalink
Sent: Sun, October 24, 2010 12:12:40 AM
Subject: Re: [shoebot-devel] Placement from center
The two transform modes we have are well and good, but it would be really
useful
to have a placement mode that works like opengl, centered around the
current
position.
This would mean that the following would place a large circle, with a small
fill(0.4)
ellipse(0, 0, 100, 100)
fill(0, 0, 0.4)
ellipse(0, 0, 50, 50)
placement(mode=CENTER)
transform(placement=CENTER)
Make sense ?
(Maybe I'm missing something here, but drawing from the center seems a bit
tricky right now)
Maybe I should make a new shoebot grammar to add the placement command
though as
it's not strictly nodebox any more.
S++
I think that could only work for Ovals and Squares, how can you draw a
path from "the center"; an easier implementation would be to enhance
the Oval or Square function to draw from the center.
Centering already occurs in bezier path - their just re transformed so that
were based around the corner:

# Go to initial point (CORNER or CENTER):
transform = self._call_transform_mode(self._transform)

# Change the origin if nessacary
if self._get_pathmode() == CENTER:
xc, yc = self._get_center()
transform.translate(-xc, -yc)

The new parameter would probably affect the 2nd of these ifs. The tricky bit
might be how the different CENTER/CORNER stuff interacts and whether it
makes sense.
_______________________________________________
Shoebot-devel mailing list
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
ricardo lafuente
2010-10-24 16:22:40 UTC
Permalink
Post by Stuart Axon
The two transform modes we have are well and good, but it would be really useful
to have a placement mode that works like opengl, centered around the current
position.
This would mean that the following would place a large circle, with a small
fill(0.4)
ellipse(0, 0, 100, 100)
fill(0, 0, 0.4)
ellipse(0, 0, 50, 50)
placement(mode=CENTER)
transform(placement=CENTER)
Make sense ?
(Maybe I'm missing something here, but drawing from the center seems a bit
tricky right now)
Maybe I should make a new shoebot grammar to add the placement command though as
it's not strictly nodebox any more.
This sounds like it could be solved with functions similar to
Processing's rectMode() and ellipseMode(), see:
http://processing.org/reference/ellipseMode_.html
http://processing.org/reference/rectMode_.html

IIRC, i think Shoebot 0.3b has rectmode implemented.
I'm okay with adding this to the Shoebot grammar (+1 for keeping
separate from Nodebox), but this issue can also be dealt with with a few
translate() calls. I wonder what would be best: having the placement()
function, or a HOWTO on the docs on how to create paths originating from
the center.
Stuart Axon
2010-10-24 16:31:09 UTC
Permalink
Sent: Sun, October 24, 2010 4:22:40 PM
Subject: Re: [shoebot-devel] Placement from center
The two transform modes we have are well and good, but it would be really
useful
to have a placement mode that works like opengl, centered around the
current
position.
This would mean that the following would place a large circle, with a small
fill(0.4)
ellipse(0, 0, 100, 100)
fill(0, 0, 0.4)
ellipse(0, 0, 50, 50)
placement(mode=CENTER)
transform(placement=CENTER)
Make sense ?
(Maybe I'm missing something here, but drawing from the center seems a bit
tricky right now)
Maybe I should make a new shoebot grammar to add the placement command
though as
it's not strictly nodebox any more.
This sounds like it could be solved with functions similar to
http://processing.org/reference/ellipseMode_.html
http://processing.org/reference/rectMode_.html
how about just pathMode() ?
- Seems like it could be more general, and the name is probably
better than placement I came up with.
IIRC, i think Shoebot 0.3b has rectmode implemented.
I'm okay with adding this to the Shoebot grammar (+1 for keeping
separate from Nodebox), but this issue can also be dealt with with a few
translate() calls. I wonder what would be best: having the placement()
function, or a HOWTO on the docs on how to create paths originating from
the center.
_______________________________________________
Shoebot-devel mailing list
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
Stuart Axon
2010-10-24 16:35:51 UTC
Permalink
Sent: Sun, October 24, 2010 4:31:09 PM
Subject: Re: [shoebot-devel] Placement from center
Sent: Sun, October 24, 2010 4:22:40 PM
Subject: Re: [shoebot-devel] Placement from center
The two transform modes we have are well and good, but it would be really
useful
to have a placement mode that works like opengl, centered around the
current
position.
This would mean that the following would place a large circle, with a
small
fill(0.4)
ellipse(0, 0, 100, 100)
fill(0, 0, 0.4)
ellipse(0, 0, 50, 50)
placement(mode=CENTER)
transform(placement=CENTER)
Make sense ?
(Maybe I'm missing something here, but drawing from the center seems a
bit
tricky right now)
Maybe I should make a new shoebot grammar to add the placement command
though as
it's not strictly nodebox any more.
This sounds like it could be solved with functions similar to
http://processing.org/reference/ellipseMode_.html
http://processing.org/reference/rectMode_.html
how about just pathMode() ?
- Seems like it could be more general, and the name is probably
better than placement I came up with.
Thinking about it maybe pathMode CENTER would imply mode CENTER ?
IIRC, i think Shoebot 0.3b has rectmode implemented.
I'm okay with adding this to the Shoebot grammar (+1 for keeping
separate from Nodebox), but this issue can also be dealt with with a few
translate() calls. I wonder what would be best: having the placement()
function, or a HOWTO on the docs on how to create paths originating from
the center.
_______________________________________________
Shoebot-devel mailing list
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
_______________________________________________
Shoebot-devel mailing list
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
ricardo lafuente
2010-10-24 17:16:05 UTC
Permalink
Post by Stuart Axon
how about just pathMode() ?
- Seems like it could be more general, and the name is probably
better than placement I came up with.
True, but how would rectmode/ellipsemode be adapted to bezier paths in
general?

Would this mean that the coords end up being relative to a center? I'm
still trying to wrap my head around this.

I think i mixed up two different concepts by relating your proposal to
Processing's rectMode/ellipsemode. Recapping:

rectMode and ellipseMode set what arguments rect() and ellipse() should
expect:
- CORNER (default): (x, y, width, height)
with (x, y) being the absolute coords of the top-left corner, unless you
use negative values for with and/or height -- e.g. with negative width
and height, (x,y) ends up being the bottom-left corner).
- CENTER: (cx, cy, width, height)
with (cx, cy) being the absolute coords of the CENTER of the
rectangle/ellipse. Width and height work the same as above.
- CORNERS: (x1, y1, x2, y2)
with (x1, y1) being the absolute coords of a corner, and (x2, y2) the
coords of the opposite corner.

On the other hand, your placement() concept would be more useful to
place paths relative to another point, if i understood correctly. This
can be easily achieved with translate(), isn't that so?
Since i'm unacquainted with OpenGL nitty-gritty, i'm not sure i got it,
so apologies in advance if this confusion is my fault.
Post by Stuart Axon
Thinking about it maybe pathMode CENTER would imply mode CENTER ?
You mean transformmode CENTER?

Loading...