本文整理汇总了TypeScript中core/util/bbox.BBox类的典型用法代码示例。如果您正苦于以下问题:TypeScript BBox类的具体用法?TypeScript BBox怎么用?TypeScript BBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BBox类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: on_hit
on_hit(sx, sy) {
let yoffset;
const { glyph_width } = this.model;
const { legend_padding } = this;
const legend_spacing = this.model.spacing;
const { label_standoff } = this.model;
let xoffset = (yoffset = legend_padding);
const legend_bbox = this.compute_legend_bbox();
const vertical = this.model.orientation === "vertical";
for (const item of this.model.items) {
const labels = item.get_labels_list_from_label_prop();
for (const label of labels) {
const x1 = legend_bbox.x + xoffset;
const y1 = legend_bbox.y + yoffset;
let h: number
let w: number
if (vertical)
[w, h] = [legend_bbox.width-(2*legend_padding), this.max_label_height];
else
[w, h] = [this.text_widths[label] + glyph_width + label_standoff, this.max_label_height];
const bbox = new BBox({x: x1, y: y1, width: w, height: h});
if (bbox.contains(sx, sy)) {
switch (this.model.click_policy) {
case "hide": {
for (const r of item.renderers)
r.visible = !r.visible;
break
}
case "mute": {
for (const r of item.renderers)
r.muted = !r.muted;
break;
}
}
return true
}
if (vertical) {
yoffset += this.max_label_height + legend_spacing;
} else {
xoffset += this.text_widths[label] + glyph_width + label_standoff + legend_spacing;
}
}
}
return false;
}
示例2: on_hit
on_hit(sx: number, sy: number): boolean {
let yoffset
const { glyph_width } = this.model
const { legend_padding } = this
const legend_spacing = this.model.spacing
const { label_standoff } = this.model
let xoffset = (yoffset = legend_padding)
const legend_bbox = this.compute_legend_bbox()
const vertical = this.model.orientation == "vertical"
for (const item of this.model.items) {
const labels = item.get_labels_list_from_label_prop()
for (const label of labels) {
const x1 = legend_bbox.x + xoffset
const y1 = legend_bbox.y + yoffset + this.title_height
let w: number, h: number
if (vertical)
[w, h] = [legend_bbox.width - 2*legend_padding, this.max_label_height]
else
[w, h] = [this.text_widths[label] + glyph_width + label_standoff, this.max_label_height]
const bbox = new BBox({left: x1, top: y1, width: w, height: h})
if (bbox.contains(sx, sy)) {
switch (this.model.click_policy) {
case "hide": {
for (const r of item.renderers)
r.visible = !r.visible
break
}
case "mute": {
for (const r of item.renderers)
r.muted = !r.muted
break
}
}
return true
}
if (vertical)
yoffset += this.max_label_height + legend_spacing
else
xoffset += this.text_widths[label] + glyph_width + label_standoff + legend_spacing
}
}
return false
}