Compass - Get width and height of generated sprite-map - sencha-touch

I'm building a Sencha Touch mobile application and are using the functionality to create image-sprite-maps with Compass.
Is there any way to calculate the size of the image-map (width and height) and put it as a variable in your SCSS file?

In Compass, image-height and image-width are the functions to get image dimensions. Using them with your sprite map would look something like this (warning, untested):
// Assuming $my-sprites is your sprite map variable
$map-path: sprite-path($my-sprites);
$map-height: image-height($map-path);
$map-width: image-width($map-path);

In the latest version of Sass (3.4) sprite-path() returns the full filesystem path while image-width() expects a path relative to the images directory. But there is a simple solution:
sprite-width($sprite-map);
sprite-height($sprite-map);

You can get a unit value by using the magical dimension functions <map>-sprite-height and <map>-sprite-width.
// Note: "my-icons" represents the folder name that contains your sprites.
#import "my-icons/*.png";
$box-padding: 5px;
$height: my-icons-sprite-height(some_icon);
$width: my-icons-sprite-width(some_icon);
.somediv {
height:$height + $box-padding;
width:$width + $box-padding;
}
Check the official documentation for more details.

Ext.getBody().getSize() gets you height and width of the screen but i dont think you can write this in SASS

Related

EaselJS: Is there any way to export a shape to an image file?

I have a project in CreateJS which I'd like to remake without CreateJS, but it seems that all my images are in an EaselJS shape format. For example:
this.shape_1 = new cjs.Shape();
this.shape_1.graphics.f("#465762").s().p("AgOAOQgFgFAAgJQAAgHAFgHQAHgFAHgBQAIABAHAFQAFAHAAAHQAAAJgFAFQgHAHgIgBQgHABgHgHg");
this.shape_1.setTransform(43.4,42,0.747,0.747);
Is there some method I could use to export that to an image file?
You can export any EaselJS DisplayObject by caching it, and then exporting the dataURL. Note that you have to know the raw bounds. If you want a larger cache of it, just increase the scale parameter.
this.shape_1.cache(x, y, w, h, [scale]);
var url = this.shape_1.getCacheDataURL();
Unfortunately this method does not support the parameters of the Canvas.toDataURL(), so if you want that, you can hit the cache directly:
this.shape_1.target.cacheCanvas.toDataURL(…[type], [encoderOptions]);
Then, you can use the dataURL in a number of ways. Here is an article on it. Alternatively, just throw the generated cache into the DOM, and right-click on it to save.
document.body.appendChild(this.shape_1.target.cacheCanvas);
Docs:
DisplayObject.cache()
EaselJS getCacheDataURL()
Canvas.toDataURL()

React Native Expo QRcode generate each rectangle with BorderRadius

I'm using the react-native-qrcode-svg package, but when I try to implement a simple QR code, this image returns.
I already tried removing all the styles, but keep returning the same image,
this is the code that i am using
<QRCode value="http://awesome.link.qr"/>
UPDATE
I was reviewing the code of the package and I noticed that it uses the Path to draw each box, check in the documentation and for some reason it has the property by default
strokeLinecap={'square'}
I had to specify that it was square, I also had to modify the width and height of each square, because they are poorly positioned.
I did that in the file
./node_modules/react-native-qrcode-svg/src/transformMAtrixIntoPath.js
I really don't know if I did it right, or there is another way much easier to solve, but for the moment that solved it
For someone who has the same problem, I fixed it like this:
ADD strokeLinecap={'square'} on Line 141, as property of at index.js file
Head to tranformMatrixIntoPath.js file and modify the algorithm
UPDATE Line 2 add const cellSize = size / matrix.length - 0.1
UPDATE Line 9 add path += 'M${cellSize * j + 9} ${cellSize / 2 + cellSize * i}'

Need to lighten a color within the variables passed in a LESS mixin

I am currently updating the bootstrap source less files for a project and I have to modify the hover state for the buttons. The end goal is something along these lines:
.btn-primary {
.buttonBackground(#btnPrimaryBackgroundHighlight, #btnPrimaryBackground);
&.hover {
.buttonBackground( lighten(#btnPrimaryBackgroundHighlight, %20), lighten(#btnPrimaryBackground, %20));
}
}
However, that returns a compile error. Any thoughts on this issue? I'm sure it's something simple, but I'm at a loss. Thanks in advance.
P.S. - I will also be using the :hover pseudo-class, but for sake of example I'm using a simple class.
Put the percent sign after the number (20% instead of %20)

Static image path in sass

In less you could always do this. You make a variable for the image path, and than you can insert the image path in the background url. How can I make this in SASS?
#static-path: "../../static";
background: url("#{static-path}/img/bg-header.jpg") repeat-x left bottom;
In SASS we define variables with $.
So define variable called path $img_path: "../../static";.
Then use something called interpolation (sass docs):
background: url("#{static-path}/img/bg-header.jpg") repeat-x left bottom;
When you are using COMPASS in your project you may use image-url() instead of url(), which grabs your image path from COMPASS config file.

App Store and iTunes API: Getting icon

I am using request like this:
http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa/wsLookup?country=ru&id=
It shows information about the app from the Apple App Store but I have some problems with icons.
If i'm getting property artworkUrl60 it is too small 60x60 image, but it is rounder.
And with artworkUrl100 I'm geting 512x512 image that is too big, not rounded and looks ugly when I'm sizing it down to 100x100.
How can I can get nice looking rounded 100x100 image?
You must get artworkUrl512 and then replace ".png" or ".jpg" with specific size ".100x100-75.png" or ".100x100-75.jpg"
See also list all available image formats (png / jpg):
42x42-50
53x53-50
60x60-50
72x72-65
75x75-65
29x29-75
53x53-75
58x58-75
64x64-75
84x84-75
100x100-75
114x114-75
128x128-75
150x150-75
170x170-75
175x175-75
200x200-75
256x256-75
340x340-75
350x350-75
512x512-75
https://itunes.apple.com/lookup?id=1036264023
As per documentation in iTunes Search API :
https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/
I use JQuery and add the ui-corner-all class to images to make them have rounded corners. This works for any size image.