All Projects → mgierlasinski → Magicgradients

mgierlasinski / Magicgradients

Licence: mit
Draw breathtaking backgrounds in your Xamarin.Forms application. It's a kind of magic.

Projects that are alternatives of or similar to Magicgradients

Xamarin Playground
Random cool stuff I play around using Xamarin.. :3 Some of these cool projects I feature them on my blog, with step by step explanation. :) Don't forget to check it out. Go to: theconfuzedsourcecode.wordpress.com
Stars: ✭ 183 (-22.46%)
Mutual labels:  xamarin, xamarin-forms
Caliburn.micro
A small, yet powerful framework, designed for building applications across all XAML platforms. Its strong support for MV* patterns will enable you to build your solution quickly, without the need to sacrifice code quality or testability.
Stars: ✭ 2,404 (+918.64%)
Mutual labels:  xamarin, xamarin-forms
Xamarin Forms Goodlooking Ui
Xamarin.Forms goodlooking UI samples
Stars: ✭ 2,300 (+874.58%)
Mutual labels:  xamarin, xamarin-forms
Xamarin Demos
This repository contains the Syncfusion Xamarin UI control’s samples and the guide to use them.
Stars: ✭ 218 (-7.63%)
Mutual labels:  xamarin, xamarin-forms
Xamarin.forms.datagrid
DataGrid Component For Xamarin.Forms Projects
Stars: ✭ 226 (-4.24%)
Mutual labels:  xamarin, xamarin-forms
Xamarinformslayoutchallenges
Sample Layouts for Xamarin Forms
Stars: ✭ 230 (-2.54%)
Mutual labels:  xamarin, xamarin-forms
Reactive Examples
Samples App using the Reactive Extensions and Reactive UI
Stars: ✭ 203 (-13.98%)
Mutual labels:  xamarin, xamarin-forms
Xamarin.plugin.calendar
Calendar plugin for Xamarin.Forms
Stars: ✭ 159 (-32.63%)
Mutual labels:  xamarin, xamarin-forms
Xamarin Forms Page Transitions
Custom page transitions in a Xamarin.Forms App
Stars: ✭ 200 (-15.25%)
Mutual labels:  xamarin, xamarin-forms
Improvexamarinbuildtimes
Tips and tricks on how to speed up the time it takes to compile a Xamarin app
Stars: ✭ 180 (-23.73%)
Mutual labels:  xamarin, xamarin-forms
Toucheffect
UI-responsive touch effects for Xamarin.Forms
Stars: ✭ 193 (-18.22%)
Mutual labels:  xamarin, xamarin-forms
Mobile
The mobile app vault (iOS and Android).
Stars: ✭ 3,149 (+1234.32%)
Mutual labels:  xamarin, xamarin-forms
Expandableview
Expandable view for Xamarin.Forms
Stars: ✭ 178 (-24.58%)
Mutual labels:  xamarin, xamarin-forms
Xfx.controls
Xamarin Forms Extended Controls
Stars: ✭ 187 (-20.76%)
Mutual labels:  xamarin, xamarin-forms
Microsoft.maui.graphics
Stars: ✭ 160 (-32.2%)
Mutual labels:  xamarin, xamarin-forms
Denunciado
This project born from the need from people to have a way of communication between municipalities and communities. Some municipalities, have their platforms, but they are complex to validate the veracity of complaints. Denounced, it was born with the purpose of offering a free platform to these municipalities. Denounced consists of three main modules developed with Microsoft technologies, using the .Net Framework and Xamarin for its development: 1. Back End Web Project: Module of administration of the complaints, by the employees of the town councils. In this tool, the employees of the city council receive, validate, report and close the complaints, after being served. 2. Web Portal Client: It consists of a web project, so that the community make their complaints, in the same, the users of the service create a profile, must specify when making their complaint, evidence to support this. Through the portal, they can see the complaints of other community members, follow it, give their opinion or provide possible solutions or more evidence. 3. Mobile Project: It has the same functionalities as the web portal, with the addition, that the automatic location can be sent, from the cell phone.
Stars: ✭ 183 (-22.46%)
Mutual labels:  xamarin, xamarin-forms
Graphicscontrols
Experimental GraphicsControls - Build drawn controls (Cupertino, Fluent and Material)
Stars: ✭ 149 (-36.86%)
Mutual labels:  xamarin, xamarin-forms
Xamarines
🕹️📱Cross-Platform Nintendo Emulator using Xamarin and .Net Standard!
Stars: ✭ 153 (-35.17%)
Mutual labels:  xamarin, xamarin-forms
Xamarin.forms.mocks
Library for running Xamarin.Forms inside of unit tests
Stars: ✭ 179 (-24.15%)
Mutual labels:  xamarin, xamarin-forms
Animationnavigationpage
AnimationNavigationPage is a NavigationPage with custom transitions animation effects.
Stars: ✭ 235 (-0.42%)
Mutual labels:  xamarin, xamarin-forms

