Error when using mix function in LESS in rails - ruby-on-rails

Using the less-rails gem.
Using the following code to mix two colours:
#base: #ffdc52;
#add: #195742;
.colour{
color: mix(#base, #add);
}
getting the following error:
Less::ParseError: error evaluating function `mix`: Cannot read property 'value' of undefined

mix needs three parameters:
mix: function (color1, color2, weight) {
var p = weight.value / 100.0;
...
},

Related

Svelte array of springs

Using svelte motion I need to create an array of springs for various objects.
import { spring, type Spring } from 'svelte/motion';
.
.
.
let coords: Array<Spring<{ x: number; y: number }>> = [];
for (let i = 0; i < foo.length; i++) {
coords.push(
spring(
{ x: 50, y: 0 },
{
stiffness: 0.1,
damping: 0.1
}
)
);
}
Now when I use it in inline style
<img alt="eggs" src="./spam"
style="transform: translate({$coords[j].x}px,{$coords[j].y}px)"
/>
I get the following error-
'coords' is not a store with a 'subscribe' method
Error: 'coords' is not a store with a 'subscribe' method
No overload matches this call.
Overload 1 of 2, '(store:SvelteStore<any>):any' gave the following error.
Argument of type 'Spring<{x:number; y:number;}>[]' is not assignable to the parameter of type 'SvelteStore<any>'.
Property 'subscribe' is missing in type 'Spring<{x:number; y:number;}>[]' but is required in type 'SvelteStore<any>'.
Overload 2 of 2, '(store:SvelteStore<any> | null |undefined ):any' gave the following error.
Argument of type 'Spring<{x:number; y:number;}>[]' is not assignable to the parameter of type 'SvelteStore<any>'.
How do I solve this without creating a custom store.
A $storeVar variable will only work for a store declared in a top-level variable. If you only need access to one of those stores, you could have a line like this in your <script>:
$: myCoords = coords[j];
and then $myCoords.x and $myCoords.y will work as you'd expect.
If you need to subscribe to every store in an array, you'll need to manage the subscriptions yourself. It's not hard, but you'll need to ensure every subscription gets unsubscribed at the appropriate time.
import { onDestroy } from "svelte";
let storeValues = [];
for ( let [i, store] of coords.entries() ) {
let unsubscribe = store.subscribe( (value) => {
storeValues[i] = value; // Svelte makes this reactive
} );
onDestroy( unsubscribe );
}

Trying to use add = True and I get an error message

I am Trying to use add = True and I get an error message. How can I do it?
This is my code
quadratcount(schools.pp)
plot(schools.sp, col = "red")
plot(quadratcount(schools.pp), add= T)`
and this is the error message I get
Error in (function (x, y = NULL, density = NULL, angle = 45, border = NULL, : plot.new has not been called yet
Looks like you made a simple typo: In the first plot command you write plot(schools.sp, col = "red"), where you probably meant plot(schools.pp, col = "red"). For future questions please provide a reproducible example where we can run each line including library(spatstat) and the definition of schools.pp etc. If you can't share your data just either:
use the first few points of your data
use a built-in dataset
generate artificial data

Dart: Constant evaluation error. The method '[]' can't be invoked in a constant expression

I am getting an error on constant evaluation.
please take a look at this code:
class A {
final num a;
const A(this.a);
}
class B {
final A a;
const B(this.a);
}
main() {
const a = A(12);
const b = B(a); // this works fine
// I believe everything inside a const List is considered constant,
// please correct me if that is wrong
const aL = [ A(12), A(13) ]; // [ a, A(13) ] will not work either
const b2 = B(
aL[0], // here the error is happening
);
}
Error:
lib/logic/dartTest.dart:22:14: Error: Constant evaluation error:
const b2 = B(
^
lib/logic/dartTest.dart:23:7: Context: The method '[]' can't be invoked on '<A>[A {a: 12}, A {a: 13}]' in a constant expression. - 'A' is from 'package:t_angband/logic/dartTest.dart' ('lib/logic/dartTest.dart').
aL[0],
^
lib/logic/dartTest.dart:22:9: Context: While analyzing:
const b2 = B(
^
The list contains constant Object, then why the constant evaluation is failing? Shouldn't this be an analyzer issue? Am I missing something?
Thankyou.
Constant expressions can only build data, it cannot deconstruct it. You cannot call any methods on the constant objects except a handful of operations on numbers (and String.length, which also creates a number).
So, aL[0] is simply not a valid compile-time constant expression.
A possible fix may be to make b2 not constant!

opencv: C2668: 'cvRound': ambiguous call to overloaded function

I am using opencv3.2 in Qt5.7. Here below are part of my codes:
for(int i=0;i<contour[0].size();i++)
{
if(contour[0][i].x>xmax) xmax = contour[0][i].x;
if(contour[0][i].x<xmin) xmin = contour[0][i].x;
if(contour[0][i].y>ymax) ymax = contour[0][i].y;
if(contour[0][i].y<ymin) ymin = contour[0][i].y;
}
int step = cvRound(contour[0].size()/16); #this line causes the error
The building error is:
error C2668: 'cvRound': ambiguous call to overloaded function
C:\opencv-3.2.0\mybuild\include\opencv2/core/fast_math.hpp(232): note: could be 'int cvRound(int)'
C:\opencv-3.2.0\mybuild\include\opencv2/core/fast_math.hpp(201): note: or 'int cvRound(float)'
C:\opencv-3.2.0\mybuild\include\opencv2/core/fast_math.hpp(93): note: or 'int cvRound(double)'
Anybody can help with the error?
Try to cast the parameters of the Round. You can write (float) in front of them. This way you help the compiler to find the correct Round function (the one that takes a float argument, for example)
I have solved the issue by changing:
int step = cvRound(contour[0].size()/16);
to:
int step = cvRound((double)contour[0].size()/16);

Using array notation instead of NSM on functions deeper then js.context.X

Can all objects after js.context be accessed with array notation from Dart? For example, I'd like to convert the following to use array notation:
var request = js.context.gapi.client.request(js.map(requestData));
Will the following array notation work?
var request = js.context['gapi']['client']['request'](js.map(requestData));
Also, should the following be done if trying to access JavaScript builtin methods?
js.context['JSON']['stringify'](jsonResp);
TL;DR : Starting from r24278 use array notation for properties and noSuchMethod for methods.
Using js.context['gapi']['client'] gives the same result as js.context.gapi.client. The main advantage of Array notation is that it avoids noSuchMethod. Until recently it was the only way to work around an issue in dart2js where minified does not work with noSuchMethod. This issue is fixed, and minification should work with Dart-JS interop.
I did a little benchmark some times ago :
For attribute access : array notation is around 10% faster than noSuchMethod. ( js.context.x vs. js.context['x'] )
For method access : array notation is around 50% slower than noSuchMethod. ( js.context.f() vs. js.context['f']() )
This last result is explained by 2 communications between JS and Dart for js.context['f'](). One to retrieve the function reference ( js.context['f'] ) and an other to call this function.
Last concern, using noSuchMethod can increase your dart2js result size (but not so much where I had tested it).
This works for me:
var hug = new js.Proxy(context['Hug']);
var hugDatabase = new js.Proxy(context['HugDatabase']);
hugDatabase['addHug'](hug);
print(hugDatabase['hugs']['length']);
Which interacts with this JavaScript:
function Hug(strength) {
this.strength = strength;
}
Hug.prototype.embrace = function(length) {
return 'Thanks, that was a good hug for ' + length + ' minutes!';
}
Hug.prototype.patBack = function(onDone) {
onDone('All done.');
}
function HugDatabase() {
this.hugs = [];
}
HugDatabase.prototype.addHug = function(hug) {
this.hugs.push(hug);
}
The full example is here: https://github.com/sethladd/dart-example-js-interop/blob/master/web/dart_js_interop_example.dart

Resources