How to use Inversable features in prestashop - prestashop

This is a very special problem I met in Prestashop.
I have a product, let's say a two color wooden stick, which is a normal 10" long stick. Half of it (5") can be blue and the other half red for example.
My product is this: Two color wooden stick. I have the following features: color 1 and and color 2 .
In the admin at the product's features I check red for the color 1 and blue for color 2.
Now the problem: when user filters using layered navigation, maybe they select blue for color 1 and red for color 2. This will result displaying 0 products as our wooden stick is inverse, but in the reality it's the same product.
How could I make that possible without duplicating the wooden stick product?

I see there is mismatching, your product 10" is not blue OR red, but blue-red in same time, so set two different colors is bad idea, instead I can propose you to do next, I hope when you said that you use color features it is named in Presta backoffice attributes, there is the difference between two this things in Presta, so:
in Catalog -> Product Attributes create new P.Attribute with name Color and for last option choose Color or textures in dropdown
add new Value for this new Color p.atrribute named e.g. "blue-red" and upload texture (img) that contains both colors. Repeat this procedure as much as needed.
in Layered navigation use this new p.attribute instead old
OR
another idea, create using same way 2 different color attributes Color1 and Color2, no textures, just use real separate colors there like "red", "blue". Then in product create combinations of this two colors and assign it to product.
In this case in layered navigation you will can set 2 filters - Color1, Color2 and customers will can to choose it. But, imho, first solution is better for UX.

Related

Tableau How to color a chart based on two fields, one continuous and other discreet

I have a data set from Kaggle and here is what it looks like:
Now I want to plot a map using Tableau which illustrates the advantage/disadvantage of Republican/Democrat. Just picture this, because I have already had the total votes of each party in every single county, it is easy to compare which party won a county. My idea is depicting this fact: if a county is won by Republican, then it should be in red; if by Democrat, it would be in blue; otherwise it would be white if being won by minor parties (I am not sure whether there was such a case).
Note that if the more overwhelming a party is within a county, the darker should the color be. For example, if a Republican won a county tinily by 0.1%, it should be light red; if a county is won by Democrat with a landslide, say 30%, then it should be deep blue.
My problem now is that with the given data, I have no ideas about how to demonstrate the gap of votes between different parties. I guess I might need to create a calculated field that shows the vote difference with a county. But is it the right solution?
---- EDIT----
I found an example: https://public.tableau.com/profile/clillich.kltv#!/vizhome/ElectionResults_5/Dashboard1, it looks good to me. It is just uncertain what its data source looks like.
The example you have shown is perhaps not related to chart as you want. It shows only one measure. Please proceed like this.
Step-1 Create a calculated field win margin in percent with the following calculation
IF [Won] = TRUE then ([Total Votes] -
{FIXED [State],[County] : MAX(
IF [Won] = FALSE then [Total Votes] END )})/
{FIXED [State],[County] : SUM([Total Votes])}
END
Step-2 Convert it to dimension (by right clicking it).
Step-3 simultaneously create a group on party field as desired.
Step-4 select both fields in dimension pane and create a new hierarchy (party-group first and win margin second). Drag this heirarchy to marks card. Convert both to colors. The following gif may help
I think this serves your purpose. Good luck

Additive Color Mixing (Blending) of images in Universal Windows XAML

I have a image of a scene with default lighting. Let's call this image_baseline.
I have another image of the same scene, but an extra red spot light is added. Let's call this image_with_extra_red. Some surfaces show a lot of red, while other surfaces remain unchanged since the red spot light does not uniformly light the scene. No place in this picture is darker than the original since the default lighting was not removed, just a red spot is added.
I have another image of the same screen, but extra green light is added just like the above. Let's call this image_extra_green.
Likewise, I have image_extra_blue.
Now I have 3 variables. Percent_of_extra_red, percent_of_extra_green, percent_of_extra_blue.
I would like to add to image_baseline the proportions of the extra color lighting.
Pseudo code :
red_adder = image_with_extra_red - image_baseline; // now red_adder contains only the incremental effect of the red light
green_adder = image_with_extra_green - image_baseline;
blue_adder = image_with_extra_blue - image_baseline;
new_picture = image_baseline + (Percent_of_extra_red * red_adder ) + (Percent_of_extra_green * green_adder ) + (Percent_of_extra_blue * blue_adder )
The purpose of the above is to allow the user to control the intensity of the added red, green or blue spot light.
Hoping this can be done by overlaying 4 pictures in XAML and binding 3 variables Percent_of_extra_red , Percent_of_extra_green, and blue.
If it makes it easier, red_adder, green_adder, and blue_adder can be constructed offline with some graphic sw.

How to relate data correctly?