Magic Gradients

image

(this picture is draggable, check it out)

Draw breathtaking backgrounds in your Xamarin.Forms application today, from simple gradients to complex textures. It's a kind of magic ✨

Supported platforms
✔️ Android
✔️ iOS
✔️ UWP
  • Linear and radial gradients supported
  • Draw as many gradients as you want with single control, blend them together for unique effects
  • Supports CSS gradients, find your ideal background somewhere on the web and copy + paste into your app
  • Make your background alive with built-in XAML animations 🙉
  • Powered by Nuget

Installation

Magic Gradients are available via NuGet:

Nuget

Install into shared project, no additional setup required.

Drawing gradient

To draw a gradient add GradientView control to your XAML page and create LinearGradient or RadialGradient as direct content.

<magic:GradientView>
    <magic:LinearGradient>
        <magic:GradientStop Color="Red" />
        <magic:GradientStop Color="Yellow" />
    </magic:LinearGradient>
</magic:GradientView>

It is also possible to add collection of gradients. You can mix linear and radial gradients, use transparency in color definitions to get blend effect.

<magic:GradientView>
    <magic:GradientCollection>
        <magic:LinearGradient Angle="45">
            <magic:GradientStop Color="Orange" Offset="0" />
            <magic:GradientStop Color="#ff0000" Offset="0.6" />
        </magic:LinearGradient>
        <magic:LinearGradient Angle="90">
            <magic:GradientStop Color="#33ff0000" Offset="0.4" />
            <magic:GradientStop Color="#ff00ff00" Offset="1" />
        </magic:LinearGradient>
    </magic:GradientCollection>
</magic:GradientView>

You can also build gradient in C# using GradientBuilder with Fluent API:

 var gradients = new GradientBuilder()
    .AddLinearGradient(g => g
        .Rotate(45)
        .AddStop(Color.Red, Offset.Prop(0.2))
        .AddStop(Color.Blue, Offset.Prop(0.4)))
    .AddRadialGradient(g => g
        .Circle().At(0.5, 0.5, o => o.Proportional())
        .Radius(200, 200, o => o.Absolute())
        .StretchTo(RadialGradientSize.FarthestSide)
        .Repeat()
        .AddStops(Color.Red, Color.Green, Color.Blue))
    .AddCssGradient("linear-gradient(red, orange)")
    .Build();

To apply gradient created in C#, you can use ToSource() extension method:

 var source = new GradientBuilder()
    .AddLinearGradient(g => g
        .Rotate(20)
        .AddStops(Color.Red, Color.Green, Color.Blue))
    .ToSource();

gradientView.GradientSource = source;

Discover amazing backgounds

image

In Magic Gradients repository you can find Magic Playground, a Xamarin.Forms app for browsing and creating gradients visually. Android, iOS and UWP are supported.

Be sure to check out the Gallery. It contains over 1700+ samples 🙉 from Gradient Magic, ready to use in any Xamarin.Forms app. Find your best, pick and copy over to your app.

Styling with CSS

Magic Gradients supports CSS functions. CSS gradient can be embeded in XAML inline:

