public static function runserver($command) { array_shift($command); array_shift($command); $cmd_string = implode(':', $command); $regex = "/^([a-zA-Z_][a-zA-Z0-9_]*[a-zA-Z0-9])\$/"; if (preg_match_all($regex, $cmd_string, $regex_output)) { $project = $regex_output[0][0]; if (file_exists('dist/' . $project)) { fwrite(STDOUT, "[2J"); fwrite(STDOUT, Color::BOLD_GREEN . '[RUNNING PROJECT]: ' . $project . Color::RESET . PHP_EOL); fwrite(STDOUT, "url-> " . Color::UNDERLINE_BLUE . "http://localhost:9000" . Color::RESET . PHP_EOL); fwrite(STDOUT, Drawing::SUCCESS_BOX('Stirlingframe->Run server:', "# Project `{$project}` is running", "# Press Ctrl + c to stop running")); fwrite(STDOUT, PHP_EOL); chdir('dist/' . $project); // exec("open http://localhost:9000"); exec('php -S localhost:9000'); } else { fwrite(STDOUT, "[2J"); $header = 'Stirlingframe run error:'; $desc = '# Project `' . $project . '` not exist'; fwrite(STDOUT, Color::BOLD_RED . '[ERROR]: unable to run project.' . Color::RESET . PHP_EOL); fwrite(STDOUT, Drawing::ERROR_BOX($header, $desc)); fwrite(STDOUT, PHP_EOL); } } }
public function run() { DB::table('drawings')->delete(); Drawing::create(array('user_id' => 1, 'original_user_id' => 1, 'img_thumb' => 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNDIiIGhlaWdodD0iMjAwIj48cmVjdCB3aWR0aD0iMjQyIiBoZWlnaHQ9IjIwMCIgZmlsbD0iI2VlZSIvPjx0ZXh0IHRleHQtYW5jaG9yPSJtaWRkbGUiIHg9IjEyMSIgeT0iMTAwIiBzdHlsZT0iZmlsbDojYWFhO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1zaXplOjE1cHg7Zm9udC1mYW1pbHk6QXJpYWwsSGVsdmV0aWNhLHNhbnMtc2VyaWY7ZG9taW5hbnQtYmFzZWxpbmU6Y2VudHJhbCI+MjQyeDIwMDwvdGV4dD48L3N2Zz4=', 'name' => 'test')); Drawing::create(array('user_id' => 1, 'original_user_id' => 1, 'img_thumb' => 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNDIiIGhlaWdodD0iMjAwIj48cmVjdCB3aWR0aD0iMjQyIiBoZWlnaHQ9IjIwMCIgZmlsbD0iI2VlZSIvPjx0ZXh0IHRleHQtYW5jaG9yPSJtaWRkbGUiIHg9IjEyMSIgeT0iMTAwIiBzdHlsZT0iZmlsbDojYWFhO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1zaXplOjE1cHg7Zm9udC1mYW1pbHk6QXJpYWwsSGVsdmV0aWNhLHNhbnMtc2VyaWY7ZG9taW5hbnQtYmFzZWxpbmU6Y2VudHJhbCI+MjQyeDIwMDwvdGV4dD48L3N2Zz4=', 'name' => 'test')); Drawing::create(array('user_id' => 1, 'original_user_id' => 1, 'img_thumb' => 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNDIiIGhlaWdodD0iMjAwIj48cmVjdCB3aWR0aD0iMjQyIiBoZWlnaHQ9IjIwMCIgZmlsbD0iI2VlZSIvPjx0ZXh0IHRleHQtYW5jaG9yPSJtaWRkbGUiIHg9IjEyMSIgeT0iMTAwIiBzdHlsZT0iZmlsbDojYWFhO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1zaXplOjE1cHg7Zm9udC1mYW1pbHk6QXJpYWwsSGVsdmV0aWNhLHNhbnMtc2VyaWY7ZG9taW5hbnQtYmFzZWxpbmU6Y2VudHJhbCI+MjQyeDIwMDwvdGV4dD48L3N2Zz4=', 'name' => 'test')); Drawing::create(array('user_id' => 1, 'original_user_id' => 1, 'img_thumb' => 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNDIiIGhlaWdodD0iMjAwIj48cmVjdCB3aWR0aD0iMjQyIiBoZWlnaHQ9IjIwMCIgZmlsbD0iI2VlZSIvPjx0ZXh0IHRleHQtYW5jaG9yPSJtaWRkbGUiIHg9IjEyMSIgeT0iMTAwIiBzdHlsZT0iZmlsbDojYWFhO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1zaXplOjE1cHg7Zm9udC1mYW1pbHk6QXJpYWwsSGVsdmV0aWNhLHNhbnMtc2VyaWY7ZG9taW5hbnQtYmFzZWxpbmU6Y2VudHJhbCI+MjQyeDIwMDwvdGV4dD48L3N2Zz4=', 'name' => 'test')); Drawing::create(array('user_id' => 1, 'original_user_id' => 1, 'img_thumb' => 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNDIiIGhlaWdodD0iMjAwIj48cmVjdCB3aWR0aD0iMjQyIiBoZWlnaHQ9IjIwMCIgZmlsbD0iI2VlZSIvPjx0ZXh0IHRleHQtYW5jaG9yPSJtaWRkbGUiIHg9IjEyMSIgeT0iMTAwIiBzdHlsZT0iZmlsbDojYWFhO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1zaXplOjE1cHg7Zm9udC1mYW1pbHk6QXJpYWwsSGVsdmV0aWNhLHNhbnMtc2VyaWY7ZG9taW5hbnQtYmFzZWxpbmU6Y2VudHJhbCI+MjQyeDIwMDwvdGV4dD48L3N2Zz4=', 'name' => 'test')); }
public static function delete($command) { array_shift($command); array_shift($command); $cmd_string = implode(':', $command); if (preg_match_all("/^(project|app)[:]([a-zA-z][a-zA-z0-9]+)\$/", $cmd_string, $regex_output)) { $type = $regex_output[1][0]; $name = $regex_output[2][0]; switch ($type) { case 'project': $dir = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'dist' . DIRECTORY_SEPARATOR . $name; if (file_exists($dir)) { $chk = true; $confirm = "Are you sure you want to " . Color::RED . "delete" . Color::RESET . " `{$name}` [no/yes][5m?" . Color::RESET . ': '; fwrite(STDOUT, "[2J"); fwrite(STDOUT, $confirm); while ($chk) { $handle = fopen("php://stdin", "r"); $line = fgets($handle); if (trim($line) != 'yes' and trim($line) != 'no') { fwrite(STDOUT, "[2J"); fwrite(STDOUT, "Just type '" . Color::BOLD_GREEN . "yes'" . Color::RESET . " or '" . Color::BOLD_GREEN . "no'" . Color::RESET . PHP_EOL); fwrite(STDOUT, $confirm); } else { $chk = false; } } if (trim($line) == 'no') { fwrite(STDOUT, "[2J"); fwrite(STDOUT, '[ABORTED]: ' . Color::BOLD_UNDERLINE . "Nothing is deleted." . Color::RESET . PHP_EOL . PHP_EOL); } else { self::$i = 0; self::$allfiles = self::count_files($dir . '/'); StopWatch::start(); self::rrmdir($dir); $seconds = round(StopWatch::elapsed(), 4); fwrite(STDERR, ""); fwrite(STDERR, PHP_EOL); fwrite(STDOUT, "[2J"); fwrite(STDOUT, Color::BOLD_GREEN . '[SUCCESS]: Project deleted.' . Color::RESET . PHP_EOL); fwrite(STDOUT, Drawing::SUCCESS_BOX('Stirlingframe->Delelte:', "# Project `{$name}` has been delete.", "# " . self::$allfiles . " files have been removed in " . $seconds . "s.")); fwrite(STDOUT, PHP_EOL); } } else { fwrite(STDOUT, "[2J"); $header = 'Stirlingframe delete error:'; $desc = '# Project `' . $name . '` not exist'; fwrite(STDOUT, Color::BOLD_RED . '[ERROR]: Can\'t delete project.' . Color::RESET . PHP_EOL); fwrite(STDOUT, Drawing::ERROR_BOX($header, $desc)); fwrite(STDOUT, PHP_EOL); } break; case 'app': fwrite(STDOUT, '$create ' . $type . ' ' . $name . PHP_EOL); break; } } else { $msg = Color::CYAN . '$' . Color::RESET . ' delete [project|app] [name] '; fwrite(STDOUT, "[2J"); fwrite(STDOUT, Color::BOLD_RED . '[ERROR]: Invalid command.' . Color::RESET . PHP_EOL); fwrite(STDOUT, Drawing::ERROR_BOX('Stirlingframe create error:', '# Invalid parameters: command should be', $msg)); fwrite(STDOUT, PHP_EOL); } }
/** * Calculate an (approximate) OpenXML column width, based on font size and text contained * * @param \PHPExcel\Style\Font $font Font object * @param \PHPExcel\RichText|string $cellText Text to calculate width * @param integer $rotation Rotation angle * @param \PHPExcel\Style\Font|NULL $defaultFont Font object * @return integer Column width */ public static function calculateColumnWidth(\PHPExcel\Style\Font $font, $cellText = '', $rotation = 0, \PHPExcel\Style\Font $defaultFont = null) { // If it is rich text, use plain text if ($cellText instanceof \PHPExcel\RichText) { $cellText = $cellText->getPlainText(); } // Special case if there are one or more newline characters ("\n") if (strpos($cellText, "\n") !== false) { $lineTexts = explode("\n", $cellText); $lineWidths = array(); foreach ($lineTexts as $lineText) { $lineWidths[] = self::calculateColumnWidth($font, $lineText, $rotation = 0, $defaultFont); } return max($lineWidths); // width of longest line in cell } // Try to get the exact text width in pixels $approximate = self::$autoSizeMethod == self::AUTOSIZE_METHOD_APPROX; if (!$approximate) { $columnWidthAdjust = ceil(self::getTextWidthPixelsExact('n', $font, 0) * 1.07); try { // Width of text in pixels excl. padding // and addition because Excel adds some padding, just use approx width of 'n' glyph $columnWidth = self::getTextWidthPixelsExact($cellText, $font, $rotation) + $columnWidthAdjust; } catch (\PHPExcel\Exception $e) { $approximate = true; } } if ($approximate) { $columnWidthAdjust = self::getTextWidthPixelsApprox('n', $font, 0); // Width of text in pixels excl. padding, approximation // and addition because Excel adds some padding, just use approx width of 'n' glyph $columnWidth = self::getTextWidthPixelsApprox($cellText, $font, $rotation) + $columnWidthAdjust; } // Convert from pixel width to column width $columnWidth = Drawing::pixelsToCellDimension($columnWidth, $defaultFont); // Return return round($columnWidth, 6); }
/** * outputs the graphic either inline or if filename is given to a file * @param string $filename file name */ public function output($filename = null) { if (isset($filename)) { parent::imgRender($filename); } else { parent::imgRender(); } }
public function getDrawing($id) { $drawing = Drawing::with('drawingObjects')->where('id', $id)->get(); return Response::json($drawing->toArray()); }
<?php namespace DxfCreator; require_once __DIR__ . '/vendor/autoload.php'; // Example of how to use this package $myDocument = new Drawing(); $pageOptions = ["xLength" => 11.0, "yLength" => 8.5, "marginBottom" => 0.5, "marginLeft" => 0.5, "marginRight" => 0.5, "marginTop" => 0.5]; $page1 = $myDocument->addPage("Page 1", $pageOptions); $rectangleOptions = ["lineWeight" => 1.0]; $myDocument->drawRectangle($page1, 0, 0, 10, 7.5, $rectangleOptions); $myDocument->drawRectangle($page1, 0, 7.5, 7.5, 6.5, $rectangleOptions); $myDocument->drawRectangle($page1, 0, 0, 7.5, 0.5, $rectangleOptions); $myDocument->drawRectangle($page1, 7.5, 7.5, 10, 0, $rectangleOptions); $page2 = $myDocument->addPage("Page 2", $pageOptions); $myDocument->drawRectangle($page2, 0, 7.5, 10, 7, $rectangleOptions); $myDocument->drawRectangle($page2, 0, 0, 3, 7, $rectangleOptions); $myDocument->drawRectangle($page2, 3, 0, 7, 7, $rectangleOptions); $myDocument->drawRectangle($page2, 7, 0, 10, 7, $rectangleOptions); $dxf = new DxfConverter($myDocument); $dxf->save('C:\\Users\\John\\myDocument.dxf');