ReflectionEffect.vb
C# VB
'''' This code is part of Document Solutions for Word demos.'' Copyright (c) MESCIUS inc. All rights reserved.''Imports System.DrawingImports GrapeCity.Documents.Word
'' This example shows how to add reflection effect to text and shapes in a DOCX.Public Class ReflectionEffect Function CreateDocx() As GcWordDocument Dim doc = New GcWordDocument()
'' Custom text reflection: Dim style0 = doc.Styles.Add("style0", StyleType.Paragraph) style0.Font.Size = 48 '' apply top half touching reflection effect to the text Dim reflection As Reflection = style0.Font.Effects.Reflection reflection.Distance = 0F reflection.Angle = 90F reflection.Blur = 0.5F reflection.Alignment = RectangleAlignment.BottomLeft reflection.ScaleX = 100F reflection.ScaleY = -100F reflection.SkewX = 0F reflection.SkewY = 0F reflection.StartOpacity = 60F reflection.EndOpacity = 0.9F reflection.StartOpacityPosition = 0F reflection.EndOpacityPosition = 58F reflection.OpacityAngle = 90F doc.Body.Paragraphs.Add("Custom text reflection.", style0)
'' Built-in text reflection (visually the same as the custom reflection above): Dim style1 = doc.Styles.Add("style1", StyleType.Paragraph) style1.Font.Size = 48 '' apply top half touching reflection effect to the text style1.Font.Effects.ApplyBuiltInReflection(BuiltInReflectionId.HalfTouching) doc.Body.Paragraphs.Add("Built-in text reflection.", style1)
'' Shape reflection - direct effects: Dim p As Paragraph = doc.Body.Paragraphs.Add() Dim run As Run = p.GetRange().Runs.Add() Dim shape As Shape = run.GetRange().Shapes.Add(100, 100, GeometryType.Heptagon) shape.Fill.Type = FillType.Solid shape.Fill.SolidFill.RGB = Color.PeachPuff shape.Line.Width = 4 shape.Line.Fill.SolidFill.ThemeColor = ThemeColorId.Accent1 shape.Effects.ApplyBuiltInReflection(BuiltInReflectionId.TightTouching) p.GetRange().Runs.Add("Shape reflection - direct effects.", doc.Styles(BuiltInStyleId.Strong))
'' Shape reflection - style effects: p = doc.Body.Paragraphs.Add() p.Style.ParagraphFormat.Spacing.SpaceBefore = 50 run = p.GetRange().Runs.Add() shape = run.GetRange().Shapes.Add(100, 100, GeometryType.Heptagon) shape.Fill.Type = FillType.Solid shape.Fill.SolidFill.RGB = Color.PeachPuff shape.Line.Width = 4 shape.Line.Fill.SolidFill.ThemeColor = ThemeColorId.Accent1 '' Apply tight touching reflection effect to the new effect record: Dim fmtEffect = doc.Theme.FormatScheme.Effects.Add() fmtEffect.ApplyBuiltInReflection(BuiltInReflectionId.TightTouching) '' Apply new effect style to shape: shape.Style.Effects.ThemeEffects = fmtEffect p.GetRange().Runs.Add("Shape reflection - style effects.", doc.Styles(BuiltInStyleId.Strong))
'' Done: Return doc End FunctionEnd Class