Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for advanced options during Export #50

Closed
ghjansen opened this issue Aug 19, 2019 · 6 comments
Closed

Support for advanced options during Export #50

ghjansen opened this issue Aug 19, 2019 · 6 comments

Comments

@ghjansen
Copy link
Owner

ghjansen commented Aug 19, 2019

When exporting the simulation as an image, support the following options:

  1. Cell scale: square root of the amount of pixels representing 1 cell (Type: Integer)
  2. Show grid lines: configuration for inclusion or exclusion of the lines of the grid of cells (Type: Boolean)
  3. Grid lines thickness: the amount of pixels to be used as grid line thickness (Type: Integer)
  4. Grid lines colour: the colour of the lines of the grid of cells (Type: String)
@ghjansen ghjansen self-assigned this Aug 19, 2019
@ghjansen ghjansen added this to Backlog in Blog via automation Aug 19, 2019
@ghjansen
Copy link
Owner Author

ghjansen commented Aug 19, 2019

Case Study 1: Cell Scale

Input: The integer informed as value of Cell Scale is the square root of the total amount of pixels to be used to represent a single cell during the construction of the image.

Logic: Each cell present in the simulation should be translated to a square of pixels, where the size of the square is equivalent to the value informed in the input. All the pixels of the square must have the same colour of the cell. All squares must follow the same distribution as the original grid.

Output: An image of the simulated grid of cells that is equals to or greater than the simulated area, scaled to the value informed.

Example Simulation size Cell Scale Total of pixels per cell Pixels Arrangement Exported image
0 100x100 -1 (invalid) - - -
1 100x100 0 (invalid) - - -
2 100x100 1 1 cell1 100x100px
3 100x100 2 4 cell2 200x200px
4 100x100 3 9 cell3 300x300px
5 100x100 4 16 cell4 400x400px
6 100x100 5 25 cell5 500x500px

