protected function createVariances(Palette $palette_1, Palette $palette_2) { $colors_1 = $palette_1->colors()->get(); $colors_2 = $palette_2->colors()->get(); // Does each palette contain the same number of colors if (count($colors_1) !== count($colors_2)) { trigger_error(__CLASS__ . " requires both Palette objects to contain the same number of colors", E_USER_WARNING); } // Loop through palettes and compare each colors based on a matching index for ($i = 0; $i < count($colors_1); $i++) { $this->variances[$i] = $colors_1[$i]->compareTo($colors_2[$i])->getVariance(); $this->rgbas[$i] = $colors_1[$i]->getRgba(); } return $this; }
/** * Based on Example10.php */ public function testPieGraph() { // Dataset definition $DataSet = new pData(); $DataSet->addPoints(array(10, 2, 3, 5, 3), "Serie1"); $DataSet->addPoints(array("January", "February", "March", "April", "May"), "Serie2"); $DataSet->AddAllSeries(); $DataSet->setAbscissaLabelSeries("Serie2"); // Initialise the graph $canvas = new TestCanvas(); $canvas->setAntialiasQuality(0); $Test = new PieChart(420, 250, $canvas); $Test->setPalette(Palette::colorGradientPalette(new Color(195, 204, 56), new Color(223, 110, 41), 5)); // Draw the pie chart $Test->setFontProperties("Fonts/tahoma.ttf", 8); $Test->drawPieGraph($DataSet, 180, 130, 110, PIE_PERCENTAGE_LABEL, FALSE, 50, 20, 5); file_put_contents(dirname(__FILE__) . '/action_logs/testPieGraph_partial1', $canvas->getActionLog()); $this->assertEquals('211751485459ed20cc6bac7215db1f20', md5($canvas->getActionLog())); $Test->drawPieLegend(330, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), new Color(250)); // Write the title $Test->setFontProperties("Fonts/MankSans.ttf", 10); $Test->drawTitle(10, 20, "Sales per month", new Color(100)); file_put_contents(dirname(__FILE__) . '/action_logs/testPieGraph', $canvas->getActionLog()); $this->assertEquals('8302fcc3542fd3f36a9d378efea49d3a', md5($canvas->getActionLog())); }
public function get_palettes($id) { $colors = Palette::find($id)->colors()->get(); $this->view->title = "Control Palette"; $this->view->lead = "Colors used for control."; $this->view->content = View::make('mockup.pages.swatches')->with('colors', $colors)->render(); return $this->view; }
/** * Creates a new palette. * @param integer $warehouseId Warehouse ID */ private function create($warehouseId) { $number = Palette::getMaxNumber($warehouseId) + 1; $sql = "INSERT INTO " . Database::getTableName('palettes') . " (number, warehouse) VALUES(?, ?)"; $id = Database::getInstance()->sql("insertPalette", $sql, 'ii', [$number, $warehouseId], false); $this->id = $id; $this->warehouseId = $warehouseId; Log::debug('Added palette #' . $this->id); }
function xform_rows_to_top5($resArray, $column_vector) { global $top5_page_list; global $top5_function_list; global $top5_data; $ts_col = array_search("timestamp", $column_vector); $page_col = array_search("page", $column_vector); $fn_col = array_search("function", $column_vector); if ($ts_col === FALSE || $page_col === FALSE || $fn_col === FALSE) { header('HTTP/1.1 500 Internal Server Error'); print_r($column_vector); die("column names messed up."); } $palette = new Palette(); $last_ts = NULL; $last_page = NULL; $chunk = array(); $top5_data = "\n\n[\n"; foreach ($resArray as $row) { $page = $row[$page_col]; $ts = $row[$ts_col]; $fn = $row[$fn_col]; # continue current chunk if ts and page are same if ($ts == $last_ts && $page == $last_page) { if (count($chunk) == 2 + 5) { # 2 is for timestamp and page # Already 5 entries continue; } else { $chunk[] = $palette->format($fn); } } else { # # either ts or page changed, insert current chunk # and reset trackers # # If there are no entries in current chunk # this is the very first entry, special case - # don't we hate those? # if (count($chunk) != 0) { while (count($chunk) < 5 + 2) { $chunk[] = "'no_entry'"; } $top5_data .= json_encode($chunk) . ",\n"; } $chunk = array(); $chunk = array($ts, $page, $palette->format($fn)); $last_ts = $ts; $last_page = $page; $top5_page_list[$page] = TRUE; } } $top5_data .= "\n],\n"; $top5_data .= json_encode($palette->elements) . "\n\n"; }
/** * Create a color palette from a file * * @static * @param string $filename * @param string $delimiter * @throws Exception * @return Palette */ public static function fromFile($filename, $delimiter = ',') { $handle = @fopen($filename, 'r'); if (!$handle) { throw new Exception('Failed to open file in loadColorPalette'); } $palette = new Palette(); $idx = 0; while (!feof($handle)) { $buffer = fgets($handle, 4096); $buffer = str_replace(chr(10), '', $buffer); $buffer = str_replace(chr(13), '', $buffer); $values = explode($delimiter, $buffer); $values = array_map('trim', $values); if (count($values) == 3) { $palette->setColor($idx, new Color($values[0], $values[1], $values[2])); $idx++; } elseif (count($values) == 1 && $values[0] !== '') { $palette->setColor($idx, new Color($values[0])); } } return $palette; }
/** * Make changes to the database. * * @return void */ public function up() { Schema::table('palettes', function ($table) { $table->create(); $table->increments('id'); $table->string('title'); $table->text('description')->nullable(); $table->integer('user_id')->unsigned(); $table->timestamps(); }); Schema::table('palettes', function ($table) { $table->foreign('user_id')->references('id')->on('users')->on_update('cascade')->on_delete('cascade'); $table->unique(array('title', 'user_id')); }); $seed = array(array('title' => 'Revlon\'s Palette', 'description' => 'Collection of colors used in foundation.', 'user_id' => 1), array('title' => 'Colgates\'s Palette', 'description' => 'Collection of teeth colors used for teeth whitening programs.', 'user_id' => 1), array('title' => 'Clairol\'s Palette', 'description' => 'Collection of colors used for hair dyeing.', 'user_id' => 1)); foreach ($seed as $rec) { Palette::create($rec); } }
public function post_store($palette_id) { $input = Input::all(); $validation = Validator::make($input, $this->rules); if ($validation->fails()) { return Redirect::back()->with('errors', $validation->errors)->with_input(); //Need to send errors back... } try { $object = new Color(); $object = $object->fill($input); $attach = Palette::find($palette_id)->colors()->insert($object); if (!$attach) { throw new Exception("There was an error inserting the color into palette!"); } } catch (Exception $e) { return Redirect::back()->with('error', "There was an error with your submission! Please try again.")->with_input(); } if ($object->id) { return Redirect::to('litmus/palettes/' . $palette_id . '/colors/' . $object->id)->with('status', 'Your color was submitted successfully!')->with_input(); } }
/** * Make changes to the database. * * @return void */ public function up() { Schema::table('colors', function ($table) { $table->create(); $table->increments('id'); $table->string('name'); $table->integer('red'); $table->integer('green'); $table->integer('blue'); $table->integer('alpha')->default(0); $table->string('hex', 7)->nullable(); $table->integer('palette_id')->unsigned(); $table->timestamps(); }); Schema::table('colors', function ($table) { $table->foreign('palette_id')->references('id')->on('palettes')->on_update('cascade')->on_delete('cascade'); }); $seed = array(); for ($r = 1; $r < 256; $r = $r * 10) { $array = array(); $array['red'] = $r; for ($g = 1; $g < 256; $g = $g * 10) { $array['green'] = $g; for ($b = 1; $b < 256; $b = $b * 10) { $array['blue'] = $b; $array['name'] = "rgb({$r}, {$g}, {$b})"; $seed[] = $array; } } } foreach (Palette::all() as $p) { foreach ($seed as $rec) { $color = new Color(); $color->fill($rec); $p->colors()->insert($color); } } }
/* Example10 : A 3D exploded pie graph */ // Standard inclusions require_once "../lib/pData.php"; require_once "../lib/pChart.php"; require_once '../lib/GDCanvas.php'; require_once '../lib/BackgroundStyle.php'; require_once '../lib/PieChart.php'; // Definitions $DataSet = new pData(); $Canvas = new GDCanvas(420, 250); $Chart = new PieChart(420, 250, $Canvas); // Dataset $DataSet->AddPoints(array(10, 2, 3, 5, 3), "Serie1"); $DataSet->AddPoints(array("January", "February", "March", "April", "May"), "Serie2"); $DataSet->AddAllSeries(); $DataSet->SetAbscissaLabelSeries("Serie2"); // Initialise the graph $Chart->setPalette(Palette::colorGradientPalette(new Color(195, 204, 56), new Color(223, 110, 41), 5)); // Draw the pie chart $Chart->setFontProperties("../Fonts/tahoma.ttf", 8); $Canvas->setAntialiasQuality(0); $Chart->drawPieGraph($DataSet, 180, 130, 110, PIE_PERCENTAGE_LABEL, FALSE, 50, 20, 5); $Chart->drawPieLegend(330, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), new Color(250)); // Write the title $Chart->setFontProperties("../Fonts/MankSans.ttf", 10); $Chart->drawTitle(10, 20, "Sales per month", new Color(100)); $Chart->Render("Example10.png"); header("Content-Type:image/png"); readfile("Example10.png");
/** * Load Color Palette from file */ function loadColorPalette($FileName, $Delimiter = ",") { $this->palette = Palette::fromFile($FileName, $Delimiter); }
<?php Route::model('colors', 'Color'); Route::bind('palettes', function ($value, $route) { $palette = Palette::find($value); $account = $palette->account; if (Auth::user()->accounts()->whereAccountId($account->id)->count()) { return Palette::find($value); } return App::abort(404); }); Route::group(['before' => "auth"], function () { Route::resource('palettes', 'PalettesController'); Route::resource('palettes/{palettes}/colors', 'ColorsController'); });
public function process() { // check if session is active $session = new Session($this->sessionId); if ($session->sessionId > 0) { // update session $session->update(); // process restricted functions switch ($this->f) { case 'checkLogin': return Login::checkLogin($session->sessionId); case 'getSession': return $session; case 'getWarehouse': if (isset($this->data->update)) { $warehouse = new Warehouse($session->warehouseId, $this->data->update); } else { $warehouse = new Warehouse($session->warehouseId); } $warehouse->dMail = $warehouse->getMail(); $warehouse->dDisableLocationLess = $warehouse->isLocationLessDisabled(); $warehouse->dDisablePaletteLess = $warehouse->isPaletteLessDisabled(); return $warehouse; case 'editWarehouse': if (!$session->restricted) { $data = $this->data; $warehouse = new Warehouse($session->warehouseId); // update warehouse data if (isset($data->name)) { $warehouse->name = $data->name; } if (isset($data->description)) { $warehouse->description = $data->description; } if (isset($data->country)) { $warehouse->country = $data->country; } if (isset($data->city)) { $warehouse->city = $data->city; } if (isset($data->password)) { $warehouse->setPassword($data->password); } if (isset($data->passwordRestricted)) { $warehouse->setPasswordRestricted($data->passwordRestricted); } if (isset($data->mail)) { $warehouse->setMail($data->mail); } if (isset($data->disableLocationLess)) { $warehouse->setDisableLocationLess($data->disableLocationLess); } if (isset($data->disablePaletteLess)) { $warehouse->setDisablePaletteLess($data->disablePaletteLess); } // update database entry return $warehouse->edit(); } break; case 'deleteWarehouse': if (!$session->restricted) { $warehouse = new Warehouse($session->warehouseId); if ($warehouse->id > 0 && $warehouse->delete()) { return $session->destroy(); } } break; case 'addCategory': if (!$session->restricted && isset($this->data->name)) { $category = new Category(null, $session->warehouseId); $category->name = $this->data->name; if (isset($this->data->parent)) { $category->parent = $this->data->parent; } if ($category->edit()) { return $category->id; } } break; case 'getCategory': if (isset($this->data->id) && isset($this->data->update)) { return new Category($this->data->id, $session->warehouseId, $this->data->update); } elseif (isset($this->data->id)) { return new Category($this->data->id, $session->warehouseId); } break; case 'deleteCategory': if (!$session->restricted && isset($this->data->id)) { $category = new Category($this->data->id, $session->warehouseId); return $category->delete(); } break; case 'editCategory': if (isset($this->data->id)) { $data = $this->data; $category = new Category($this->data->id, $session->warehouseId); if (!$session->restricted) { if (isset($data->name)) { $category->name = $data->name; } if (isset($data->parent)) { $category->parent = $data->parent; } if (isset($data->male)) { $category->male = $data->male; } if (isset($data->female)) { $category->female = $data->female; } if (isset($data->children)) { $category->children = $data->children; } if (isset($data->baby)) { $category->baby = $data->baby; } if (isset($data->summer)) { $category->summer = $data->summer; } if (isset($data->winter)) { $category->winter = $data->winter; } } if (isset($data->demand)) { $category->demand = $data->demand; } if (isset($data->weight)) { $category->weight = $data->weight; } return $category->edit(); } break; case 'getCategories': if (isset($this->data->parent)) { return Category::getCategories($session->warehouseId, $this->data->parent); } else { return Category::getCategories($session->warehouseId); } case 'addLocation': if (!$session->restricted && isset($this->data->name)) { $location = new Location(null, $session->warehouseId); $location->name = $this->data->name; if ($location->edit()) { return $location->id; } return true; } break; case 'getLocation': if (isset($this->data->id) && isset($this->data->update)) { return new Location($this->data->id, $session->warehouseId, $this->data->update); } elseif (isset($this->data->id)) { return new Location($this->data->id, $session->warehouseId); } break; case 'deleteLocation': if (!$session->restricted && isset($this->data->id)) { $location = new Location($this->data->id, $session->warehouseId); return $location->delete(); } break; case 'editLocation': if (!$session->restricted && isset($this->data->id) && isset($this->data->name)) { $location = new Location($this->data->id, $session->warehouseId); $location->name = $this->data->name; return $location->edit(); } break; case 'getLocations': return Location::getLocations($session->warehouseId); case 'addPalette': $palette = new Palette(null, $session->warehouseId); if (isset($this->data->locationId)) { $palette->locationId = $this->data->locationId; } if ($palette->edit()) { return $palette->id; } break; case 'getPalette': if (isset($this->data->id) && isset($this->data->update)) { return new Palette($this->data->id, $session->warehouseId, $this->data->update); } elseif (isset($this->data->id)) { return new Palette($this->data->id, $session->warehouseId); } break; case 'deletePalette': if (isset($this->data->id)) { $palette = new Palette($this->data->id, $session->warehouseId); return $palette->delete(); } break; case 'editPalette': if (isset($this->data->id)) { $palette = new Palette($this->data->id, $session->warehouseId); if (isset($this->data->locationId)) { $palette->locationId = $this->data->locationId; } return $palette->edit(); } break; case 'getPalettes': return Palette::getPalettes($session->warehouseId); case 'getCarton': if (isset($this->data->id) && isset($this->data->update)) { return new Carton($this->data->id, $session->warehouseId, null, null, $this->data->update); } elseif (isset($this->data->id)) { return new Carton($this->data->id, $session->warehouseId); } break; case 'addCarton': $locationId = null; $paletteId = null; if (isset($this->data->location)) { $locationId = $this->data->location; } if (isset($this->data->palette)) { $paletteId = $this->data->palette; } $carton = new Carton(null, $session->warehouseId, $locationId, $paletteId); return $carton->id; case 'deleteCarton': if (isset($this->data->id)) { $carton = new Carton($this->data->id, $session->warehouseId); return $carton->delete(); } break; case 'editCarton': if (isset($this->data->id)) { $carton = new Carton($this->data->id, $session->warehouseId); if (isset($this->data->location)) { $carton->locationId = $this->data->location; } else { $carton->locationId = null; } if (isset($this->data->palette)) { $carton->paletteId = $this->data->palette; } else { $carton->paletteId = null; } return $carton->edit(); } break; case 'addArticle': if (isset($this->data->carton) && isset($this->data->category) && isset($this->data->amount)) { return Stock::addArticle($this->data->carton, $this->data->category, isset($this->data->male) ? $this->data->male : false, isset($this->data->female) ? $this->data->female : false, isset($this->data->children) ? $this->data->children : false, isset($this->data->baby) ? $this->data->baby : false, isset($this->data->winter) ? $this->data->winter : false, isset($this->data->summer) ? $this->data->summer : false, $this->data->amount >= 0 ? $this->data->amount : 0, $this->data->amount < 0 ? $this->data->amount : 0); } break; case 'getStock': return Stock::getStock($session->warehouseId, isset($this->data->carton) ? $this->data->carton : null, isset($this->data->category) ? $this->data->category : null, isset($this->data->palette) ? $this->data->palette : null, isset($this->data->location) ? $this->data->location : null, isset($this->data->male) ? $this->data->male : false, isset($this->data->female) ? $this->data->female : false, isset($this->data->children) ? $this->data->children : false, isset($this->data->baby) ? $this->data->male : false, isset($this->data->summer) ? $this->data->male : false, isset($this->data->winter) ? $this->data->male : false, isset($this->data->details) ? $this->data->details : false); case 'getBarcodeUri': if (isset($this->data->text)) { // create barcode object $bc = new Barcode39($this->data->text); if (isset($this->data->textSize)) { $bc->barcode_text_size = $this->data->textSize; } if (isset($this->data->barThin)) { $bc->barcode_bar_thin = $this->data->barThin; } if (isset($this->data->barThick)) { $bc->barcode_bar_thick = $this->data->barThick; } // generate barcode image $img = "barcode_" . mt_rand(0, 100) . ".png"; $bc->draw($img); // get data uri $uri = Barcode39::getDataURI($img); unlink($img); return $uri; } break; } } else { // process unrestricted function switch ($this->f) { case 'getActiveSessions': return Session::getActiveSessionsNumber(); case 'getWarehouses': return Warehouse::getWarehouses(); case 'addWarehouse': $data = $this->data; if (isset($data->name) && isset($data->description) && isset($data->country) && isset($data->city) && isset($data->password) && isset($data->mail)) { $warehouse = new Warehouse(); Log::debug('new warehouse' . $warehouse->id); $warehouse->name = $data->name; $warehouse->description = $data->description; $warehouse->country = $data->country; $warehouse->city = $data->city; $warehouse->setPassword($data->password); $warehouse->setMail($data->mail); return $warehouse->edit(); } break; case 'getCountries': return getCountries(); break; case 'getCountryCode': $data = $this->data; if (isset($data->name)) { return getCountryCode(null, $data->name); } return false; } } return false; }
/** * Sets the cell's font color * * @param string|integer $color either a string (like 'blue'), or an integer (range is [8...63]). * * @return Font */ public function setColor($color) { $this->color = Palette::getColor($color); return $this; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { try { $palette = Palette::findOrFail($id); $palette->delete(); return Redirect::route('palettes.index'); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); } catch (Exception $e) { return $this->respondBadRequest($e->getMessage()); } }
/** * Remove the specified resource from storage. * * @param Palette Palette * @return Response */ public function destroy(Palette $palette) { $palette->delete(); return Redirect::route($this->namespace . '.index'); }
array('word' => "aaaa", 'count' => "0", 'title' => "cedric", 'link' => "cedric"), array('word' => "bbbbb", 'count' => "8", 'title' => "cedric", 'link' => "cedric"), array('word' => "bbbbb", 'count' => "0", 'title' => "cedric", 'link' => "cedric"), array('word' => "bbbbb", 'count' => "0", 'title' => "cedric", 'link' => "cedric"), array('word' => "bbbbb", 'count' => "5", 'title' => "cedric", 'link' => "cedric"), array('word' => "rrrrrr", 'count' => "2", 'title' => "cedric", 'link' => "cedric"), ); */ $palettes = array('aqua' => array('BED661', '89E894', '78D5E3', '7AF5F5', '34DDDD', '93E2D5'), 'yellow/blue' => array('FFCC00', 'CCCCCC', '666699'), 'grey' => array('87907D', 'AAB6A2', '555555', '666666'), 'brown' => array('CC6600', 'FFFBD0', 'FF9900', 'C13100'), 'army' => array('595F23', '829F53', 'A2B964', '5F1E02', 'E15417', 'FCF141'), 'pastel' => array('EF597B', 'FF6D31', '73B66B', 'FFCB18', '29A2C6'), 'red' => array('FFFF66', 'FFCC00', 'FF9900', 'FF0000')); $font = dirname(__FILE__) . '/Arial.ttf'; $width = 600; $height = 600; //$width, $height, $font, $text = null, $imagecolor = array(0, 0, 0, 127), $words_limit = null, $vertical_freq = FrequencyTable::WORDS_MAINLY_HORIZONTAL $cloud = new WordCloud(16, 72, $width, $height, $font, $full_text); $palette = Palette::get_palette_from_hex($cloud->get_image(), $palettes['grey'], 0, FrequencyTable::WORDS_MAINLY_HORIZONTAL); $cloud->render($palette); // Render the cloud in a temporary file, and return its base64-encoded content $file = tempnam(getcwd(), 'img'); imagepng($cloud->get_image(), $file); $img64 = base64_encode(file_get_contents($file)); unlink($file); imagedestroy($cloud->get_image()); ?> <img usemap="#mymap" src="data:image/png;base64,<?php echo $img64; ?> " border="0"/> <map name="mymap"> <?php
/** * function to return Json response for all Palette/Editor elements * * @since 2.0.0 * * @return JSON data * * @param Post data [action],[category] */ public function get_pallete_elements() { if (isset($_POST['category']) && $_POST['category'] == 'Palette') { //if pallete required try { header("Content-Type: application/json"); $palette = new Palette(); $elements = $palette->to_JSON(); echo $elements; } catch (Exception $e) { echo '{"error":{"text":' . $e->getMessage() . '}}'; } } else { //if editor elements required try { header("Content-Type: application/json"); $instance = $_POST['instance']; $editor = new Editor($instance); $elements = $editor->to_JSON(); echo $elements; } catch (Exception $e) { echo '{"error":{"text":' . $e->getMessage() . '}}'; } } exit; }
/** * This function create the background picture */ function __construct($XSize, $YSize, ICanvas $canvas) { $this->palette = Palette::defaultPalette(); $this->XSize = $XSize; $this->YSize = $YSize; $this->setFontProperties("tahoma.ttf", 8); $this->shadowProperties = ShadowProperties::FromDefaults(); $this->canvas = $canvas; }
/** * Address for third parties to incorporate an image upload form. * * @return html */ public function get_form() { $data = array(); $data['fields'] = Config::get('litmus::config.form.image'); unset($data['fields'][0]); unset($data['fields'][1]); foreach (Palette::all() as $palette) { $id = $palette->id; $title = $palette->title; $data['fields'][4]['values'][$id] = $title; } $data['url'] = Input::has('url') ? Input::get('url') : ''; $form = View::make('litmus::partials.form', $data)->render(); return $form; }
$full_text = <<<EOT dreamcraft.ch is a developement company based in Switzerland, aimed to create, integrate and mantain cutting-edge technology web applications. We provide you our expertise in PHP/MySQL, Microsoft .NET and various Content Management Systems in order to develop new web applications or maintain and upgrade your current web sites. Our philosophy: Establish a durable and trustworthy win-win relation with our customers. Use quality Open Source Software whenever possible. Enforce good programming rules and standards to create better rich content web 2.0 applications. A folk wisdom says "united we stand, divided we fall". As such we work closely with other Swiss companies to offer you an even larger range of skills. Aicom are the creators of interactive web based tools such as FormFish, MettingPuzzle or MailJuggler. oriented.net is a high-quality web hosting company based in Switzerland. Our partnership with them allows us to offer advanced hosting solutions to your web application. EOT; $font = dirname(__FILE__) . '/Arial.ttf'; $width = 600; $height = 600; $cloud = new WordCloud($width, $height, $font, $full_text); $palette = Palette::get_palette_from_hex($cloud->get_image(), array('FFA700', 'FFDF00', 'FF4F00', 'FFEE73')); $cloud->render($palette); // Render the cloud in a temporary file, and return its base64-encoded content $file = tempnam(getcwd(), 'img'); imagepng($cloud->get_image(), $file); $img64 = base64_encode(file_get_contents($file)); unlink($file); imagedestroy($cloud->get_image()); ?> <img usemap="#mymap" src="data:image/png;base64,<?php echo $img64; ?> " border="0"/> <map name="mymap"> <?php
public function get_palettes($user_id) { $data['title'] = "Palettes Page"; $data['lead'] = "Your registered palettes."; $data['tabs'][] = array('All', URL::to('litmus/palettes'), 'active'); $data['tabs'][] = array('Add', URL::to('litmus/palettes/create')); $data['table']['objects'] = Palette::where('user_id', '=', $user_id)->get(); // DEVELOPMENT!!!!!!!!!!!!! $data['content'] = View::make('litmus::partials.table', $data['table'])->render(); return $this->layout($data); }
public function delete_destroy($id) { $delete = Palette::find($id)->delete(); if ($delete) { return Redirect::to('litmus/palettes')->with('status', 'Your palette was deleted successfully!'); } else { return Redirect::back()->with('error', "There was an error deleting the record! Please try again."); } }
public function get_palettes($id) { $colors = Palette::find($id)->colors()->get(); return $this->view->nest('main', 'mockup.pages.swatches', compact('colors')); }
<?php // Users Controller Route::get('litmus/users', 'litmus::users@index'); Route::get('litmus/users/create', 'litmus::users@create'); Route::post('litmus/users', 'litmus::users@store'); Route::get('litmus/users/(:num)', 'litmus::users@show'); Route::get('litmus/users/(:num)/edit', 'litmus::users@edit'); Route::put('litmus/users/(:num)', 'litmus::users@update'); Route::get('litmus/users/(:num)/palettes', 'litmus::users@palettes'); //table redirects for BELONGS TO Route::get('litmus/palettes/(:num)/user', function ($palette_id) { $user_id = Palette::find($palette_id)->user()->first()->id; return Redirect::to('litmus/users/' . $user_id); }); Route::get('litmus/users/(:num)/palettes/(:num)', function ($user_id, $palette_id) { return Redirect::to('litmus/palettes/' . $palette_id); }); // Palettes Controller Route::get('litmus/palettes', array('as' => 'palettes', 'uses' => 'litmus::palettes@index')); Route::get('litmus/palettes/create', 'litmus::palettes@create'); Route::post('litmus/palettes', 'litmus::palettes@store'); Route::get('litmus/palettes/(:num)', 'litmus::palettes@show'); Route::get('litmus/palettes/(:num)/edit', 'litmus::palettes@edit'); Route::put('litmus/palettes/(:num)', 'litmus::palettes@update'); Route::delete('litmus/palettes/(:num)', 'litmus::palettes@destroy'); //table redirects for BELONGS TO Route::get('litmus/palettes/(:num)/colors/(:num)/palette', function ($palette_id, $color_id) { return Redirect::to('litmus/palettes/' . $palette_id); }); // Colors Controller
/** * custom or preset palette * * @param $params * @param $cloud * @return array */ private function getPalette($params, $cloud) { $useCustomPalette = $params->get('wordleUseCustomPalette', '0'); if ($useCustomPalette) { $customPalette = $params->get('wordleCustomPalette', 'CC6600,FFFBD0,FF9900,C13100'); $palette = Palette::get_palette_from_hex($cloud->get_image(), explode(",", $customPalette)); return $palette; } else { $palettes = array('aqua' => array('BED661', '89E894', '78D5E3', '7AF5F5', '34DDDD', '93E2D5'), 'yellow/blue' => array('FFCC00', 'CCCCCC', '666699'), 'grey' => array('87907D', 'AAB6A2', '555555', '666666'), 'brown' => array('CC6600', 'FFFBD0', 'FF9900', 'C13100'), 'army' => array('595F23', '829F53', 'A2B964', '5F1E02', 'E15417', 'FCF141'), 'pastel' => array('EF597B', 'FF6D31', '73B66B', 'FFCB18', '29A2C6'), 'red' => array('FFFF66', 'FFCC00', 'FF9900', 'FF0000')); $presetPalette = $params->get('wordlePresetPalette', 'aqua'); $selectedPalette = $palettes[$presetPalette]; $palette = Palette::get_palette_from_hex($cloud->get_image(), $selectedPalette); return $palette; } }
/** * Sets the cell's background color * * @param string|integer $color either a string (like 'blue'), or an integer (range is [8...63]). */ public function setBgColor($color) { $this->bgColor = Palette::getColor($color); if ($this->pattern == Fill::PATTERN_NONE) { $this->setPattern(Fill::PATTERN_SOLID); } }