コード例 #1
0
            public override void drawOnImage(ref Image image, ref Image normalMap, BoundingBox boundingBox)
            {
                drawOnImage(ref image, boundingBox);

                if (_normalOption == NormalOption.USE_BACKGROUND) return;

                Image textImage = new Image(image.width, image.height);
                Color32 backgroudColor = new Color32(127, 127, 127, 0);
                textImage.fill(backgroudColor);

                Color32 color = Global.Gray32;
                if (_normalOption == NormalOption.RAISE_TEXT) color = Global.White32;
                if (_normalOption == NormalOption.LOWER_TEXT) color = Global.Black32;

                textImage.drawText(_text, _fontName, _fontSize, _position, _rotation, color, _mirror, AlphaOption.OVERWRITE, 255, BlendMethod.PIXEL);

                BoundingBox bBox = new BoundingBox(boundingBox);
                if (image.width != normalMap.width || image.height != normalMap.height)
                {
                    textImage.rescale(normalMap.width, normalMap.height);
                    bBox.x = (int)((float)bBox.x * (float)normalMap.width / (float)image.width);
                    bBox.w = (int)((float)bBox.w * (float)normalMap.width / (float)image.width);
                    bBox.y = (int)((float)bBox.y * (float)normalMap.height / (float)image.height);
                    bBox.h = (int)((float)bBox.h * (float)normalMap.height / (float)image.height);
                }

                Image normalMapImage = textImage.createNormalMap(_normalScale);
                normalMap.overlay(normalMapImage, textImage, 128, bBox);
            }
コード例 #2
0
            protected void drawDecalOnImage(ref Image image, ref Image normalMap, string _url, BoundingBox boundingBox)
            {
                BitmapDecal decal;
                if (!BitmapDecalCache.Instance.decals.TryGetValue(_url, out decal)) return;

                drawOnImage(ref image, boundingBox);

                if (_normalOption == NormalOption.USE_BACKGROUND) return;

                Image backgroundImage = new Image(normalMap.width, normalMap.height);
                Color32 backgroudColor = new Color32(127, 127, 127, 0);
                backgroundImage.fill(backgroudColor);

                Color32 color = Global.Gray32;
                if (_normalOption == NormalOption.RAISE_TEXT) color = Global.White32;
                if (_normalOption == NormalOption.LOWER_TEXT) color = Global.Black32;

                Image decalImage = new Image(decal.image);
                decalImage.recolor(Global.Black32, color, false, true);
                decalImage.rotateImage(_rotation);
                if (_mirror) decalImage.flipHorizontally();

                backgroundImage.blendImage(decalImage, BlendMethod.PIXEL, _position, AlphaOption.OVERWRITE, 255, boundingBox);

                Image normalMapImage = backgroundImage.createNormalMap(_normalScale);

                if (image.width == normalMap.width && image.height == normalMap.height) normalMap.rescale(image.width, image.height);
                normalMap.overlay(normalMapImage, backgroundImage, 128, boundingBox);
            }