<magic:GradientView>
    <magic:CssGradientSource>
        <x:String>
            <![CDATA[
                linear-gradient(242deg, red, green, orange)
            ]]>
        </x:String>
    </magic:CssGradientSource>
</magic:GradientView>

Styling from CSS stylesheet is also possible:

<magic:GradientView StyleClass="myGradient" />
.myGradient {
    background: linear-gradient(90deg, rgb(235, 216, 9), rgb(202, 60, 134));
}

CSS can be also set via C#:

gradientView.GradientSource = CssGradientSource.Parse("linear-gradient(red, green, blue)");

Linear gradient functions

Alt text Alt text
linear-gradient repeating-linear-gradient

CSS Syntax

linear-gradient(direction | angle, color-stop1, color-stop2, ...);
Value Description
direction Possible values: to left, to right, to top, to bottom, to left top, to right bottom etc.
angle In degrees (135deg) or proportional (0.45turn, range between 0-1)

Each color stop should contain color information and optionally position described in percents or pixels. Suppored color formats:

  • colors in RGB or HSL format: rgb(red, green, blue), rgba(red, green, blue, alpha), hsl(hue, saturation, lightness), hsla(hue, saturation, lightness, alpha)
  • colors in hex: #ff0000
  • named colors: red, green, blue, orange, pink

Radial gradient functions

Alt text Alt text
radial-gradient repeating-radial-gradient

CSS Syntax

radial-gradient(shape size at position, start-color, ..., last-color);
Value Description
shape Possible values: circle, ellipse
size In pixels (px), proportional (%) or named sizes: closest-side, closest-corner, farthest-side, farthest-corner (default)
position In pixels (px), proportional (%) or named directions: left, right, top, bottom, center

Examples

radial-gradient(circle at top left, red, green);
radial-gradient(circle 100px at 70% 20%, red, green);           // one radius for circle
radial-gradient(ellipse closest-corner at 30% 80%, red, green);
radial-gradient(ellipse 200px 300px at 50% 60%, red, green);    // two radiuses for ellipse

Play with CSS

You can play around with CSS functions live in Magic Playground app, Hot Reload 🔥 included.

Animations (preview)

xmlns:anim="clr-namespace:MagicGradients.Animation;assembly=MagicGradients"
Timeline property Values
Target {x:Reference myGradient} Reference to animated element.
Duration 3000 Length of single loop (in ms).
Delay 200 Time before animations starts (in ms).
Easing {x:Static Easing.SinInOut} Easing function.
RepeatBehavior 1x, 3x, Forever How many times animation must be repeated.
AutoReverse True, False If true, next loop will be animated backwards.

Running animation

Run automatically:

<magic:GradientView.Behaviors>
    <anim:Animate>
        <anim:DoubleAnimation ... />
    </anim:Animate>
</magic:GradientView.Behaviors>

Control animation from view model:

<magic:GradientView.Triggers>
    <anim:AnimateTrigger IsRunning="{Binding IsRunning}">
         <anim:PointAnimation ... />
    </anim:AnimateTrigger>
</magic:GradientView.Triggers>

AnimateTrigger is a MarkupExtension. It's shorter way of creating DataTrigger with BeginAnimation and EndAnimation as EnterActions and ExitActions.

Property animations

With this type of animation you can animate single property between two values defined as From and To.

Properties Value
TargetProperty magic:GradientStop.Color Animated property with full namespace.
From Value matching TargetProperty type Value when animation starts.
To Value matching TargetProperty type Value when animation ends.

Animate color sample:

<anim:ColorAnimation Target="{x:Reference AnimColor}" 
                     TargetProperty="magic:GradientStop.Color" 
                     From="Red" To="Yellow" 
                     Duration="3000"
                     RepeatBehavior="Forever" 
                     AutoReverse="True" />

Built-in property types:

ColorAnimation, DimensionsAnimation, DoubleAnimation, IntegerAnimation, OffsetAnimation, PointAnimation, ThicknessAnimation

