123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <template>
- <div style="margin-top: 10px;">
- <el-button size="small" @click="changeEnable">切换item1禁用状态</el-button>
- 圆角半径 : <el-input-number @change="changeY" v-model="R" size="mini" style="width: 100px"></el-input-number>
- <canvas :id="id" width="740" height="400" />
- </div>
- </template>
- <script lang="ts">
- import {SGraphRectItem, SGraphScene, SGraphView} from "@persagy-web/graph/lib";
- import { Component, Vue } from "vue-property-decorator";
- @Component
- export default class RectCanvas extends Vue {
- id: string = 'rect' + Date.now();
- view: SGraphView | undefined;
- item: SGraphRectItem | undefined;
- item2: SGraphRectItem | undefined;
- R: number = 0;
- rectData = {
- x: 0,
- y: 0,
- width: 500,
- height: 500,
- radius: 0,
- style: {
- "default":{
- "stroke": "#cccccc",
- "fill": "SLinearGradient{0,0;0,1000;0,#ff483bff;0.5,#04ff00ff;1,#3d4effff;}",
- "lineWidth": 2,
- "effect": {}
- },
- "selected": {
- "stroke": "#66ff66",
- "fill": "SRadialGradient{500,500,50;500,500,500;0,#ff483bff;0.5,#04ff00ff;1,#3d4effff;}",
- "lineWidth": 3,
- "effect": {}
- },
- "disabled": {
- "stroke": "#333333",
- "fill": "#afafaf",
- "lineWidth": 1,
- "effect": {}
- },
- }
- };
- rectData2 = {
- x: 1000,
- y: 0,
- width: 500,
- height: 500,
- radius: 0,
- style: {
- "default":{
- "stroke": "#cccccc",
- "fill": "#ffccee",
- "lineWidth": 2,
- "effect": {}
- },
- "selected": {
- "stroke": "#66ff66",
- "fill": "#ff33ee",
- "lineWidth": 3,
- "effect": {}
- },
- "disabled": {
- "stroke": "#333333",
- "fill": "#afafaf",
- "lineWidth": 1,
- "effect": {}
- },
- }
- };
- private mounted (): void {
- this.init();
- }
- init(): void {
- this.view = new SGraphView(this.id);
- const scene = new SGraphScene();
- this.item = new SGraphRectItem(null, this.rectData);
- this.item.selectable = true;
- this.item._resizeable = false;
- scene.addItem(this.item);
- this.item2 = new SGraphRectItem(null, this.rectData2);
- this.item2.selectable = true;
- this.item2._resizeable = false;
- scene.addItem(this.item2);
- this.view.scene = scene;
- this.view.fitSceneToView();
- this.view.scalable = false;
- }
- changeEnable(): void{
- if (this.item) {
- this.item.enabled = !this.item.enabled;
- }
- }
- // 修改圆角半径
- changeY(val: number): void {
- if (this.item){
- this.item.radius = val;
- }
- if(this.item2) {
- this.item2.radius = val;
- }
- }
- }
- </script>
- <style scoped>
- </style>
|