WIP WYSIWYG ~3D SVG editor.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Delegate widget anchor calculation to tools.

Makes more sense for them to calculate where their widgets needs to go,
or to bypass it altogether if they don't draw widgets or if they just
need to do Something Different.

+24 -13
+24 -13
zoodle.js
··· 145 145 return; 146 146 } 147 147 148 - // Create anchors matching selected objects. 149 - let targets = this.selection.map((target) => { 150 - return new Zdog.Anchor({ 151 - addTo: this.ui, 152 - // TODO: Maybe a flag for whether or not to include our own transforms vs just our parents'. 153 - // Cause right now translate widgets are getting rotated when translation is applied before rotation. 154 - ...this.getWorldTransforms(target), 155 - }); 156 - }); 157 - 158 - this.tool.drawWidget(targets); 148 + this.tool.drawWidget(this.selection); 159 149 } 160 150 161 151 syncLayers() { ··· 360 350 let direction = this.widget.renderNormal; // TODO: Break out into a function. 361 351 let delta = this.editor.getAxisDistance(x, y, Math.atan2(direction.y, direction.x)); 362 352 delta /= -this.editor.scene.zoom; 363 - delta /= this.widget.scale; 364 - let command = new TranslateCommand(this.editor, this.targets, new Zdog.Vector({[this.mode]: delta})); 353 + delta *= this.widget.scale.x; 354 + let command = new TranslateCommand(this.editor, this.targets, new Zdog.Vector({[this.mode]: delta}), this.startTranslate); 365 355 this.editor.did(command); 366 356 } 367 357 drawWidget(targets) { 358 + // Create anchors matching selected objects. 359 + targets = targets.map((target) => { 360 + // TODO: Double check this is correct. 361 + let parentTransforms = this.editor.getWorldTransforms(target.addTo); 362 + let childTranslate = target.translate.copy().rotate(parentTransforms.rotate); 363 + parentTransforms.translate.add(childTranslate); 364 + parentTransforms.translate.multiply(parentTransforms.scale); 365 + return new Zdog.Anchor({ 366 + addTo: this.editor.ui, 367 + ...parentTransforms, 368 + }); 369 + }); 370 + 368 371 let origin = new Zdog.Shape({ 369 372 stroke: .5, 370 373 color: lace, ··· 485 488 this.editor.did(command); 486 489 } 487 490 drawWidget(targets) { 491 + // Create anchors matching selected objects. 492 + targets = targets.map((target) => { 493 + return new Zdog.Anchor({ 494 + addTo: this.editor.ui, 495 + ...this.editor.getWorldTransforms(target), 496 + }); 497 + }); 498 + 488 499 const widgetDiameter = 10; 489 500 const widgetStroke = 0.75; 490 501