blobs 1.0.0 copy "blobs: ^1.0.0" to clipboard
blobs: ^1.0.0 copied to clipboard

outdated

Create beautiful blobs - fixed/random blob generation, animations, svgs and more


Blobs

Create beautiful blob shapes with minimal code. Includes widgets, animations, clipper and services.

Blobs #

Blobs can be created from widgets, clippers and services.

Features #

  • Generate blob in any size
  • Control the edges and complexity
  • Animate the blob
  • Set hash ID for a fixed blob
  • Shuffle between the fixed blobs
  • Loop animation
  • Custom clipper
  • Get SVG path
  • Debug, child, controller and few more

Contents #

Widgets #

There are four widgets,

  • Blob.random() - Generate random blobs
  • Blob.animatedRandom() - Generate blobs and animate the shape change
  • Blob.fromHash() - Use one or more hash ID's for fixed blobs
  • Blob.animatedFromHash() - Animate the shape change

Blobs and animations are configurable.

Blob Size

Size of the blob. It is mandatory.

Blob.random(size:200),

Basic blob

Blob shape settings

edgesCount is the nodes count. Minimum is 3 and max is 300. But for cool shapes you can stick between 3-20. Default is 7 minGrowth is the minimum size of the blob. Value should be an interger between 2-9. Default is 4.

Blob.random(
  size:200,
  edgesCount:5,
  minGrowth:4,
),

Basic blob

Controller

You can use BlobController, if you want to change the shape programatically. As of. now it has only one method called change(). When you call this, the shape will be changed and returns some useful data of the blob (BlobData).

BlobConroller blobCtrl = BlobController();
Blob.random(
  size:200,
  edgesCount:5,
  minGrowth:4,
  controller: blobCtrl
),
BlobData blobData = blobCtrl.change();

Fixed shapes

In most scenarios you wanted a same blob to be loaded every time. This can be achieved using hash. Hash is just a ID, which contains the shape data. You can get the hash id from the blobData from the controller's change() method.

Blobs app is in progress. Once it is ready, you will be able to generate and get the hash ID from that app.

Hash id looks like H4sIANhSwV4A/w3LsQ0AMQgEwYY24A5koBbr+2/jnY40NzdxBD7GPagXrznzKKlFbjSBJDKKs9QLE98PNkNQxj0AAAA=

hash option accepts one or multiple id's. If it has only one hash, then it will be a fixed blob.

Blob.fromHash(
  size:200,
  hash:['XXXXXXXX...'],
  controller: blobCtrl
),

If you provide multiple id's, then it will show each one in order on changing.

Blob.fromHash(
  size:200,
  hash:['XXXXXXXX...','YYYYYYY....','ZZZZZZZZ....'],
  controller: blobCtrl
),

Fixed blob

Styles

You can change the color, add gradient, make outlined using BlobStyles()

Blob.random(
  size:200,
  styles: BlobStyles(
    color: Colors.green,
    fillType: BlobFillType.STROKE,
    gradient: LinearGradient(),
    strokeWidth:3,
  ),
),

Custom color

Gradient can be Linear or Radial. LinearGradient will look like this,

LinearGradient(colors: [Colors.red, Colors.green])
.createShader(Rect.fromLTRB(0, 0, 300, 300))

Basic blob Basic blob

Child Widget

You can use child property to display a child which looks like the blob as background.

Blob.random(
  size:200,
  child: Text('I am a child!'),
),

Child

Animating the blobs

Whenever the blobs are changing, this widget will animate the shape change.

Blob.animatedRandom(
  size:200,
  edgesCount:5,
  minGrowth:4,
  duration: Duration(milliseconds:500)
),

duration is optional. Default is 500 milliseconds.

Animation

Change shapes automatically

When you want to change the shapes automatically you can set loop to true.

Blob.animatedRandom(
  size:200,
  edgesCount:5,
  minGrowth:4,
  loop: true,
),

Animate Fixed shapes

If you use loop in Blob.fromAnimatedHash() widget, it will change shapes within the provided blobs.

Blob.animatedFromHash(
  size:200,
  hash:['XXXXXXXX...','YYYYYYY....','ZZZZZZZZ....'],
  loop: true,
),

Animate fixed blobs

Debug

When you set debug to true, it will show you circles and lines that connect the blob points.

Blob.random(
  size:200,
  debug: true,
),

Debug

Clipper #

Sometime you. might want to clip the widget by blob shape. In such cases you can use BlobClipper(). You can either provide hash or edgesCount and minGrowth options.

Container(
	child: ClipPath(
        clipper: BlobClipper(<OPTIONS>),
        child: new Image.network("https://bit.ly/2nirIxg"),
      ),
)

Animate fixed blobs

Service #

Blobs shape are created by BlobGenerator(). Both widgets and clipper uses this internally to create the shape and then it is painted to canvas. This will return BlobData.


BlobData blobData =  BlobGenerator(
  edgesCount: 7,
  minGrowth: 4,
  size: Size(30, 30),
  hash: null,
).generate();

BlobData

It is the raw data, which contains the path definitions, coordinates and other basic info about the blob.

BlobData(
  dots,
  innerRad,
  svgPath,
  coords,
  hash,
  edgesCount,
  minGrowth,
  size,
  originalSize,
)

SVG

BlobData contains svgPath info. It is just a path string which will look like this,

M326.0,251.5Q282.0,303.0,226.5,315.0Q171.0,327.0,118.5,296.0Q66.0,265.0,90.0,211.5Q114.0,158.0,145.0,126.0Q176.0,94.0,228.5,96.0Q281.0,98.0,325.5,149.0Q370.0,200.0,326.0,251.5Z

from this you can easily create SVG like

<svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
  <path fill="#474787" d="M326.0,251.5Q282.0,303.0,226.5,315.0Q171.0,327.0,118.5,296.0Q66.0,265.0,90.0,211.5Q114.0,158.0,145.0,126.0Q176.0,94.0,228.5,96.0Q281.0,98.0,325.5,149.0Q370.0,200.0,326.0,251.5Z" />
</svg>
339
likes
0
pub points
89%
popularity

Publisher

unverified uploader

Create beautiful blobs - fixed/random blob generation, animations, svgs and more

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

archive, flutter

More

Packages that depend on blobs