phlsa / gmynd-old

A toolkit that makes creating graphics easy
2 stars 0 forks source link

"Center Mode" for shapes #10

Open bohnacker opened 11 years ago

bohnacker commented 11 years ago

Most times it would be nice to give the position of shape as a coordinate for the center of the shape. Would it be possible to introduce x and y as new "css-properties"?

phlsa commented 11 years ago

Definitely something we should have! In CSS, centering an object around its reference point would be something like margin: -50%. We could introduce a shorthand like centered:true that compiles to this margin. That way, centering would also work with elements positioned relative to the right and/or bottom edges which wouldn't work when using x and y.

bohnacker commented 11 years ago

the centered property works fine for top level objects. But as soon as there are children appended, the result is not as expected. In this example (examples_real_world/Example_01.html) the circles should be in a horizontal line. Is there a way to fix it?

phlsa commented 11 years ago

Hm, you are right. I think the main Problem is that we are positioning everything absolute. That way, adding child elements does not change the size of the container. I currently can't think of a way to to work around this. Maybe we can do something with transforms here, but there are a few other issues with those which we need to solve first.