void tower(double r, double h) { int i; double h1, r1, angle, nx, ny, nz; onion(); diff(); cylinder(h, r, r * 0.85); cylinder(h, r * 0.85, r * 0.75); enddiff(); xlate(0, 0, h * 0.95); diff(); onion(); cylinder(h * 0.15, r * 0.85, r * 1.25); xlate(0, 0, h * 0.12); diff(); cylinder(h * 0.15, r * 1.25, r * 1.25); cylinder(h * 0.15 + 1, r * 0.95, r * 0.95); enddiff(); endxlate(); endonion(); xlate(0, 0, 0.25 * h); crenelation(h, r); endxlate(); enddiff(); endxlate(); for (i = 0; i < 5; i++) { angle = (360.0 * rand()) / RAND_MAX * 3.1415927 / 180.0; nx = cos(angle) * r * 0.85; ny = sin(angle) * r * 0.85; nz = 0.25 * h + (percent(55.0) * h); r1 = percent(40.0) * r; h1 = percent(50.0) * h; if (r1 < 5) continue; if (h1 < 20) continue; xlate(nx, ny, nz); tower(r1, h1); endxlate(); } xlate(0, 0, -h / 5.0); cylinder(h / 5.0, r * 0.1, r); endxlate(); endonion(); }
void Phonion::launch(int index) { App* app = _appModel->app(index); QQmlContext* context = app->context(); if (!context) { context = new QQmlContext(_view->engine(), app); } app->launch(context, onion(), _notifier); /* Get the area which contains the app. */ QObject* apparea = _view->rootObject()->findChild<QObject*>("apparea"); /* Use an AppIncubator to prepare component to be injected into apparea. * * A new component is created each time the app is launched but the * context for the app is persistent. */ AppIncubator incubator(qobject_cast<QQuickItem*>(apparea)); QQmlComponent component(_view->engine(), QUrl(app->source())); component.create(incubator, context); _currentAppItem = QSharedPointer<QQuickItem>(qobject_cast<QQuickItem*>(incubator.object())); }
static void renderchar(double x, double y, char *c[]) { int i; double maxx; double px, py; char *p; onion(); py = PIXELHEIGHT * 7; px = 0; xlate(x, y, 0); for (i = 0; c[i] != NULL; i++) { px = 0; for (p = c[i]; *p; p++) { xlate(px, py - (PIXELHEIGHT), 0); xlate(0, -PIXELHEIGHT / 2.0 + 1, 0); square(PIXELWIDTH * 0.25, 1, 1); endxlate(); if (*p == '#') square(PIXELWIDTH * 0.5, PIXELHEIGHT * 0.6, 1); endxlate(); px += PIXELWIDTH; } py -= PIXELHEIGHT; } endxlate(); endonion(); }
/* width is y axis, length is x axis */ static void english_house(double width, double length, double height, double peak) { double wall_thickness = width * 0.1; if (wall_thickness < 5.0) wall_thickness = 5.0; diff(); onion(); gothic_hall(length * 1.05, width, height, 0, 1, wall_thickness, 0); xlate(-length / 2.05, 0, 0); english_house_end(width, height * 1.3, wall_thickness, peak, peak * 1.2); endxlate(); xlate(length / 2.05, 0, 0); english_house_end(width, height * 1.3, wall_thickness, peak, peak * 1.2); endxlate(); xlate(0, 0, height * 1.20); rotate(90, 0, 0, 1); gabled_roof(length, width, peak); endrotate(); endxlate(); endonion(); xlate(0, 0, height * 0.5); gothic_arch_array(length, width * 2, height * 0.60 , length * 0.1, 4); endxlate(); enddiff(); }
static void arched_opening(double height, double width, double depth) { /* make the windows 10x too big, then scale 10x down. This prevents small windows from having bad artifcacts due to openscad's weird curve rendering. Judicious tweaking of $fa, $fn, could probably accomplish the same thing, but this seemed easier to me. */ height *= 10.0; width *= 10.0; depth *= 10.0; scale(0.1, 0.1, 0.1); xlate(-width / 2.0, -depth / 2.0, -height / 2.0); onion(); cube(width, depth, height - width / 2.0, 0); xlate(width / 2.0, depth, height - width / 2.0); rotate(90, 1, 0, 0); cylinder(depth, width / 2.0, width / 2.0); endrotate(); endxlate(); endonion(); endxlate(); endscale(); }
void gothic_arch(double width, double height, double depth) { double radius; double archheight; double cubeheight; if (height < width * 2.0) width = height / 2.0; radius = 5.0 * width / 4.0; archheight = width; cubeheight = height - archheight; xlate(-depth / 2.0, 0, cubeheight); onion(); intersection(); xlate(0, 3.0 * width / 4.0, 0); rotate(90, 0, 1, 0); cylinder(depth, radius, radius); endrotate(); endxlate(); xlate(0, -3.0 * width / 4.0, 0); rotate(90, 0, 1, 0); cylinder(depth, radius, radius); endrotate(); endxlate(); endintersection(); xlate(depth / 2.0, 0, -cubeheight / 2.0); cube(depth, width, cubeheight, 1); endxlate(); endonion(); endxlate(); }
static void make_castle(void) { scale(0.85, 0.85, 0.85); onion(); scale(0.15, 0.15, 0.15); onion(); keep_foundation(350, 200, 150); endonion(); xlate(0, 0, 150); recursive_keep(0, 0, 200, 350, 50, 4); endxlate(); endscale(); enclosure(8, 65.0, 90.0 * HEIGHT_RADIUS); enclosure(6, 38.0, 140.0 * HEIGHT_RADIUS); endonion(); endscale(); }
static void gothic_matrix(double length, double width, double height, int larches, int warches, double border_thickness) { onion(); gothic_arch_array(length, width, height, border_thickness, larches); rotate(90, 0, 0, 1); gothic_arch_array(width, length, height, border_thickness, warches); endrotate(); endonion(); }
static void pointy_tower(double x, double y, double r, double h, int flying, double fa) { double pointiness; pointiness = perturbup(1.4, 0.5); int extra_pointy; /* prevent > 45 degree overhangs to maintain 3d-printability */ if (r > h * 0.20) flying = 0; extra_pointy = (r < h * 0.30 && irandomn(100) < 40); xlate(x, y, 0); /* xlate(0, 0, h * 0.8); */ diff(); onion(); if (flying) { angular_cylinder(h * 0.75, 0.15 * r, 0.15 * r, fa); xlate(0, 0, h * 0.5); angular_cylinder(h * 0.25, 0.10 * r, r * 1.2, fa); xlate(0, 0, h * 0.25); angular_cylinder(1.6 * r, 1.2 * r, r * 1.2, fa); xlate(0, 0, r * 1.6); angular_cylinder(pointiness * r, 1.2 * r, 0, fa); if (extra_pointy) angular_cylinder(pointiness * 2 * r, 0.6 * r, 0, fa); } else { angular_cylinder(h, r, 0.80 * r, fa); xlate(0, 0, h - 0.6 * r); angular_cylinder(0.6 * r, 0.81 * r, r * 1.2, fa); xlate(0, 0, r * 0.6); angular_cylinder(0.6 * r, 1.2 * r, r * 1.2, fa); xlate(0, 0, r * 0.6); angular_cylinder(pointiness * r, 1.2 * r, 0, fa); if (extra_pointy) angular_cylinder(pointiness * 2 * r, 0.6 * r, 0, fa); } endxlate(); endxlate(); endxlate(); endonion(); if (!flying) { add_windows(r, h); } if (!flying) xlate(0, 0, h + 3); else xlate(0, 0, h * 0.85); crenelation(r * 1.2, r * 2); endxlate(); enddiff(); endxlate(); }
void reference(uint8 *map, int w, int h) { int i,j; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { leader[j][i].x = i; leader[j][i].y = j; } } for (j=1; j < h-1; ++j) { for (i=1; i < w-1; ++i) { if (map[j*w+i] == 255) { if (map[(j+1)*w+i] == 255) onion(i,j, i,j+1); if (map[(j)*w+i+1] == 255) onion(i,j, i+1,j); } } } for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { uint32 c = 0xff000000; if (leader[j][i].x == i && leader[j][i].y == j) { if (map[j*w+i] == 255) c = stb_randLCG() | 0xff404040; } color[j][i] = c; } } for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { if (leader[j][i].x != i || leader[j][i].y != j) { point p = find(i,j); color[j][i] = color[p.y][p.x]; } } } }
static void renderstring(double x, double y, char **s[]) { int i; onion(); renderchar(x, y, s[0]); x += PIXELWIDTH; for (i = 1; s[i] != NULL; i++) { renderchar(x, y, s[i]); x += PIXELWIDTH * 8; } endonion(); }
static fancy_roof(double length, double width, double height) { onion(); intersection(); gabled_roof(length, width, height * 3); rotate(90, 0, 0, 1); gabled_roof(width, length, height); endrotate(); endintersection(); crenelated_rectangle(width, length, height * 0.35, height * 0.15, hypot(length, width) * 0.05); endonion(); }
void crenelation(double h, double r) { onion(); cube(r * 0.25, r * 3.0, h * 0.12, 1); rotate(90.0, 0.0, 0.0, 1.0); cube(r * 0.25, r * 3.0, h * 0.12, 1); endrotate(); rotate(45.0, 0.0, 0.0, 1.0); cube(r * 0.25, r * 3.0, h * 0.12, 1); endrotate(); rotate((45.0 + 90.0), 0.0, 0.0, 1.0); cube(r * 0.25, r * 3.0, h * 0.12, 1); endrotate(); endonion(); }
/* width is yaxis, length is xaxis, h=zaxis, angle 0 = vertical, degrees */ static void buttressed_foundation(double width, double length, double height, double buttress_angle, double buttress_interval) { onion(); xlate(0, 0, height / 2.0); cube(length, width, height, 1); endxlate(); buttress_array_pair(length * 0.10, width * 0.2, height, buttress_angle, (length / 5.0) * 0.9, 5, width * 0.85); rotate(90, 0, 0, 1); buttress_array_pair(width * 0.05, length * 0.2, height, buttress_angle, (width / 5.0) * 0.9, 5, length * 0.85); endrotate(); endonion(); }
static void angular_tower(double x, double y, double r, double h, int flying, double fa) { xlate(x, y, 0); /* prevent > 45 degree overhangs to maintain 3d-printability */ if (r > h * 0.20) flying = 0; if (!flying) diff(); onion(); if (flying) { angular_cylinder(h * 0.75, r * 0.15, 0.15 * r, fa); xlate(0, 0, h * 0.50); angular_cylinder(h * 0.25, 0.10 * r, r * 1.2, fa); xlate(0, 0, h * 0.25); diff(); angular_cylinder(1.6 * r, 1.2 * r, r * 1.2, fa); xlate(0, 0, 0.80 * r); angular_cylinder(1.00 * r, 1.0 * r, r * 1.0, fa); xlate(0, 0, 0.7 * r); crenelation(2.3 * r, r * 2.0); endxlate(); } else { angular_cylinder(h, r, 0.80 * r, fa); xlate(0, 0, h - 0.6 * r); angular_cylinder(0.6 * r, 0.81 * r, r * 1.2, fa); xlate(0, 0, r * 0.6); diff(); angular_cylinder(0.6 * r, 1.2 * r, r * 1.2, fa); angular_cylinder(0.75 * r, 1.0 * r, r * 1.0, fa); xlate(0, 0, 0.7 * r); crenelation(2.3 * r, r * 2.0); } endxlate(); enddiff(); endxlate(); endxlate(); endonion(); if (!flying) { add_windows(r, h); enddiff(); } endxlate(); }
static void english_house_end(double width, double wall_height, double wall_thickness, double peak_height, double chimney_height) { rotate(90, 0, 0, 1); onion(); xlate(0, 0, wall_height / 2.0); cube(width, wall_thickness, wall_height, 1); endxlate(); xlate(0, 0, wall_height * 0.999); gabled_roof(wall_thickness, width, peak_height); endxlate(); xlate(0, 0, (wall_height + chimney_height) / 2.0); cube(width * 0.20, wall_thickness, wall_height + chimney_height, 1); endxlate(); endonion(); endrotate(); }
void crenelation(double h, double r) { rotate(360.0 / 16.0, 0, 0, 1); onion(); //cube(r * 0.15, r * 3.0, h * 0.12, 1); arched_opening(h * 0.35, r * 0.15, r * 3.0); rotate(90.0, 0.0, 0.0, 1.0); //cube(r * 0.15, r * 3.0, h * 0.12, 1); arched_opening(h * 0.35, r * 0.15, r * 3.0); endrotate(); rotate(45.0, 0.0, 0.0, 1.0); //cube(r * 0.15, r * 3.0, h * 0.12, 1); arched_opening(h * 0.35, r * 0.15, r * 3.0); endrotate(); rotate((45.0 + 90.0), 0.0, 0.0, 1.0); //cube(r * 0.15, r * 3.0, h * 0.12, 1); arched_opening(h * 0.35, r * 0.15, r * 3.0); endrotate(); endonion(); endrotate(); }