I have this database where I am storing clothes from different retailers:
So each product has different colors
Each product also has different sizes
Each size has also different colors
Now for each product and for each different size and color, there could be different prices.
I am using Django for this, and I am asking any thoughts on how this database relation might work out.
Would I have something like this?
class Product(models.Model):
name = model.CharField()
class Size(models.Model):
size_of_product = model.CharField()
product = model.ForeignKey(Product)
class Color(models.Model):
color_of_product = model.CharField()
product = model.ForeignKey(Product)
size = model.ManyToManyField(Size,though="Price")
class price(model.Model):
size = model.ForeignKey(Size)
color = model.ForeignKey(Color)
date =model.Date()
Could anyone please suggest me of a better solution because obviously I don't have much practice with databases yet?
Thank You!
I propose the following to be close with your initial design:
class Product(models.Model):
name = models.CharField()
class Size(models.Model):
size_of_product = models.CharField()
class Color(models.Model):
color_of_product = models.CharField()
class ProductPrice(model.Model):
size = models.ForeignKey(Size)
color = models.ForeignKey(Color)
product = modelss.ForeignKey(Product)
price = models.DecimalField(...)
With that you'll have a list of products, a list of sizes and a list of colors. Whenever you want to add a variation for a product, you'll just a new ProductPrice instance with the price of the combination of all three (product, size, color) instances.
However, as a general comment, most e-shops do not work like this since products have more characteristics than color or size (for example manufacturer or material).
So, a more general solution would be to have a Category model that defines different categories of things (f.e shoes, jackets, trousers). Each Category has a number of Characteristics (for example color or material) and each Characteristic has a number of possible Values (for example blue, brown or leather, cotton etc). Finally, your Product which will be a specific item with a price, will belong to a specific Category and have specific Values for each of the Characteristics of that Category.
class Characteristic(models.Model):
name = modes.CharField()
class Category(models.Model):
name = modes.CharField()
# Each Category can have many characteristics and each
# characteristic may be related to many categories (e.g
# both shoes and jackets have color
characteristics = models.ManyToManyField(Characteristic)
class Value(models.Model):
value = models.CharField()
# each value belongs to a specific characteristic
characteristic = models.ForeignKey(Characteristic)
class Product(models.Model):
category = models.ForeignKey(Category)
# A product will have a number of values (e.g brown, leather)
values = models.ManyToManyField(Value)
prices = models.DecimalField()
So using the above design we can support as many characteristics as we want for each of our Products.
Ok, so you're modeling clothing. (Pun absolutely intended!) Fine, let's see what we can do about that.
Each product has different colors
Fine. The entity product has an attribute color. Let's continue.
Each product also has different sizes
Fine again. The entity product has an attribute size. So far so good.
Each size has also different colors
Um. Hold on. While a product may have a size and a color, a size cannot have a color nor a color have a size. As attributes, these relate to product, not to each other. Your modeling breaks down at this point.
I think what you mean is that all colors are not available in all sizes. This is different. In this case, a color is not directly related to a product, but a product/size combination.
You have correctly identified this as a many-to-many relationship. But it is between color and an intermediate product/size combination, not directly to product.

Available Colors for SetConsoleTextAttribute

im working with SetConsoleTextAttribute API (Delphi to be specific), well anyway i cannot find a list of available colors anywhere?? can anyone help me out
There a 4 Bits used for the foreground color
FOREGROUND_BLUE; //1
FOREGROUND_GREEN; //2
FOREGROUND_RED; //4
FOREGROUND_INTENSITY; //8
which will give 16 possible colors. (0-15)
The next 4 bits are used for background color with the same scheme
See this. Colors are formed by ORing different constants. For instance:
An application can combine the foreground and background constants to
achieve different colors. For example, the following combination
results in bright cyan text on a blue background.
FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY |
BACKGROUND_BLUE
For more Turbo/Borland Pascal CRTish implementations of such, see this. The colors available in the Windows console via SetConsoleTextAttribute work out roughly to be the same ones as the CRT unit, so any more relevant details can be found there.

The best way to change background color in image in Cocoa

Little description:
I get an image from my scanner using Capture Core Framework and background color is gray. So I want to do white background.
I'm looking for best way to remove this color. I looked at Image Core Filters. And as I understood I should use those ones, but I couldn't find included/ready filterfor this task. So, Do I have to write it myself?
It means to remove color I should write my own filter and apply it to my images? Right? Thank you.
UPD: I develop for Mac os
Why not just simply change the brightness of your image? If this gray background color value is fixed then you can increase the brightness a little bit, as a preprocess step, until you're satisfied.
A filter isn't quite the right tool for the job here. Filters apply a colour-shifting algorithm, pixel by pixel, to all of the pixels in an image.
This would be appropriate in your case if there was something completely unique about the pixels that you want to turn to white. For example, if the background you wish to eliminate was in a very narrow colour range that did not occur in any other part of the image. This is the technique used in greenscreen/bluescreen filming, which only works if that green or blue colour does not occur anywhere in the image regions you want to keep.
But - as you say in one of your comments - you cannot do this as that grey level you want to get rid of will not be unique to the background, so any filter you apply that would pick out those pixes may also affect pixels in the scanned subjectmatter.
What you really need is a way to select a region of interest and apply a filter to that region alone. You could use openCV for this. In fact it has a function that can achieve your result in one go:
http://docs.opencv.org/modules/imgproc/doc/miscellaneous_transformations.html?highlight=floodfill#int
floodFill(InputOutputArray image, //image to process
Point seedPoint, //starting pixel
Scalar newVal, //New value of the repainted domain pixels
Rect* rect, //optional output param (you won't need it)
Scalar loDiff, //max lower brightness/colour diff to select
Scalar upDiff, //max upper brightness/colour diff to select
int flags) //you want FLOODFILL_FIXED_RANGE
This function starts from a seedPoint, which should be any pixel that you can guarantee will be a part of the background grey you want to eliminate. (0,0) might work for you. It then interrogates neighbouring pixels, including them in the ROI array if they are sufficiently similar. The resulting array is a connected region. If your background grey uniformly falls between loDiff and upDiff - and your subject scan has a defined edge which does NOT fall into this range, you will get your result - selection and remapping of all background pixels to newVal (white).