(Edit: see #56 (comment) for the outcome)

@ghjansen
Copy link
Owner Author

ghjansen commented Aug 24, 2019

Case Study 2: Show grid lines

Input: A binary choice between "Yes" and "No", where "Yes" means that the grid lines must be included in the image to be exported, while "No" means that the grid lines must be excluded from the image to be exported. This option will be available only if the value informed for Cell Scale is greater or equals to 3. If the Cell Scale informed is less than 3, the component must be disabled, and no grid lines will be included.

Logic: The following axioms will be considered as a definition of Grid:

  1. A grid must surround with lines the cellular space as a frame.
  2. A grid must separate with lines a cell from the cells of its neighbourhood.
  3. A grid must keep the cellular space with the same size as when there is no grid.
  4. A grid must preserve the state of all cells of the cellular space while 1, 2 and 3.

The following table contains attempts of applying the axioms using the examples 2, 3, 4, 5 and 6 of Case Study 1, considering that each attempt uses a cellular space of 9 cells, each cell with the correspondent Cell Scale in pixels, as defined per example. All cells are notated with X(I,J), where X is the cell number, I the line of the cellular space and J the column of the cellular space.

Attempt Example Result
1 2

AdvancedExportOptions1

2 3

AdvancedExportOptions2

3 4

AdvancedExportOptions3

4 5

AdvancedExportOptions4

5 6

AdvancedExportOptions5

  • Result of attempt 1: With only 1 pixel per cell, it is not possible to apply any of the 4 axioms.
  • Result of attempt 2: With 4 pixels per cell, it is possible to apply only axiom 1, but none of the other 3.
  • Result of attempt 3: With 9 pixels per cell, it is possible to apply all 4 axioms, therefore, Cell Scale equals to 3 is the lowest value that supports grid lines.
  • Result of attempt 4: With 16 pixels per cell, it is possible to apply all 4 axioms, therefore, Cell Scale equals to 4 is the second lowest value that supports grid lines.
  • Result of attempt 5: With 25 pixels per cell, it is possible to apply all 4 axioms, therefore, Cell Scale equals to 5 is the third lowest value that supports grid lines.

Overall, the attempts 3, 4 and 5 managed to surround with lines the cellular space as a frame, separate with lines a cell from the cells of its neighbourhood, keep the cellular space with the same size as when there is no grid while preserving the state of all cells of the cellular space. (Axioms 1, 2, 3 and 4)

The successful attempts 3, 4 and 5 also disclosed 3 patterns:

  1. All cells receive the grid as their first column and last line of pixels (as a "L" shape);
  2. The cellular space can close the grid by using the first line and last column of pixels;
  3. The first line and last column of cells will be slightly smaller than all the other cells. Also, the last cell in the first line will be the smallest cell in the cellular space.

The patterns 1 and 2 can be used as steps of the algorithm.

Output: An image of the simulated grid of cells that is equals to or greater than the simulated area, scaled to the value informed in Cell Scale, which includes the grid lines if the value informed in Cell Scale is greater or equals to 3, and Show grid lines is configured with the value "Yes".

(Edit: see #57 (comment) for the outcome)

@ghjansen
Copy link
Owner Author

ghjansen commented Aug 27, 2019

Case Study 3: Grid lines thickness

Input: The integer informed as value of Grid lines thickness represents the thickness to be used in the grid lines of the cellular space. The lowest value possible is equals to 1, and the highest value possible is described by the formula t = (c-1)/2, where t represents Grid lines thickness and c represents the value informed as Cell Scale (from Case Study 1). This component is enabled only when the component Show grid lines (from Case Study 2) is enabled and configured with the option "Yes", and the Cell Scale informed is greater or equals to 5.

Logic: The 4 axioms defined in Case Study 2 must remain valid and applicable to the variations in grid lines thickness. All 5 attempts of applying the axioms through different Cell Scales considered thickness equals to 1 (pixel), even though disclosed 3 patterns, in which the first and third are of great relevance for the current case study:

  1. All cells receive the grid as their first column and last line of pixels (as a "L" shape);
  1. The first line and last column of cells will be slightly smaller than all the other cells. Also, the last cell in the first line will be the smallest cell in the cellular space.

Considering the pattern above and the successful attempts (3, 4 and 5) from Case Study 2, it is possible to notice a new pattern which determines the shape of the grid lines in every cell. Considering any of the cellular spaces from the successful attempts, it is possible to assume that for the cells 1 and 2, the grid uses the first and last lines of pixels from the cell, and also the fist column, in a "C" like shape. In the cells 6 and 9, the grid uses the first and last column of pixels, and also the last line, in a "U" like shape. In the cells 4, 5, 7 and 8, the grid uses the first column of pixels, and also the last line, in a "L" like shape. Finally, in the cell 3, the grid uses the first and last line of pixels, and also the first and last column, in a "O" like shape.

Aware of this 4 possible shapes of the grid within a cellular space, it is possible to assume that the real area of the cell is calculated through the formula a = (c^2) - (c-1) * l, where a represents the area of the cell not occupied by the grid, c represents the Cell Scale and l is the amount of grid lines within the cell. The following shows the grid area calculated per grid shape using the cellular space of attempt 5 from Case Study 2:

Cell with grid shape "O":

a = (c^2) - (c-1) * l
a = (5^2) - (5-1) * 4
a = (25) - 4 * 4
a = 25 - 16
a = 9

Cell with grid shape "L":

a = (c^2) - (c-1) * l
a = (5^2) - (5-1) * 2
a = (25) - 4 * 2
a = 25 - 8
a = 17

Cell with grid shape "U":

a = (c^2) - (c-1) * l
a = (5^2) - (5-1) * 3
a = (25) - 4 * 3
a = 25 - 12
a = 13

Cell with grid shape "C":

a = (c^2) - (c-1) * l
a = (5^2) - (5-1) * 3
a = (25) - 4 * 3
a = 25 - 12
a = 13

Giving that the cell with grid shape "O" is the one with the smallest area in the cellular space, this cell is the reference for evaluating the higher limit of Grid lines thickness, as this is the first cell to potentially violate the axiom 4 as the thickness increases. Thus, the goal is to ensure that the state of the cell will be preserved by at least 1 of the pixels of the cell, e.g. the cell 3 in the attempt 3 of Case Study 2.

As the cell with grid shape "O" increases the grid thickness from all 4 sides towards the center equally, it is possible to assume only 2 sides for the investigation, as the other 2 sides will be simply a reflection in a different orientation. Given the first and last columns of a cell, each time the grid lines increases, they occupy the columns that are free towards the center. By repeating that process, when it hits the center it is possible that: 1 - exactly 1 pixel is left as cell and all the other pixels are grid (this happens if the Cell Scale informed is a uneven number) or, 2 - no pixel is left as cell and all the other pixels are grid (this happens if the Cell Scale informed is a even number). Situation 2 must be avoided.

Since at least 1 pixel must be left as the area of the cell, the Cell Scale must account that by subtracting 1 from the amount informed.

Example: 5 - 1 = 4 (5 pixels as Cell Scale, 1 pixel as cell, 4 pixels as grid)

Now still considering the example above, if 4 pixels are used as grid, 2 pixels are occupied at one side of the 1 pixel representing the cell, and 2 pixels are occupied in the other side of that same pixel. So by dividing this amount by 2, the result is the maximum of thickness allowed.

The above is the logic behind the formula: t = (c-1)/2, where t represents Grid lines thickness and c represents the value informed as Cell Scale (from Case Study 1).

Output: An image of the simulated grid of cells that is equals to or greater than the simulated area, scaled to the value informed in Cell Scale, which includes the grid lines if the value informed in Cell Scale is greater or equals to 3, and Show grid lines is configured with the value "Yes". The grid lines thickness will be equals to 1 pixel for when the Cell Scale informed is 3 or 4, and equals to the allowed values from t = (c-1)/2 when Cell Scale is greater or equals to 5.

(Edit: see #59 (comment) for the outcome)

@ghjansen
Copy link
Owner Author

ghjansen commented Aug 31, 2019

Case Study 4: Grid lines colour

Input: A String in hexadecimal format representing the RGB colour to be used by the grid lines. This component is enabled only when the component Show grid lines (from Case Study 2) is enabled and configured with the option "Yes".

Logic: All grid lines must be created using the valid RGB colour informed, with no alpha, gradient or pattern. Just solid colour equally distributed through all lines.

Output: An image of the simulated grid of cells that is equals to or greater than the simulated area, scaled to the value informed in Cell Scale, which includes the grid lines if the value informed in Cell Scale is greater or equals to 3, and Show grid lines is configured with the value "Yes". The grid lines thickness will be equals to 1 pixel for when the Cell Scale informed is 3 or 4, and equals to the allowed values from t = (c-1)/2 when Cell Scale is greater or equals to 5. The grid lines colour will be the RGB informed through Grid lines colour.

(Edit: see #60 (comment) for the outcome)

@ghjansen
Copy link
Owner Author

Summary of progress and outcome per Case Study:

Case Study 1 (Cell Scale): #56 (comment)
Case Study 2 (Show grid lines): #57 (comment)
Case Study 3 (Grid lines thickness): #59 (comment)
Case Study 4 (Grid lines colour): #60 (comment)

@ghjansen
Copy link
Owner Author

Closed via #53 #61 #62 #63 #64 #65 .

Blog automation moved this from Backlog to Done Oct 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Blog
  
Done
Development

No branches or pull requests

1 participant