How to use pts_svg_dom class

Best Phoronix-test-suite code snippet using pts_svg_dom

pts_graph_core.php

Source: pts_graph_core.php Github

copy

Full Screen

...321 return $maximum;322 }323 protected function text_size_bounds($string, $font_size, $minimum_font_size, $bound_width, $bound_height = -1)324 {325 list($string_width, $string_height) = pts_svg_dom::estimate_text_dimensions($string, $font_size);326 while($font_size > $minimum_font_size && $string_width > $bound_width || ($bound_height > 0 && $string_height > $bound_height))327 {328 $font_size -= 0.3;329 list($string_width, $string_height) = pts_svg_dom::estimate_text_dimensions($string, $font_size);330 }331 return $font_size;332 }333 protected function update_graph_dimensions($width = -1, $height = -1, $recalculate_offsets = false)334 {335 /​/​ Allow render area to be increased, but not decreased336 $this->i['graph_width'] = max($this->i['graph_width'], $width);337 $this->i['graph_height'] = max($this->i['graph_height'], $height);338 if($recalculate_offsets)339 {340 $this->i['graph_top_end'] = $this->i['graph_height'] - $this->i['top_end_bottom'];341 $this->i['graph_left_end'] = $this->i['graph_width'] - $this->i['left_end_right'];342 }343 }344 protected function identifier_to_branded_color($identifier, $fallback_color = null)345 {346 if($this->i['support_color_branding'] == false || !isset($identifier[6]))347 {348 return $fallback_color;349 }350 /​/​ See if the result identifier matches something to be color-coded better351 $identifier = strtolower($identifier) . ' ';352 if(strpos($identifier, 'geforce') !== false || strpos($identifier, 'nvidia') !== false || strpos($identifier, 'quadro') !== false)353 {354 $paint_color = '#77b900';355 }356 else if(strpos($identifier, 'radeon') !== false || strpos($identifier, 'amd ') !== false || strpos($identifier, 'a10-') !== false || strpos($identifier, 'opteron ') !== false || strpos($identifier, 'fx-') !== false || strpos($identifier, 'firepro ') !== false || strpos($identifier, 'ryzen ') !== false)357 {358 $paint_color = '#f1052d';359 }360 else if(strpos($identifier, 'intel ') !== false || strpos($identifier, 'xeon ') !== false || strpos($identifier, 'core i') !== false || strpos($identifier, 'pentium') !== false || strpos($identifier, 'celeron') !== false)361 {362 $paint_color = '#0b5997';363 }364 else if(strpos($identifier, 'bsd') !== false)365 {366 $paint_color = '#850000';367 }368 else if(strpos($identifier, 'windows ') !== false)369 {370 $paint_color = '#0078d7';371 }372 else373 {374 $paint_color = $fallback_color;375 }376 if($paint_color != $fallback_color && strpos($identifier, ' - '))377 {378 /​/​ If there is " - " in string, darken the color... based upon idea when doing AMDGPU vs. Mesa vs. stock NVIDIA comparison for RX 480379 $paint_color = $this->darken_color($paint_color);380 }381 return $paint_color;382 }383 /​/​384 /​/​ Render Functions385 /​/​386 public function darken_color(&$paint_color)387 {388 $new_color = null;389 foreach(str_split(str_replace('#', null, $paint_color), 2) as $color)390 {391 $dec = hexdec($color);392 $dec = min(max(0, $dec * 0.7), 255);393 $new_color .= str_pad(dechex($dec), 2, 0, STR_PAD_LEFT);394 }395 return '#' . substr($new_color, 0, 6);396 }397 public function renderGraph()398 {399 $this->render_graph_start();400 $this->render_graph_finish();401 }402 public function render_graph_start()403 {404 $this->render_graph_dimensions();405 $this->render_graph_pre_init();406 $this->render_graph_init();407 }408 public function render_graph_dimensions()409 {410 $this->i['graph_max_value'] = $this->maximum_graph_value();411 $longest_identifier = $this->test_result->test_result_buffer->get_longest_identifier();412 /​/​ Make room for tick markings, left hand side413 if($this->i['iveland_view'] == false)414 {415 if($this->i['graph_value_type'] == 'NUMERICAL')416 {417 $this->i['left_start'] += self::text_string_width($this->i['graph_max_value'], self::$c['size']['tick_mark']) + 2;418 }419 if($this->i['hide_graph_identifiers'])420 {421 $this->i['graph_top_end'] += $this->i['top_end_bottom'] /​ 2;422 }423 $this->i['top_start'] += $this->graph_key_height();424 }425 else426 {427 if($this->i['graph_orientation'] == 'HORIZONTAL')428 {429 if($this->is_multi_way_comparison && count($this->results) > 1)430 {431 $longest_r = $longest_identifier;432 $longest_r = explode(' - ', $longest_r);433 $plus_extra = 0;434 if(count($longest_r) > 1)435 {436 $plus_extra = count($longest_r) * $this->i['identifier_size'] * 1.2;437 }438 $longest_identifier_width = self::text_string_width($this->i['graph_max_value'], $this->i['identifier_size']) + 60 + $plus_extra;439 }440 else441 {442 $longest_identifier_width = self::text_string_width($longest_identifier, $this->i['identifier_size']) + 8;443 }444 $longest_identifier_max = ($this->i['graph_width'] * 0.5) + 0.01;445 $this->i['left_start'] = min($longest_identifier_max, max($longest_identifier_width, 70));446 $this->i['left_end_right'] = 15;447 $this->i['graph_left_end'] = $this->i['graph_width'] - $this->i['left_end_right'];448 }449 else if($this->i['graph_value_type'] == 'NUMERICAL')450 {451 $this->i['left_start'] += max(20, self::text_string_width($this->i['graph_max_value'] + 0.01, self::$c['size']['tick_mark']) + 2);452 }453 /​/​ Pad 8px on top and bottom + title bar + sub-headings454 $this->i['top_heading_height'] = 16 + self::$c['size']['headers'] + (count($this->graph_sub_titles) * (self::$c['size']['sub_headers'] + 4));455 if($this->i['iveland_view'])456 {457 /​/​ Ensure there is enough room to print PTS logo458 $this->i['top_heading_height'] = max($this->i['top_heading_height'], 46);459 }460 $key_height = $this->graph_key_height();461 if($key_height > $this->i['key_line_height'])462 {463 /​/​ Increase height so key doesn't take up too much room464 $this->i['graph_height'] += $key_height;465 $this->i['graph_top_end'] += $key_height;466 }467 $this->i['top_start'] = $this->i['top_heading_height'] + $key_height + 16; /​/​ + spacing before graph starts468 $bottom_heading = 14;469 if($this->i['graph_orientation'] == 'HORIZONTAL')470 {471 if($this->is_multi_way_comparison && count($this->results) > 1)472 {473 $longest_string = explode(' - ', $longest_identifier);474 $longest_string = pts_strings::find_longest_string($longest_string);475 $rotated_text = round(self::text_string_width($longest_string, $this->i['identifier_size']) * 0.96);476 $per_identifier_height = 26; /​/​ default477 if(ceil($rotated_text * 1.25) >= floor($per_identifier_height * count($this->results)))478 {479 /​/​ this is to avoid having a rotated text bar overrun other results480 /​/​ XXX the 50 number might be too hacky481 $per_identifier_height = max(54, ceil($rotated_text /​ count($this->results) * 1.1));482 }483 }484 else if(count($this->results) > 3)485 {486 $per_identifier_height = count($this->results) * 18;487 }488 else489 {490 /​/​ If there's too much to plot, reduce the size so each graph doesn't take too much room491 $id_count = count(pts_arrays::first_element($this->results));492 if($id_count < 10)493 {494 $per_identifier_height = 46;495 }496 else if($id_count < 20)497 {498 $per_identifier_height = 36;499 }500 else if($id_count <= 38)501 {502 $this->i['compact_result_view'] = true;503 $per_identifier_height = 30;504 }505 else506 {507 $this->i['compact_result_view'] = true;508 $per_identifier_height = 26;509 }510 }511 $num_identifiers = $this->test_result->test_result_buffer->get_count();512 $this->i['graph_top_end'] = $this->i['top_start'] + ($num_identifiers * $per_identifier_height);513 /​/​ $this->i['top_end_bottom']514 $this->i['graph_height'] = $this->i['graph_top_end'] + 25 + $bottom_heading;515 }516 else517 {518 $this->i['graph_height'] += $bottom_heading + 4;519 }520 if(!empty($this->i['notes']))521 {522 $this->i['graph_height'] += $this->note_display_height();523 }524 }525 }526 public function render_graph_finish()527 {528 $this->render_graph_key();529 $this->render_graph_base($this->i['left_start'], $this->i['top_start'], $this->i['graph_left_end'], $this->i['graph_top_end']);530 $this->render_graph_heading();531 if($this->i['hide_graph_identifiers'] == false)532 {533 $this->render_graph_identifiers();534 }535 if($this->i['graph_value_type'] == 'NUMERICAL')536 {537 $this->render_graph_value_ticks($this->i['left_start'], $this->i['top_start'], $this->i['graph_left_end'], $this->i['graph_top_end']);538 }539 $this->render_graph_result();540 $this->render_graph_post();541 }542 protected function render_graph_pre_init()543 {544 return;545 }546 protected function render_graph_init()547 {548 $this->update_graph_dimensions();549 $this->svg_dom = new pts_svg_dom(ceil($this->i['graph_width']), ceil($this->i['graph_height']));550 /​/​ Background Color551 if($this->i['iveland_view'] || self::$c['graph']['border'])552 {553 $this->svg_dom->add_element('rect', array('x' => 0, 'y' => 0, 'width' => $this->i['graph_width'], 'height' => $this->i['graph_height'], 'fill' => self::$c['color']['background'], 'stroke' => self::$c['color']['border'], 'stroke-width' => 2));554 }555 else556 {557 $this->svg_dom->add_element('rect', array('x' => 0, 'y' => 0, 'width' => $this->i['graph_width'], 'height' => $this->i['graph_height'], 'fill' => self::$c['color']['background']));558 }559 if($this->i['iveland_view'] == false && ($sub_title_count = count($this->graph_sub_titles)) > 1)560 {561 $this->i['top_start'] += (($sub_title_count - 1) * (self::$c['size']['sub_headers'] + 4));562 }563 }564 protected function render_graph_heading($with_version = true)565 {566 $href = null;567 if($this->test_identifier != null)568 {569 $href = 'http:/​/​openbenchmarking.org/​test/​' . $this->test_identifier;570 }571 /​/​ Default to NORMAL572 if($this->i['iveland_view'])573 {574 $this->svg_dom->add_element('rect', array('x' => 0, 'y' => 0, 'width' => $this->i['graph_width'], 'height' => $this->i['top_heading_height'], 'fill' => self::$c['color']['main_headers']));575 if(isset($this->graph_title[36]))576 {577 /​/​ If it's a long string make sure it won't run over the side...578 while(self::text_string_width($this->graph_title, self::$c['size']['headers']) > ($this->i['graph_left_end'] - 20))579 {580 self::$c['size']['headers'] -= 0.5;581 }582 }583 $this->svg_dom->add_text_element($this->graph_title, array('x' => 6, 'y' => (self::$c['size']['headers'] + 2), 'font-size' => self::$c['size']['headers'], 'fill' => self::$c['color']['background'], 'text-anchor' => 'start', 'xlink:show' => 'new', 'xlink:href' => $href, 'font-weight' => 'bold'));584 foreach($this->graph_sub_titles as $i => $sub_title)585 {586 $vertical_offset = 12 + self::$c['size']['headers'] + (($i + 1) * (self::$c['size']['sub_headers'] - 4));587 $sub_title_size = self::$c['size']['sub_headers'];588 if(isset($sub_title[69]))589 {590 while(self::text_string_width($sub_title, $sub_title_size) > ($this->i['graph_left_end'] - 20))591 $sub_title_size -= 0.5;592 }593 $this->svg_dom->add_text_element($sub_title, array('x' => 6, 'y' => $vertical_offset, 'font-size' => $sub_title_size, 'font-weight' => 'bold', 'fill' => self::$c['color']['background'], 'text-anchor' => 'start'));594 }595 /​/​ SVG version of PTS thanks to https:/​/​gist.github.com/​xorgy/​65c6d0e87757dbb56a75596 $this->svg_dom->add_element('path', array('d' => 'm74 22v9m-5-16v16m-5-28v28m-23-2h12.5c2.485281 0 4.5-2.014719 4.5-4.5s-2.014719-4.5-4.5-4.5h-8c-2.485281 0-4.5-2.014719-4.5-4.5s2.014719-4.5 4.5-4.5h12.5m-21 5h-11m11 13h-2c-4.970563 0-9-4.029437-9-9v-20m-24 40v-20c0-4.970563 4.0294373-9 9-9 4.970563 0 9 4.029437 9 9s-4.029437 9-9 9h-9', 'stroke' => '#ffffff', 'stroke-width' => 4, 'fill' => 'none', 'transform' => 'translate(' . ceil($this->i['graph_left_end'] - 77) . ',' . (ceil($this->i['top_heading_height'] /​ 40 + 2)) . ')'));597 }598 else599 {600 $this->svg_dom->add_text_element($this->graph_title, array('x' => round($this->i['graph_left_end'] /​ 2), 'y' => (self::$c['size']['headers'] + 2), 'font-size' => self::$c['size']['headers'], 'fill' => self::$c['color']['main_headers'], 'text-anchor' => 'middle', 'xlink:show' => 'new', 'xlink:href' => $href));601 foreach($this->graph_sub_titles as $i => $sub_title)602 {603 $this->svg_dom->add_text_element($sub_title, array('x' => round($this->i['graph_left_end'] /​ 2), 'y' => (31 + (($i + 1) * 18)), 'font-size' => self::$c['size']['sub_headers'], 'fill' => self::$c['color']['main_headers'], 'text-anchor' => 'middle'));604 }605 if($with_version)606 {607 $this->svg_dom->add_text_element($this->i['graph_version'], array('x' => $this->i['graph_left_end'] , 'y' => ($this->i['top_start'] - 3), 'font-size' => 7, 'fill' => self::$c['color']['body_light'], 'text-anchor' => 'end', 'xlink:show' => 'new', 'xlink:href' => 'http:/​/​www.phoronix-test-suite.com/​'));608 }609 }610 }611 protected function render_graph_post()612 {613 if($this->i['iveland_view'])614 {615 $bottom_heading_start = $this->i['graph_top_end'] + $this->i['bottom_offset'] + 22;616 $this->svg_dom->add_element('rect', array('x' => 0, 'y' => $bottom_heading_start, 'width' => $this->i['graph_width'], 'height' => ($this->i['graph_height'] - $bottom_heading_start), 'fill' => self::$c['color']['main_headers']));617 $this->svg_dom->add_text_element($this->i['graph_version'], array('x' => $this->i['graph_left_end'], 'y' => ($bottom_heading_start + self::$c['size']['key'] + 3), 'font-size' => self::$c['size']['key'], 'fill' => self::$c['color']['background'], 'text-anchor' => 'end', 'xlink:show' => 'new', 'xlink:href' => 'http:/​/​www.phoronix-test-suite.com/​'));618 if(isset($this->d['link_alternate_view']) && $this->d['link_alternate_view'])619 {620 /​/​ add SVG version: https:/​/​gist.github.com/​xorgy/​169a65e29a3c2cc41e7f621 $a = $this->svg_dom->make_a($this->d['link_alternate_view']);622 $g = $this->svg_dom->make_g(array('transform' => 'translate(' . 4 . ',' . ($bottom_heading_start + 1) . ')', 'width' => 10, 'height' => 16), $a);623 $this->svg_dom->add_element('path', array('d' => 'M5 0v6.5L0 11l3-3-3-3.5L5 0', 'fill' => '#038bb8'), $g);624 $this->svg_dom->add_element('path', array('d' => 'M5 0v6.5l5 4.5-3-3 3-3.5L5 0', 'fill' => '#25b3e8'), $g);625 $this->svg_dom->add_element('path', array('d' => 'M5 16V9l5-4.5V11l-5 5', 'fill' => '#e4f4fd'), $g);626 $this->svg_dom->add_element('path', array('d' => 'M5 16V9L0 4.5V11l5 5', 'fill' => '#65cbf4'), $g);627 }628 if(!empty($this->i['notes']))629 {630 $estimated_height = 0;631 foreach($this->i['notes'] as $i => $note_r)632 {633 $this->svg_dom->add_textarea_element(($i + 1) . '. ' . $note_r['note'], array('x' => 5, 'y' => ($bottom_heading_start + (self::$c['size']['key'] * 2) + 8 + $estimated_height), 'font-size' => (self::$c['size']['key'] - 1), 'fill' => self::$c['color']['background'], 'text-anchor' => 'start', 'xlink:title' => $note_r['hover-title']), $estimated_height);634 }635 }636 }637 }638 protected function render_graph_base($left_start, $top_start, $left_end, $top_end)639 {640 if($this->i['graph_orientation'] == 'HORIZONTAL' || $this->i['iveland_view'])641 {642 $g = $this->svg_dom->make_g(array('stroke' => self::$c['color']['notches'], 'stroke-width' => 1));643 $this->svg_dom->add_element('line', array('x1' => $left_start, 'y1' => $top_start, 'x2' => $left_start, 'y2' => ($top_end + 1)), $g);644 $this->svg_dom->add_element('line', array('x1' => $left_start, 'y1' => $top_end, 'x2' => ($left_end + 1), 'y2' => $top_end), $g);645 if(!empty(self::$c['text']['watermark']))646 {647 $this->svg_dom->add_text_element(self::$c['text']['watermark'], array('x' => $left_end, 'y' => ($top_start - 5), 'font-size' => 8, 'fill' => self::$c['color']['text'], 'text-anchor' => 'end', 'xlink:show' => 'new', 'xlink:href' => self::$c['text']['watermark_url']));648 }649 }650 else651 {652 $this->svg_dom->add_element('rect', array('x' => $left_start, 'y' => $top_start, 'width' => ($left_end - $left_start), 'height' => ($top_end - $top_start), 'fill' => self::$c['color']['body'], 'stroke' => self::$c['color']['notches'], 'stroke-width' => 1));653 if(self::$c['text']['watermark'] != null)654 {655 $this->svg_dom->add_text_element(self::$c['text']['watermark'], array('x' => ($left_end - 2), 'y' => ($top_start + 12), 'font-size' => 10, 'fill' => self::$c['color']['text'], 'text-anchor' => 'end', 'xlink:show' => 'new', 'xlink:href' => self::$c['text']['watermark_url']));656 }657 }658 if(!empty($this->graph_y_title) && $this->i['hide_y_title'] == false)659 {660 $str = $this->graph_y_title;661 $offset = 0;662 if($this->i['graph_proportion'] != null)663 {664 $proportion = null;665 switch($this->i['graph_proportion'])666 {667 case 'LIB':668 $proportion = 'Less Is Better';669 $offset += 12;670 if($this->i['graph_orientation'] == 'HORIZONTAL')671 {672 $this->draw_arrow($left_start, $top_start - 8, $left_start + 9, $top_start - 8, self::$c['color']['text'], self::$c['color']['body_light'], 1);673 }674 else675 {676 $this->draw_arrow($left_start + 4, $top_start - 4, $left_start + 4, $top_start - 11, self::$c['color']['text'], self::$c['color']['body_light'], 1);677 }678 break;679 case 'HIB':680 $proportion = 'More Is Better';681 $offset += 12;682 if($this->i['graph_orientation'] == 'HORIZONTAL')683 {684 $this->draw_arrow($left_start + 9, $top_start - 8, $left_start, $top_start - 8, self::$c['color']['text'], self::$c['color']['body_light'], 1);685 }686 else687 {688 $this->draw_arrow($left_start + 4, $top_start - 11, $left_start + 4, $top_start - 4, self::$c['color']['text'], self::$c['color']['body_light'], 1);689 }690 break;691 }692 if($proportion)693 {694 if($str)695 {696 $str .= ', ';697 }698 $str .= $proportion;699 }700 }701 $this->svg_dom->add_text_element($str, array('x' => ($left_start + $offset), 'y' => ($top_start - 5), 'font-size' => 8, 'fill' => self::$c['color']['text'], 'text-anchor' => 'start'));702 }703 }704 protected function render_graph_value_ticks($left_start, $top_start, $left_end, $top_end, $show_numbers = true)705 {706 $increment = round($this->i['graph_max_value'] /​ $this->i['mark_count'], $this->i['graph_max_value'] < 10 ? 4 : 2);707 if($this->i['graph_orientation'] == 'HORIZONTAL')708 {709 $tick_width = round(($left_end - $left_start) /​ $this->i['mark_count']);710 $display_value = 0;711 $g = $this->svg_dom->make_g(array('font-size' => self::$c['size']['tick_mark'], 'fill' => self::$c['color']['text'], 'text-anchor' => 'middle'));712 $g_lines = $this->svg_dom->make_g(array('stroke' => self::$c['color']['body'], 'stroke-width' => 1));713 for($i = 0; $i < $this->i['mark_count']; $i++)714 {715 $px_from_left = $left_start + ($tick_width * $i);716 if($i != 0)717 {718 $show_numbers && $this->svg_dom->add_text_element($display_value, array('x' => $px_from_left + 2, 'y' => ($top_end + 5 + self::$c['size']['tick_mark'])), $g);719 $this->svg_dom->add_element('line', array('x1' => ($px_from_left + 2), 'y1' => ($top_start), 'x2' => ($px_from_left + 2), 'y2' => ($top_end - 5), 'stroke-dasharray' => '5,5'), $g_lines);720 $this->svg_dom->add_element('line', array('x1' => ($px_from_left + 2), 'y1' => ($top_end - 4), 'x2' => ($px_from_left + 2), 'y2' => ($top_end + 5)), $g_lines);721 }722 $display_value += $increment;723 }724 }725 else726 {727 $tick_width = round(($top_end - $top_start) /​ $this->i['mark_count']);728 $px_from_left_start = $left_start - 5;729 $px_from_left_end = $left_start + 5;730 $display_value = 0;731 $g_lines = $this->svg_dom->make_g(array('stroke' => self::$c['color']['notches'], 'stroke-width' => 1, 'stroke-dasharray' => '5,5'));732 $g_lines_2 = $this->svg_dom->make_g(array('stroke' => self::$c['color']['notches'], 'stroke-width' => 1));733 $g_background_lines = $this->svg_dom->make_g(array('stroke' => self::$c['color']['body_light'], 'stroke-width' => 1, 'stroke-dasharray' => '5,5'));734 $g_text = $this->svg_dom->make_g(array('font-size' => self::$c['size']['tick_mark'], 'fill' => self::$c['color']['text'], 'text-anchor' => 'end'));735 for($i = 0; $i < $this->i['mark_count']; $i++)736 {737 $px_from_top = round($top_end - ($tick_width * $i));738 if($i != 0)739 {740 $show_numbers && $this->svg_dom->add_text_element($display_value, array('x' => ($px_from_left_start - 4), 'y' => round($px_from_top + (self::$c['size']['tick_mark'] /​ 2))), $g_text);741 if($this->i['show_background_lines'])742 {743 $this->svg_dom->add_element('line', array('x1' => ($px_from_left_end + 6), 'y1' => ($px_from_top + 1), 'x2' => ($this->i['graph_left_end']), 'y2' => ($px_from_top + 1)), $g_background_lines);744 }745 $this->svg_dom->add_element('line', array('x1' => ($left_start), 'y1' => ($px_from_top + 1), 'x2' => ($left_end), 'y2' => ($px_from_top + 1)), $g_lines);746 $this->svg_dom->add_element('line', array('x1' => ($left_start - 4), 'y1' => ($px_from_top + 1), 'x2' => ($left_start + 4), 'y2' => ($px_from_top + 1)), $g_lines_2);747 }748 $display_value += $increment;749 }750 }751 }752 protected function render_graph_identifiers()753 {754 return;755 }756 protected function render_graph_result()757 {758 return;759 }760 protected function graph_key_height()761 {762 if((count($this->results) < 2 || $this->i['show_graph_key'] == false) && !$this->is_multi_way_comparison) /​/​ TODO likely should be OR763 {764 return 0;765 }766 $this->i['key_line_height'] = 16;767 $ak = array_keys($this->results);768 $this->i['key_item_width'] = 20 + self::text_string_width(pts_strings::find_longest_string($ak), self::$c['size']['key']);769 $this->i['keys_per_line'] = max(1, floor(($this->i['graph_left_end'] - $this->i['left_start']) /​ $this->i['key_item_width']));770 return ceil(count($this->results) /​ $this->i['keys_per_line']) * $this->i['key_line_height'];771 }772 protected function render_graph_key()773 {774 if($this->i['key_line_height'] == 0)775 {776 return;777 }778 $y = $this->i['top_start'] - $this->graph_key_height() - 7;779 $i = 0;780 $g_rect = $this->svg_dom->make_g(array('stroke' => self::$c['color']['notches'], 'stroke-width' => 1));781 $g_text = $this->svg_dom->make_g(array('font-size' => self::$c['size']['key'], 'text-anchor' => 'start', 'font-weight' => 'bold'));782 if(!is_array($this->results))783 {784 return false;785 }786 foreach(array_keys($this->results) as $title)787 {788 if(!empty($title))789 {790 $this_color = $this->get_paint_color($title);791 if($i != 0 && $i % $this->i['keys_per_line'] == 0)792 {793 $y += $this->i['key_line_height'];794 }795 $x = $this->i['left_start'] + 13 + ($this->i['key_item_width'] * ($i % $this->i['keys_per_line']));796 $this->svg_dom->add_element('rect', array('x' => ($x - 13), 'y' => ($y - 5), 'width' => 10, 'height' => 10, 'fill' => $this_color), $g_rect);797 $this->svg_dom->add_text_element($title, array('x' => $x, 'y' => ($y + 4), 'fill' => $this_color), $g_text);798 $i++;799 }800 }801 }802 protected function draw_arrow($tip_x1, $tip_y1, $tail_x1, $tail_y1, $background_color, $border_color = null, $border_width = 0)803 {804 $is_vertical = ($tip_x1 == $tail_x1);805 if($is_vertical)806 {807 /​/​ Vertical arrow808 $arrow_length = sqrt(pow(($tail_x1 - $tip_x1), 2) + pow(($tail_y1 - $tip_y1), 2));809 $arrow_length_half = $arrow_length /​ 2;810 $arrow_points = array(811 $tip_x1 . ',' . $tip_y1,812 ($tail_x1 + $arrow_length_half) . ',' . $tail_y1,813 ($tail_x1 - $arrow_length_half) . ',' . $tail_y1814 );815 }816 else817 {818 /​/​ Horizontal arrow819 $arrow_length = sqrt(pow(($tail_x1 - $tip_x1), 2) + pow(($tail_y1 - $tip_y1), 2));820 $arrow_length_half = $arrow_length /​ 2;821 $arrow_points = array(822 $tip_x1 . ',' . $tip_y1,823 $tail_x1 . ',' . ($tail_y1 + $arrow_length_half),824 $tail_x1 . ',' . ($tail_y1 - $arrow_length_half)825 );826 }827 $this->svg_dom->add_element('polygon', array('points' => implode(' ', $arrow_points), 'fill' => $background_color, 'stroke' => $border_color, 'stroke-width' => $border_width));828 }829 protected static function text_string_width($string, $size)830 {831 $dimensions = pts_svg_dom::estimate_text_dimensions($string, $size);832 return $dimensions[0];833 }834 protected static function text_string_height($string, $size)835 {836 $dimensions = pts_svg_dom::estimate_text_dimensions($string, $size);837 return $dimensions[1];838 }839 protected function note_display_height()840 {841 /​/​ This basically figures out how many lines of notes there are times the size of the font key...842 /​/​ additionally, it attempts to figure out if the note will word-wrap to additional lines to accomodate that843 $note_height = 0;844 $sections = array();845 if(!empty($this->i['notes']))846 {847 foreach($this->i['notes'] as $note)848 {849 /​/​ If the note isn't at least 36 characters long, assume it's not long enough to word-wrap, so take short-cut for efficiency850 $note_height += !isset($note['note'][36]) ? (self::$c['size']['key'] + 2) : (ceil(self::text_string_width($note['note'], self::$c['size']['key']) /​ ($this->i['graph_width'] - 14))) * self::$c['size']['key'];...

Full Screen

Full Screen

pts_svg_dom

Using AI Code Generation

copy

Full Screen

1require_once(PTS_CORE_PATH . 'pts-svg-dom.php');2require_once(PTS_CORE_PATH . 'pts-result-file-analyzer.php');3require_once(PTS_CORE_PATH . 'pts-result-file-parser.php');4require_once(PTS_CORE_PATH . 'pts-result-file-output.php');5require_once(PTS_CORE_PATH . 'pts-result-file-analyzer.php');6require_once(PTS_CORE_PATH . 'pts-result-file-parser.php');7require_once(PTS_CORE_PATH . 'pts-result-file-output.php');8require_once(PTS_CORE_PATH . 'pts-result-file-analyzer.php');9require_once(PTS_CORE_PATH . 'pts-result-file-parser.php');10require_once(PTS_CORE_PATH . 'pts-result-file-output.php');11require_once(PTS_CORE_PATH . 'pts-result-file-analyzer.php');12require_once(PTS_CORE_PATH . 'pts-result-file-parser.php');13require_once(PTS_CORE_PATH . 'pts-result-file-output.php');14require_once(PTS_CORE_PATH . 'pts-result-file-analyzer.php');15require_once(PTS_CORE_PATH . 'pts-result-file-parser.php');16require_once(PTS_CORE_PATH . 'pts-result-file-output.php');17require_once(PTS_CORE_PATH . 'pts

Full Screen

Full Screen

pts_svg_dom

Using AI Code Generation

copy

Full Screen

1$dom = new pts_svg_dom();2$dom->load('1.svg');3$dom->save('2.svg');4$dom = new pts_svg_dom();5$dom->load('2.svg');6$dom->save('3.svg');7$dom = new pts_svg_dom();8$dom->load('3.svg');9$dom->save('4.svg');10$dom = new pts_svg_dom();11$dom->load('4.svg');12$dom->save('5.svg');13$dom = new pts_svg_dom();14$dom->load('5.svg');15$dom->save('6.svg');16$dom = new pts_svg_dom();17$dom->load('6.svg');18$dom->save('7.svg');19$dom = new pts_svg_dom();20$dom->load('7.svg');21$dom->save('8.svg');22$dom = new pts_svg_dom();23$dom->load('8.svg');24$dom->save('9.svg');25$dom = new pts_svg_dom();26$dom->load('9.svg');27$dom->save('10.svg');28$dom = new pts_svg_dom();29$dom->load('10.svg');30$dom->save('11.svg');31$dom = new pts_svg_dom();32$dom->load('11.svg');33$dom->save('12.svg');

Full Screen

Full Screen

pts_svg_dom

Using AI Code Generation

copy

Full Screen

1require_once('pts_svg_dom.php');2$svg = new pts_svg_dom(100, 100);3$svg->add_element('rect', array('x'=>0, 'y'=>0, 'width'=>100, 'height'=>100, 'fill'=>'#000000'));4$svg->add_element('circle', array('cx'=>50, 'cy'=>50, 'r'=>40, 'fill'=>'#ff0000'));5$svg->add_element('text', array('x'=>50, 'y'=>50, 'fill'=>'#ffffff', 'text-anchor'=>'middle', 'dominant-baseline'=>'middle'), 'Hello World');6$svg->render();7SVG DOM: Creating SVGs in PHP (Part 1)

Full Screen

Full Screen

pts_svg_dom

Using AI Code Generation

copy

Full Screen

1include_once('pts_svg_dom.php');2$svg = new pts_svg_dom();3$svg->set_width(1000);4$svg->set_height(1000);5$svg->set_style('background-color:#ffffff');6$circle = $svg->add_circle(100,100,50);7$circle->set_style('fill:#ff0000');8$rect = $svg->add_rect(200,100,50,50);9$rect->set_style('fill:#00ff00');10$ellipse = $svg->add_ellipse(300,100,50,50);11$ellipse->set_style('fill:#0000ff');12$line = $svg->add_line(400,100,450,150);13$line->set_style('stroke:#000000');14$points = array(500,100,550,150,500,150);15$polygon = $svg->add_polygon($points);16$polygon->set_style('fill:#00ffff');17$points = array(600,100,650,150,600,150);18$polyline = $svg->add_polyline($points);19$polyline->set_style('fill:#ff00ff');20$text = $svg->add_text(700,100,'Hello World!');21$text->set_style('fill:#000000');22$path = $svg->add_path('M800 100 L850 150 L800 150 z');23$path->set_style('fill:#ffff00');24$group = $svg->add_group();25$group->set_id('group1');26$group->set_style('fill:#ff0000');27$circle = $group->add_circle(100,200,50);28$circle->set_style('fill:#ff0000');29$rect = $group->add_rect(200,200,50,50);30$rect->set_style('fill:#00ff00');

Full Screen

Full Screen

pts_svg_dom

Using AI Code Generation

copy

Full Screen

1$svg = new pts_svg_dom();2$svg->set_width(500);3$svg->set_height(500);4$circle = $svg->create_circle(250, 250, 50, array('fill' => 'red'));5$svg->add_element($circle);6$svg->add_text(250, 250, 'Hello World', array('text-anchor' => 'middle', 'font-size' => 15, 'fill' => 'white'));7$svg->save('2.svg');8$svg = new pts_svg_dom();9$svg->set_width(500);10$svg->set_height(500);11$circle = $svg->create_circle(250, 250, 50, array('fill' => 'red'));12$svg->add_element($circle);13$svg->add_text(250, 250, 'Hello World', array('text-anchor' => 'middle', 'font-size' => 15, 'fill' => 'white'));14$svg->save('3.svg');15$svg = new pts_svg_dom();16$svg->set_width(500);17$svg->set_height(500);18$circle = $svg->create_circle(250, 250, 50, array('fill' => 'red'));19$svg->add_element($circle);20$svg->add_text(250, 250, 'Hello World', array('text-anchor' => 'middle', 'font-size' => 15, 'fill' => 'white'));21$svg->save('4.svg');22$svg = new pts_svg_dom();23$svg->set_width(500);24$svg->set_height(500);

Full Screen

Full Screen

pts_svg_dom

Using AI Code Generation

copy

Full Screen

1require_once('pts_svg_dom.php');2$svg = new pts_svg_dom();3$svg->set_width(1000);4$svg->set_height(1000);5$svg->add_element('circle', array('cx' => 500, 'cy' => 500, 'r' => 400, 'fill' => 'none', 'stroke' => 'black', 'stroke-width' => 5));6$svg->add_element('circle', array('cx' => 500, 'cy' => 500, 'r' => 300, 'fill' => 'none', 'stroke' => 'black', 'stroke-width' => 5));7$svg->add_element('circle', array('cx' => 500, 'cy' => 500, 'r' => 200, 'fill' => 'none', 'stroke' => 'black', 'stroke-width' => 5));8$svg->add_element('circle', array('cx' => 500, 'cy' => 500, 'r' => 100, 'fill' => 'none', 'stroke' => 'black', 'stroke-width' => 5));9$svg->add_element('circle', array('cx' => 500, 'cy' => 500, 'r' => 50, 'fill' => 'none', 'stroke' => 'black', 'stroke-width' => 5));10$svg->add_element('circle', array('cx' => 500, 'cy' => 500, 'r' => 25, 'fill' => 'none', 'stroke' => 'black', 'stroke-width' => 5));11$svg->add_element('line', array('x1' => 500, 'y1' => 500, 'x2' => 1000, 'y2' => 500, 'stroke' => 'black', 'stroke-width' => 5));12$svg->add_element('line', array('x1' => 500, 'y1' => 500, 'x2' => 0, 'y2' => 500, 'stroke' => 'black', 'stroke-width' => 5));13$svg->add_element('line', array('x1' => 500, 'y1' => 500, 'x2' => 500,

Full Screen

Full Screen

pts_svg_dom

Using AI Code Generation

copy

Full Screen

1require_once(PTS_CORE_PATH . 'pts_svg_dom.php');2$svg = new pts_svg_dom();3$svg->width = 500;4$svg->height = 500;5$svg->title = 'SVG DOM Document';6$svg->style = 'rect {fill: #0000FF; stroke: #000000; stroke-width: 2; }';7<rect x="340" y="340" width="100" height="100" /​>';8echo $svg->output_svg();9require_once(PTS_CORE_PATH . 'pts_svg_dom.php');10$svg = new pts_svg_dom();

Full Screen

Full Screen

pts_svg_dom

Using AI Code Generation

copy

Full Screen

1require_once('pts_svg_dom.php');2require_once('pts_svg_dom_gd.php');3$svg = new pts_svg_dom_gd(500, 500, 'white');4$svg->draw_rect(100, 100, 300, 300, 'black', 1, 'red');5$svg->save('test.svg');6$svg->display();7require_once('pts_svg_dom.php');8require_once('pts_svg_dom_gd.php');9$svg = new pts_svg_dom_gd(500, 500, 'white');10$svg->draw_rect(100, 100, 300, 300, 'black', 1, 'red');11$svg->draw_line(100, 100, 400, 400, 'black', 1);12$svg->draw_circle(250, 250, 100, 'black', 1, 'blue');13$svg->save('test.svg');14$svg->display();15require_once('pts_svg_dom.php');16require_once('pts_svg_dom_gd.php');17$svg = new pts_svg_dom_gd(500, 500, 'white');18$svg->draw_rect(100, 100, 300, 300, 'black', 1, 'red');19$svg->draw_line(100, 100, 400, 400, 'black', 1);20$svg->draw_circle(250, 250, 100, 'black', 1, 'blue');21$svg->draw_polygon(array(100, 100, 200, 200, 300, 100), 'black', 1, 'green');22$svg->save('test.svg');23$svg->display();

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Three Techniques for Improved Communication and Testing

Anyone who has worked in the software industry for a while can tell you stories about projects that were on the verge of failure. Many initiatives fail even before they reach clients, which is especially disheartening when the failure is fully avoidable.

Developers and Bugs &#8211; why are they happening again and again?

Entering the world of testers, one question started to formulate in my mind: “what is the reason that bugs happen?”.

How To Handle Multiple Windows In Selenium Python

Automating testing is a crucial step in the development pipeline of a software product. In an agile development environment, where there is continuous development, deployment, and maintenance of software products, automation testing ensures that the end software products delivered are error-free.

Fault-Based Testing and the Pesticide Paradox

In some sense, testing can be more difficult than coding, as validating the efficiency of the test cases (i.e., the ‘goodness’ of your tests) can be much harder than validating code correctness. In practice, the tests are just executed without any validation beyond the pass/fail verdict. On the contrary, the code is (hopefully) always validated by testing. By designing and executing the test cases the result is that some tests have passed, and some others have failed. Testers do not know much about how many bugs remain in the code, nor about their bug-revealing efficiency.

And the Winner Is: Aggregate Model-based Testing

In my last blog, I investigated both the stateless and the stateful class of model-based testing. Both have some advantages and disadvantages. You can use them for different types of systems, depending on whether a stateful solution is required or a stateless one is enough. However, a better solution is to use an aggregate technique that is appropriate for each system. Currently, the only aggregate solution is action-state testing, introduced in the book Paradigm Shift in Software Testing. This method is implemented in Harmony.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful