logo
down
shadow

Calculate New Height Based On New Width?


Calculate New Height Based On New Width?

By : Santu
Date : October 15 2020, 11:12 PM
I wish this help you I have a control whose width is 500 and height is 240, and I want to maintain the aspect ratio. , Algebra tells us it should be:
code :


Share : facebook icon twitter icon
Calculate text width based on available height?

Calculate text width based on available height?


By : user3152885
Date : March 29 2020, 07:55 AM
Hope this helps what you can do is to measure a string in a default size with this method: (g is a Graphics Object)
code :
g.MeasureString("area", Font, maxWidth)
float measureFontSize = 5;
SizeF measuredBox = g.MeasureString("my string", new Font("Arial", measureFontSize));
double measuredProportion = measuredBox.Width / measuredBox.Height;

double expectedWidth = measuredProportion * wishedHeight;
How to calculate proportional width of an image based on its height?

How to calculate proportional width of an image based on its height?


By : SGRoeh
Date : March 29 2020, 07:55 AM
may help you . How to calculate proportional width of an image based on its height? , With known height and width:
code :
var ratio = image.Height / image.Width;
var width = image.Height / ratio;
var height = image.Width * ratio;
Calculate height of banner based on width

Calculate height of banner based on width


By : karan khanna
Date : March 29 2020, 07:55 AM
Any of those help It might be possible to do this with CSS alone. The problem with @media rules is that you'd need one for each pixel width, which isn't viable. So you could try this instead:
Firstly, change the wrapper div here:
code :
<div align="center">
<div class="pluswrap">
.pluswrap {
text-align: center;
padding-bottom: 30%;
height: 0;
position: relative;
}
Calculate the price based on height and width

Calculate the price based on height and width


By : Darshan Kale
Date : March 29 2020, 07:55 AM
will be helpful for those in need let's say that you want to do it on the product ID N° 1 from the product page : first add two inputs fields in your product.tpl ( or in your module.tpl called in product.tpl)
code :
<input name="height"><br>
<input name="width">
$id_product = 1;    
$newPrice = 0;
$height = Tools::getValue('height');
$width = Tools::getValue('width');

//Price rules (change with your rules)
if($height > 10 && $width > 10) $newPrice = 10;

    $specific_price = new SpecificPrice();
    $specific_price->price = $newPrice;
    $specific_price->id_cart = (int) $this->context->cart->id;
    $specific_price->id_shop = 0;
    $specific_price->id_shop_group = 0;
    $specific_price->id_currency = 0;
    $specific_price->id_country = 0;
    $specific_price->id_group = 0;
    $specific_price->id_customer = (int) $this->context->customer->id;
    $specific_price->id_product = (int)$id_product;
    $specific_price->id_product_attribute = 0;
    $specific_price->from_quantity = 1;
    $specific_price->reduction = 0;
    $specific_price->reduction_type = 'amount';
    $specific_price->from = '0000-00-00 00:00:00';
    $specific_price->to = '0000-00-00 00:00:00';
    $specific_price->add();
    $cart->id_lang = (int)($this->context->cookie->id_lang);
    $cart->id_currency = (int)($this->context->cookie->id_currency);
    $cart->updateQty($qte, $id_product);
class OrderConfirmationController extends OrderConfirmationControllerCore
{
    public $ssl = true;
    public $php_self = 'order-confirmation';
    public $id_cart;
    public $id_module;
    public $id_order;
    public $reference;
    public $secure_key;

    public function getPriceBack($id_product){

        $normalPrice = Product::getPriceStatic($id_product);

        $specific_price = new SpecificPrice();
        $specific_price->price = $normalPrice;
        $specific_price->id_cart = (int) $this->context->cart->id;
        $specific_price->id_shop = 0;
        $specific_price->id_shop_group = 0;
        $specific_price->id_currency = 0;
        $specific_price->id_country = 0;
        $specific_price->id_group = 0;
        $specific_price->id_customer = (int) $this->context->customer->id;
        $specific_price->id_product = (int)$id_product;
        $specific_price->id_product_attribute = 0;
        $specific_price->from_quantity = 1;
        $specific_price->reduction = 0;
        $specific_price->reduction_type = 'amount';
        $specific_price->from = '0000-00-00 00:00:00';
        $specific_price->to = '0000-00-00 00:00:00';
        $specific_price->add();

    }

    public function init()
    {
        parent::init();

        $this->id_cart = (int)(Tools::getValue('id_cart', 0));
        $is_guest = false;

        /* get normal price back */
        $id_product = 1;
        self::getPriceBack($id_product);

        /* check if the cart has been made by a Guest customer, for redirect link */
        if (Cart::isGuestCartByCartId($this->id_cart)) {
            $is_guest = true;
            $redirectLink = 'index.php?controller=guest-tracking';
        } else {
            $redirectLink = 'index.php?controller=history';
        }

        $this->id_module = (int)(Tools::getValue('id_module', 0));
        $this->id_order = Order::getOrderByCartId((int)($this->id_cart));
        $this->secure_key = Tools::getValue('key', false);
        $order = new Order((int)($this->id_order));
        if ($is_guest) {
            $customer = new Customer((int)$order->id_customer);
            $redirectLink .= '&id_order='.$order->reference.'&email='.urlencode($customer->email);
        }
        if (!$this->id_order || !$this->id_module || !$this->secure_key || empty($this->secure_key)) {
            Tools::redirect($redirectLink.(Tools::isSubmit('slowvalidation') ? '&slowvalidation' : ''));
        }
        $this->reference = $order->reference;
        if (!Validate::isLoadedObject($order) || $order->id_customer != $this->context->customer->id || $this->secure_key != $order->secure_key) {
            Tools::redirect($redirectLink);
        }
        $module = Module::getInstanceById((int)($this->id_module));
        if ($order->module != $module->name) {
            Tools::redirect($redirectLink);
        }
    }
}
    $this->context->cart->deleteProduct(1);

    Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'specific_price WHERE  id_customer='.(int)$this->context->customer->id);
Calculate height of div based off width & maintain proportion

Calculate height of div based off width & maintain proportion


By : E-l Pedro
Date : October 13 2020, 06:00 AM
seems to work fine Maintaining specific height:width ratios in CSS is usually done by exploiting the fact that padding percentage is always calculated based on the element's width.
For example, let's say you had an element with width: 500px, height: 300px and padding: 10%. Now you might expect the top and bottom paddings to be 10% of height, and the left and right paddings to be 10% of width. However this would give unequal vertical and horizontal paddings which is counter-intuitive to what is intended - equal paddings of 10%. To make sense of this we need to base the padding percentage on the save dimension, and that dimension has been chosen to be the width.
code :
width: 33%;
height: 0;
padding-bottom: 24.75%;
footer {
  max-width: 1000px;
  margin: 0 auto;
  background-color: rgba(0, 0, 0, 0.171);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}
footer div {
  background-image: url('https://learnwebdesign.online/img/bg.jpg');
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  position: relative;
  width: 33%;
  height: 0;
  padding-bottom: 24.75%;
}
footer div span {
  /* Used as content wrapper, with flex to centre content */
  position: absolute;
  top: 0; bottom: 0;
  left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background-color: rgba(165, 165, 165, 0.282);
  padding: 7px 15px;
  border-radius: 3px;
  color: #FFFFFF;
  text-transform: uppercase;
  font-weight: bold;
  letter-spacing: 2px;
  font-size: 21px;
}
<footer>
  <div><span>left photo</span></div>
  <div><span>center photo</span></div>
  <div><span>right photo and more text</span></div>
</footer>
Related Posts Related Posts :
  • Use SHIFT + ENTER for multiline textbox in UWP
  • Trying to sync data from third party api
  • Use Array.Sort to only sort elements and not index numbers?
  • Access Identity Password Options after Configure Services
  • How to fill DataGrid with DataTable content in UWP c#
  • How do you add the equivalent of the OwnedAttribute using FluentAPI?
  • aspNetCore 2.2.0 - AspNetCoreModuleV2 error
  • Two Groups with the same sAMAccountName, using FindOne() to getting the second occurance of group
  • How does MVC routing detects file path
  • What is the most elegant way to add some XML Elements to the XML produced by DataTable.WriteXML (C#)
  • How to download attachment from email sent to google group mail address
  • Deserialization not filling my variables/response.data shows null
  • Check if instance of class exists with certain property
  • C# WPF Livecharts Formatter
  • Modify method logic MOQ
  • C# Group nested lists
  • Ancestor binding works only once in ListView
  • Loading data from different models
  • Xamarin Forms Post Request Body
  • Crop image from X and Y?
  • How do I fix C# Error cs0103 in Visual Studio 2017?
  • How to merge Worksheets from Multiple Workbooks into New WorkBook
  • Zip collections matching by ID
  • Visual Studio 2017 - Diagostic tool - Heap profiling affects program memory consumption
  • How to detect Collision only once Unity 3D?
  • Get certain value from JSON string
  • How to run BackgroundService on a timer in ASP.NET Core 2.1
  • How to manipulate a url to access a parent directory
  • XUnit Asserting Exceptions In Debug Mode In Visual Studio
  • Generate the shortest alphanumeric save code
  • WPF Combobox with checkboxes inside
  • How to Sort Variables and Use it Properly in Unity?
  • What to deal with multiple asynchronous method invocations in C#
  • ASP.NET Core MVC Dropdown box with single select
  • SixLabors/ImageSharp breaks down some jpegs
  • Prism Module + Entity Framework sharing one databse connection
  • Rename a set of files using the information present in a txt file
  • How to set button to column number 2 in datagridview (windows form application)
  • StyleCop : Warning not suppressed
  • Retrieve different groups of values in a regex
  • Selenium getting attribute/ CSS / property
  • Changing content of GroupBox based on ComboBox selection
  • Seeding the database with a many-to-many relationship using Entity Framework Core
  • Displaying SQL Server table data in webform
  • Cache gets null when I try to retrieve information in another class method
  • Camera follow the player only on his Z axis Unity 3D
  • Count and Max Columns Group By in LINQ
  • How to NOT UserControl.dispose()
  • How can I retrieve the ID of the clicked button from the method handling this event into a SharePoint 2013 Web Part?
  • separate task manager for each user
  • Lists getting cleared unexpectedly after assignment
  • Generate key/Encryption/Decryption for RSACryptoProvider and BouncyCastle
  • Safest way to run query from client into sql server using Asp net
  • Multiple controller types were found that match the URL in mvc app
  • Binding WPF combobox and displaying its Value to TextBox
  • How can I create a working extension-dll for Fiddler with MS V C# 2008 EE?
  • Opening folder with no law to escape
  • C# has abstract classes and interfaces, should it also have "mixins"?
  • Specifications for DB file systems?
  • When should we not create Assembly's strong name? What are the disadvantages of "strong named assembly"?
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org