/* * Copyright (c) 2024 Ross Cunniff * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ using namespace oadl; #include "libstd.oah" const nCirc = 150; const rad = 12.0; proc main() { var ang, x, y; var i, j, n; var pic; using math::PI, math::floor, math::sin, math::cos; // Go for the full circle from 0 to 2*PI ang = 2*PI*nCirc.iterate() / nCirc; // Calculate col and row x = Int(floor(0.5 + rad * (1.0 + sin(ang)))); y = Int(floor(0.5 + rad * (1.0 + cos(ang)))); // Allocate our picture n = 2*Int(rad) + 1; pic = new Array(n); // And its rows - initializing them to spaces for (i = 0; i < n; i++) { pic[i] = new String(2*n); for (j = 0; j < 2*n; j++) { pic[i][j] = ' '; } } // Now draw the circle with asterisks for (i = 0; i < nCirc; i += 1) { pic[y[i]][2*x[i]] = '*'; } // Print out our pretty circle say(std::tolower("HERE IS A PRETTY CIRCLE\n")); for (i = 0; i < pic.length(); i++) { say(pic[i], "\n"); } }