예제 #1
0
        public void ModifyEditorWidget(GuiWidget widget, ThemeConfig theme, Action requestWidgetUpdate)
        {
            var child = this.Children.First();

            if (child is ImageObject3D imageObject)
            {
                ImageObject3D.ModifyImageObjectEditorWidget(imageObject, widget, theme, requestWidgetUpdate);
            }
        }
예제 #2
0
        private ImageBuffer SetImage(ThemeConfig theme, ImageObject3D imageObject)
        {
            var image = imageObject.Image;

            // Show image load error if needed
            if (image == null)
            {
                image = new ImageBuffer(185, 185).SetPreMultiply();
                var graphics2D = image.NewGraphics2D();

                graphics2D.FillRectangle(0, 0, 185, 185, theme.MinimalShade);
                graphics2D.Rectangle(0, 0, 185, 185, theme.SlightShade);
                graphics2D.DrawString("Error Loading Image".Localize() + "...", 10, 185 / 2, baseline: Agg.Font.Baseline.BoundsCenter, color: Color.Red, pointSize: theme.DefaultFontSize, drawFromHintedCach: true);
            }

            return((image.Height <= 185) ? image : ScaleThumbnailImage(185, image));
        }
예제 #3
0
        public override async Task Rebuild()
        {
            this.DebugDepth("Rebuild");

            using (RebuildLock())
            {
                var currentAssetPath = ImageObject == null?AggContext.StaticData.ToAssetPath(Path.Combine("Images", "mh-logo.png")) : ImageObject.AssetPath;

                this.Children.Modify((list) =>
                {
                    list.Clear();
                });

                var imageObject = new ImageObject3D()
                {
                    AssetPath = currentAssetPath,
                };

                await imageObject.Rebuild();

                this.Children.Add(imageObject);

                IObject3D logoBase = new CylinderObject3D(outerDiameter, 3, 60);
                IObject3D logoRing = new AlignObject3D(new RingObject3D(outerDiameter, innerDiameter, 2, 60), FaceAlign.Bottom, logoBase, FaceAlign.Top);

                IObject3D coinBlank = logoBase.Plus(logoRing);
                if (CreateHook)
                {
                    var cube = await CubeObject3D.Create(4, 2, 4);

                    IObject3D connect = logoBase.Plus(new AlignObject3D(cube, FaceAlign.Front | FaceAlign.Bottom, logoBase, FaceAlign.Back | FaceAlign.Bottom, 0, -.5));
                    IObject3D hook    = logoBase.Plus(new AlignObject3D(new RingObject3D(10, 7, 5, 30), FaceAlign.Front | FaceAlign.Bottom, connect, FaceAlign.Back | FaceAlign.Bottom, 0, -.5));

                    coinBlank = coinBlank.Plus(connect);
                    coinBlank = coinBlank.Plus(hook);
                }

                var imageToPath = new ImageToPathObject3D();

                imageToPath.Children.Add(imageObject);

                await imageToPath.Rebuild();

                var inputShape = imageToPath.VertexSource;

                if (Inflate != 0)
                {
                    var bounds = inputShape.GetBounds();
                    var scale  = Math.Max(bounds.Width, bounds.Height) / (17 * 4);
                    inputShape = inputShape.Offset(Inflate * scale);
                }

                if (AlternateCentering)
                {
                    inputShape = new VertexSourceApplyTransform(inputShape, GetCenteringTransformVisualCenter(inputShape, innerDiameter / 2));
                }
                else
                {
                    inputShape = new VertexSourceApplyTransform(inputShape, GetCenteringTransformExpandedToRadius(inputShape, innerDiameter / 2));
                }

                if (ScalePercent != 100 &&
                    ScalePercent != 0)
                {
                    inputShape = new VertexSourceApplyTransform(inputShape, Affine.NewScaling(ScalePercent / 100.0));
                }

                if (NegativeSpace)
                {
                    var disk = new Ellipse(0, 0, innerDiameter / 2 + .2, innerDiameter / 2 + .2)
                    {
                        ResolutionScale = 1000
                    };
                    inputShape = disk.Minus(inputShape);
                }

                imageToPath.VertexSource = inputShape;

                var pathExtrusion = new LinearExtrudeObject3D();
                pathExtrusion.Children.Add(imageToPath);
                await pathExtrusion.Rebuild();

                IObject3D extrusionObject = imageObject;

                var loadingScale = 32 / extrusionObject.XSize();
                extrusionObject = new ScaleObject3D(extrusionObject, loadingScale, loadingScale, 1 / extrusionObject.ZSize());
                extrusionObject = PlaceOnBase(logoBase, extrusionObject);

                this.Children.Add(coinBlank);
                this.Children.Add(extrusionObject);
            }

            Invalidate(InvalidateType.Mesh);
        }