summaryrefslogtreecommitdiff
path: root/legacy/ephysics/doc
diff options
context:
space:
mode:
authorRicardo de Almeida Gonzaga <ricardo@profusion.mobi>2012-10-04 22:37:40 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-10-04 22:37:40 +0000
commitfcea4e820ac852c56f3a289c27f4f12215682734 (patch)
treee96ca97a796e95225bbc59404e058ed5fb91833c /legacy/ephysics/doc
parentbd9c06c5f57ff4b816cecdef9531cb86b93abd69 (diff)
ephysics: add a new example doc: EPhysics Logo -
ephysics_logo.c Patch by: Ricardo de Almeida Gonzaga <ricardo@profusion.mobi> SVN revision: 77451
Diffstat (limited to 'legacy/ephysics/doc')
-rw-r--r--legacy/ephysics/doc/examples.dox187
1 files changed, 187 insertions, 0 deletions
diff --git a/legacy/ephysics/doc/examples.dox b/legacy/ephysics/doc/examples.dox
index 7b7693bf57..03c59cc926 100644
--- a/legacy/ephysics/doc/examples.dox
+++ b/legacy/ephysics/doc/examples.dox
@@ -14,6 +14,7 @@
14 * @li @ref tutorial_ephysics_forces 14 * @li @ref tutorial_ephysics_forces
15 * @li @ref tutorial_ephysics_growing_balls 15 * @li @ref tutorial_ephysics_growing_balls
16 * @li @ref tutorial_ephysics_gravity 16 * @li @ref tutorial_ephysics_gravity
17 * @li @ref tutorial_ephysics_logo
17 * @li @ref tutorial_ephysics_rotating_forever 18 * @li @ref tutorial_ephysics_rotating_forever
18 * @li @ref tutorial_ephysics_velocity 19 * @li @ref tutorial_ephysics_velocity
19 * @li @ref tutorial_ephysics_shapes 20 * @li @ref tutorial_ephysics_shapes
@@ -1096,6 +1097,192 @@
1096 * @example test_no_gravity.c 1097 * @example test_no_gravity.c
1097 */ 1098 */
1098 1099
1100/**
1101 * @page tutorial_ephysics_logo EPhysics - Logo
1102 *
1103 * The purpose of this example is to demonstrate the EPhysics_Logo.
1104 *
1105 * For this example we'll have an EPhysics_World.
1106 *
1107 * The basic concepts like - initializing an EPhysics_World, render geometry,
1108 * physics limiting boundaries, were already covered in
1109 * @ref tutorial_ephysics_bouncing_ball
1110 *
1111 * @section add-logostruct Logo Data Struct
1112 * @dontinclude ephysics_logo.c
1113 *
1114 * While in this example we'll be working with a struct to hold some objects
1115 * in our code. For clarity sake we present you the struct declaration in the
1116 * following block.
1117 *
1118 * @skip struct letter_desc {
1119 * @until };
1120 *
1121 * @section add-lett Adding the letters
1122 * @dontinclude ephysics_logo.c
1123 *
1124 * To add the letters we'll use this function that creates the shadow, light
1125 * and letter images.
1126 *
1127 * @skip _letter_add(Evas *evas
1128 * @until }
1129 *
1130 * In this loop we'll use the function letter_add using the falling_letters
1131 * declared in logo data struct.
1132 *
1133 * @skip for (i = 0; i < EINA_C_ARRAY
1134 * @until (image, &w, &h);
1135 *
1136 * Place image and light on top, above what the viewport can show, to fall
1137 * later on.
1138 *
1139 * @skip evas_object_move(image, x,
1140 * @until evas_object_move(light, x, -h * (i + 1) - 50);
1141 *
1142 * Place shadow below the hit-line: FLOOR_Y, centered at image.
1143 *
1144 * @skipline evas_object_move(shadow, x + CENTER(w, sh_w
1145 *
1146 * Here we set the letters padding and add letter body using the function
1147 * below and setting its friction.
1148 *
1149 * @skip x += falling_letters[i].padd
1150 * @until }
1151 *
1152 * Here we call another function that will be common to the circle body as
1153 * well, note that we add a callback that will be explained later.
1154 * @dontinclude ephysics_logo.c
1155 *
1156 * @skip _letter_body_box_add(EPhysics_World *world
1157 * @until }
1158 *
1159 * This function is used to create the body setting its properties. Note that
1160 * we disable the rotation on Z axis to this letters don't tilt or recline.
1161 * @dontinclude ephysics_logo.c
1162 *
1163 * @skip _letter_body_setup_common(EPhysics_Body *body
1164 * @until }
1165 *
1166 * In this callback function that we added to our letter body we'll update its
1167 * light and shadow.
1168 *
1169 * First we'll update the body, get its image geometry and set the floor
1170 * distance based on images height.
1171 *
1172 * @dontinclude ephysics_logo.c
1173 *
1174 * @skip _update_box_cb(void *data
1175 * @until floor_distance = FLOOR_Y - h;
1176 *
1177 * As long as the letter approaches the floor, its shadow is darker, with bigger y.
1178 *
1179 * @skip if (y > SH_THRESHOLD)
1180 * @until &sh_h);
1181 * @skipline alpha = 255 * (y - SH_THRESHOLD)
1182 *
1183 * And with bigger x -- its proportional to x / WIDTH, but varies from 100 to
1184 * 255
1185 *
1186 * @skip pos_x = (double) x /
1187 * @until PROP_GET(pos_x, 100, 255);
1188 *
1189 * Note that the box shadow is not resized, just moved. And here set also the
1190 * colors.
1191 *
1192 * @skip evas_object_move(shadow, x +
1193 * @until alpha, alpha);
1194 *
1195 * As long as the letter approaches the floor, its lighter, with bigger x and y.
1196 *
1197 * @skipline evas_object_move(light, x
1198 * @skipline alpha = (y <= 0) ? 0 : y * 255
1199 * @skip alpha = alpha * (x - OFFSET_X + 80)
1200 * @until }
1201 *
1202 * @section add-lettere Adding the letter E
1203 *
1204 * Here we'll add the last letter, "E" is a circle that comes rolling on
1205 * the floor.
1206 *
1207 * First we use the letter_add function, set its shadow color and get
1208 * its sizes.
1209 *
1210 * @skip _letter_add(evas, "E", &image
1211 * @until evas_object_image_size_get(image, &w, &h);
1212 *
1213 * Place image and light above the floor and to the left of viewport, to comes
1214 * rolling later on.
1215 *
1216 * @skip evas_object_move(image, -w - 1, FLOOR_Y
1217 * @until evas_object_move(light, -w - 1, FLOOR_Y - h + 1);
1218 *
1219 * Place the shadow below the hit-line: FLOOR_Y centered at image.
1220 *
1221 * @skipline evas_object_move(shadow, -w - 1 + CENTER(w, sh_w)
1222 *
1223 * Here we create the body using body_circle function and enable its rotation
1224 * on Z axis.
1225 *
1226 * @skip letter_body = _letter_body_circle_add
1227 * @until letter_body, EINA_TRUE);
1228 *
1229 * Make the "E" logo get into the viewport by applying a horizontal force.
1230 *
1231 * @skipline ephysics_body_central_impulse_apply(letter_body
1232 *
1233 * Here we use the letter_body_setup_common to create the body and set its
1234 * properties, note that we add a callback that will be explained below.
1235 * @dontinclude ephysics_logo.c
1236 *
1237 * @skip _letter_body_circle_add(EPhysics_World *world
1238 * @until }
1239 *
1240 * In this callback function that we added to our "E" letter body we'll update
1241 * its light and shadow.
1242 *
1243 * First we'll update the body and get its image geometry.
1244 *
1245 * @dontinclude ephysics_logo.c
1246 *
1247 * @skip _update_circle_cb(void *data
1248 * @until geometry_get(image, &x, &y, &w, &h);
1249 *
1250 * As long as the letter approaches the floor, its lighter, with bigger x.
1251 *
1252 * @skip evas_object_move(light, x
1253 * @until alpha, alpha);
1254 *
1255 * Use the same map from image to the light (rotate it).
1256 *
1257 * @skip map = evas_object_map_get(image
1258 * @until light, EINA_TRUE);
1259 *
1260 * As long as the letter approaches the floor, its shadow is darker, with
1261 * bigger y.
1262 *
1263 * @skip evas_object_image_size_get(shadow,
1264 * @until alpha, alpha);
1265 *
1266 * When the letter "E" passes the viewport, we send it to the begin again to
1267 * collide with the other letters.
1268 *
1269 * @skip if (x > E_THRESHOLD)
1270 * @until }
1271 *
1272 * Here we finish the example. The full source code can be found at
1273 * @ref ephysics_logo_c.
1274 *
1275 */
1276
1277 /**
1278 * @page ephysics_logo_c ephysics_logo.c
1279 *
1280 * @section ephysics-logo-c ephysics_logo.c
1281 * @include ephysics_logo.c
1282 *
1283 * @example ephysics_logo.c
1284 */
1285
1099 /** 1286 /**
1100 * @page tutorial_ephysics_rotating_forever EPhysics - Rotating Forever 1287 * @page tutorial_ephysics_rotating_forever EPhysics - Rotating Forever
1101 * 1288 *