(shape_type, shape_args, position)
| 144 | |
| 145 | |
| 146 | def annotation_params_for_rect(shape_type, shape_args, position): |
| 147 | x0 = shape_args["x0"] |
| 148 | x1 = shape_args["x1"] |
| 149 | y0 = shape_args["y0"] |
| 150 | y1 = shape_args["y1"] |
| 151 | |
| 152 | position, pos_str = _prepare_position(position, prepend_inside=True) |
| 153 | if position == set(["inside", "top", "left"]): |
| 154 | return _df_anno("left", "top", min([x0, x1]), max([y0, y1])) |
| 155 | if position == set(["inside", "top", "right"]): |
| 156 | return _df_anno("right", "top", max([x0, x1]), max([y0, y1])) |
| 157 | if position == set(["inside", "top"]): |
| 158 | return _df_anno("center", "top", _mean([x0, x1]), max([y0, y1])) |
| 159 | if position == set(["inside", "bottom", "left"]): |
| 160 | return _df_anno("left", "bottom", min([x0, x1]), min([y0, y1])) |
| 161 | if position == set(["inside", "bottom", "right"]): |
| 162 | return _df_anno("right", "bottom", max([x0, x1]), min([y0, y1])) |
| 163 | if position == set(["inside", "bottom"]): |
| 164 | return _df_anno("center", "bottom", _mean([x0, x1]), min([y0, y1])) |
| 165 | if position == set(["inside", "left"]): |
| 166 | return _df_anno("left", "middle", min([x0, x1]), _mean([y0, y1])) |
| 167 | if position == set(["inside", "right"]): |
| 168 | return _df_anno("right", "middle", max([x0, x1]), _mean([y0, y1])) |
| 169 | if position == set(["inside"]): |
| 170 | # TODO: Do we want this? |
| 171 | return _df_anno("center", "middle", _mean([x0, x1]), _mean([y0, y1])) |
| 172 | if position == set(["outside", "top", "left"]): |
| 173 | return _df_anno( |
| 174 | "right" if shape_type == "vrect" else "left", |
| 175 | "bottom" if shape_type == "hrect" else "top", |
| 176 | min([x0, x1]), |
| 177 | max([y0, y1]), |
| 178 | ) |
| 179 | if position == set(["outside", "top", "right"]): |
| 180 | return _df_anno( |
| 181 | "left" if shape_type == "vrect" else "right", |
| 182 | "bottom" if shape_type == "hrect" else "top", |
| 183 | max([x0, x1]), |
| 184 | max([y0, y1]), |
| 185 | ) |
| 186 | if position == set(["outside", "top"]): |
| 187 | return _df_anno("center", "bottom", _mean([x0, x1]), max([y0, y1])) |
| 188 | if position == set(["outside", "bottom", "left"]): |
| 189 | return _df_anno( |
| 190 | "right" if shape_type == "vrect" else "left", |
| 191 | "top" if shape_type == "hrect" else "bottom", |
| 192 | min([x0, x1]), |
| 193 | min([y0, y1]), |
| 194 | ) |
| 195 | if position == set(["outside", "bottom", "right"]): |
| 196 | return _df_anno( |
| 197 | "left" if shape_type == "vrect" else "right", |
| 198 | "top" if shape_type == "hrect" else "bottom", |
| 199 | max([x0, x1]), |
| 200 | min([y0, y1]), |
| 201 | ) |
| 202 | if position == set(["outside", "bottom"]): |
| 203 | return _df_anno("center", "top", _mean([x0, x1]), min([y0, y1])) |
no test coverage detected