Git Product home page Git Product logo

xl_old's Introduction

๐Ÿ•น๏ธ xl

API References: XL


XL Package Logotype XL Logotype "Spinning Top"
Starfield Warpspeed

A package providing the XL stack widget to implement accelerometer- and
pointer-fueled parallax animations that smoothly transform
children according to a spatial, three-dimensional layer definition.
Touch and Gyroscope support included.

Design simple or elaborate XL-erometer driven interactions and interfaces.

ย 

Getting Started

To get started with sensor data, use an XL with XLayers:

const Widget xl = XL(layers: [XLayer(. . .), ...]);

To distinguish between pointer data (mouse/touch) and sensors data,
employ PLayers and the relevant flags:

const Widget xl = XL(
 sharesPointer = false, // default is true
 sharesSensors = false, // default is false
 layers: [
   PLayer(. . .), // ignores sensors
   PLayer(. . .), // ignores sensors
   XLayer(. . .), // ignores pointer
   ...
 ],
);

ย 

Layers

The XL.layers property takes a list of XLayers or PLayers.

These layers allow you to define the animatable properties of their child widgets.

Delicious parallax by accelerometer ๐Ÿคค is the result of the below Example:

class Example extends StatelessWidget {
 @override
 Widget build(BuildContext context) {
   return MaterialApp(home: Scaffold(
     body: XL(
       layers: [
         XLayer(
           xRotation: 1.0,
           yRotation: 1.0,
           xOffset: 200,
           yOffset: 200,
           child: Center(
             child: Container(
               width: 250,
               height: 250,
               color: Colors.black,
         ))),
         XLayer(
           xRotation: 1.5,
           yRotation: 1.5,
           xOffset: 300,
           yOffset: 300,
           child: Center(
             child: Container(
               width: 200,
               height: 200,
               color: Colors.red,
         ))),
       ],
     ),
   ));
 }
}

ย 

Advanced Usage

As stated, an XL may have both varieties of layer interspersed.
The default function of the stack is to apply pointer data to both
varieties of Layer, and to only apply sensors data to XLayers;
there are, however, flags available to toggle either functionality, as:

const layers = [
  XLayer(/* Blue X Layer; reactive */),
  PLayer(/* Red P Layer; more reactive */),
  XLayer(/* Black Layer; non-reactive control */),
];

final example = Column(children: [
  Expanded(
    child: Row(children: [
      const Expanded(
        child: XL(
          // X and P Layers behave the same way with these flags
          // (but still may differ slightly on parameters for Z axis rotation).
          sharesPointer: true,
          sharesSensors: true,
          layers: layers,
      )),
      const Expanded(
        child: XL(
          // All Layers react to pointers, but only XLayers
          // will recognize sensors. Default flags.
          sharesPointer: true, // default
          sharesSensors: false, // default
          layers: layers,
  ))])),
  Expanded(
    child: Row(children: [
      const Expanded(
        child: XL(
          // All Layers react to sensors,
          // but only PLayers will recognize pointer.
          sharesPointer: false,
          sharesSensors: true,
          layers: layers,
      )),
      const Expanded(
        child: XL(
          // Each Layer will deal only with its prescribed input data.
          sharesPointer: false,
          sharesSensors: false,
          layers: layers,
  ))])),
]);

That same stack of layers laid out in a demonstration with the two flags in their four possible configurations:

Flags to handle `XLayers` and `PLayers` separately

๐ŸŸฅ Red layers are PLayers and react primarily to pointers data.
๐Ÿ‘ˆ The left two ๐ŸŸฅ PLayers also consider sensors data

๐ŸŸฆ Blue layers are XLayers and react primarily to sensors data.
๐Ÿ‘† The top two ๐ŸŸฆ XLayers also consider pointer data

โฌ› Black layers are control XLayers with no animation properties. They make no reaction to any input.

ย 

Reference

๐Ÿ›ฃ๏ธ Roadmap

  1. ๐Ÿ”ณ Provide richer access to sensors data and ability to manipulate Layers in new ways
    • Such as an AccelSpec and GyroSpec that would enable transformation of any axis based on input from any axis, determined by parameter.
      • Currently, for example, yRotation is controlled by accelerometer X axis rotation. zRotation may also be controlled by accelerometer X axis rotation with parameter zRotationByX. However, zRotationByGyro may interpret Z axis gyroscope rotations. It is the only axis with two such inputs.
      • Imagine declaring an axis to rotate or offset, then also determining which axis/sensor contributes to it. What deep options that could provide! Such as offsetting a Widget vertically and rotating it over Y axis based on only one input from accelerometer.
  2. ๐Ÿ”ณ Along with #1 above, provide more Gyroscope functionality than only one axis of influence.
    • Gyro is a little tricker, as the sensor mostly reads flat near-0 values unless the device is moving.
    • This still provides cool options for developers to make neat interactions, and so should be expanded upon.
  3. โœ… Offer an automatic XL stack that simply accepts a List<Widget> (not necessarily XLayers) and dynamically generates progressively greater translation and rotation values for each layer.
    • Check out AutoXL which makes a parallax stack even easier to implement.
      Simply provide any old widgets as layers and optionally tinker with the depthFactor or max layer depth.
    • Pre-configured: AutoXL.pane, AutoXL.wiggler, AutoXL.deep

ย 

๐Ÿž Bugs

  1. Discrepancy with normalization delay and normalization duration.

ย 

๐Ÿ“œ History

For posterity and developer preference, there are three extension "wrappers" available.

  • Instead of the short, all-caps XL, consider a ParallaxStack
  • Instead of the double-cap XLayer, consider an AcceleraxLayer
  • Instead of the double-cap PLayer, consider a ParallaxLayer
final xl = ParallaxStack( // XL
  sharesSensors: true, // same parameters and functionality
  layers: [
    AcceleraxLayer(. . .), // XLayer
    ParallaxLayer(. . .), // PLayer
  ],
);
WORK IN PROGRESS
Forked from mouse_parallax considering the required AnimatedParallaxStack widget is not exported with the original package and that accelerometers have nothing to do with mice.
transparent 600x1 pixel-pusher (ignore) ๐Ÿ“š

More by Zaba

Wrappers | Widgets that surround other widgets with functionality


Container Widget | Wraps many functionalities in one, very customizable


Succinct Utility | Work great alone or employed above

  • ๐Ÿ†• neu header

  • ๐Ÿ™‹โ€โ™‚๏ธ img

  • ๐Ÿ™‹โ€โ™‚๏ธ icon

  • ๐Ÿ“ ball

  • ๐Ÿ‘โ€๐Ÿ—จ sense

  • ๐Ÿ‘ฅ shadows

  • ๐ŸŽจ spectrum header

xl_old's People

Contributors

wilsonowilson avatar zabadam avatar creativecreatorormaybenot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.