For custom types, see Custom animation types.

Storyboards

Attached properties Values
anim:Storyboard.BeginAt from 0 to 1 Start animation at given point of Storyboard.
anim:Storyboard.FinishAt from 0 to 1 End animation at given point of Storyboard.

Animate two colors at different times:

<anim:Storyboard Duration="4000" RepeatBehavior="Forever">
    <anim:ColorAnimation Target="{x:Reference Color1}" 
                         TargetProperty="magic:GradientStop.Color" 
                         From="White" To="Red" 
                         anim:Storyboard.BeginAt="0"
                         anim:Storyboard.FinishAt="0.8"
                         AutoReverse="True" />
    <anim:ColorAnimation Target="{x:Reference Color2}" 
                         TargetProperty="magic:GradientStop.Color" 
                         From="LightGray" To="DarkRed" 
                         anim:Storyboard.BeginAt="0.3"
                         anim:Storyboard.FinishAt="1"
                         AutoReverse="True" />
</anim:Storyboard>

KeyFrame animations

<Type>AnimationUsingKeyFrames

<Type>KeyFrame properties:

  • KeyTime - time when value is applied to animated target
  • Value - of type <Type>
  • Easing - easing function

Move radial circle between corners, at different times:

<anim:PointAnimationUsingKeyFrames Target="{x:Reference Radial2}" 
                                   TargetProperty="magic:RadialGradient.Center" 
                                   RepeatBehavior="Forever">
    <anim:PointKeyFrame KeyTime="1000" Value="0.9,0.1" />
    <anim:PointKeyFrame KeyTime="1500" Value="0.9,0.9" />
    <anim:PointKeyFrame KeyTime="2500" Value="0.1,0.9" Easing="{x:Static Easing.SinInOut}" />
    <anim:PointKeyFrame KeyTime="3000" Value="0.1,0.1" />
</anim:PointAnimationUsingKeyFrames>

Advanced features

Color positions

Similar to CSS, with Magic Gradient you can posion each color with proportional value or by absolute pixels.

<magic:GradientView>
    <magic:LinearGradient>
        <magic:GradientStop Color="Red" />
        <magic:GradientStop Color="Yellow" Offset="100px" />
        <magic:GradientStop Color="Green" Offset="40%" />
        <magic:GradientStop Color="Blue" Offset="0.8" />
    </magic:LinearGradient>
</magic:GradientView>

Offset types:

  • 0.3, 30% - proportional, Offset.Prop(0.3) in code
  • 200px - absolute, Offset.Abs(200) in code
  • leave blank - each undefined offset will be calculated like in CSS

Backgroud size and position

GradientView let's you specify size of the background with GradientSize property:

<GradientView GradientSource="..." GradientSize="0.6,0.6">
<GradientView GradientSource="..." GradientSize="200px,200px">

Proportional and absolute values are supported. Size can also be set from CSS:

.myGradient {
    background: ...;
    background-size: 60px 60px;
}

When size is set, gradient will be tiled to fill available space. You can change tile mode with GradientRepeat property. Supported values:

  • Repeat, repeat
  • RepeatX, repeat-x
  • RepeatY, repeat-y
  • NoRepeat, no-repeat

Repeat mode can be set from CSS as well:

.myGradient {
    background: ...;
    background-size: 60px 60px;
    background-repeat: repeat-x;
}

Custom animation types

  • create ITweener implementation
public class DoubleTweener : ITweener<double>
{
    public double Tween(double @from, double to, double progress)
    {
        return from + (to - from) * progress;
    }
}
  • define animations
public class DoubleAnimation : PropertyAnimation<double>
{
    public override ITweener<double> Tweener { get; } = new DoubleTweener();
}

public class DoubleAnimationUsingKeyFrames : PropertyAnimationUsingKeyFrames<double>
{
    public override ITweener<double> Tweener { get; } = new DoubleTweener();
}

public class DoubleKeyFrame : KeyFrame<double> { }

Articles


Icons made by Icongeek26 from www.flaticon.com
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].