# Draw pixels instead of dots

How can I be able to draw a pixel instead of a dot and still change the color?

Is the only way to do this to draw a box and fill it or stamp a costume?

Turn on FLAT LINE ENDS. Then even at pen width 1 you can say MOVE 1 STEPS (should be move 0 steps; this is a longstanding misfeature that I had thought was fixed but I guess not) and get a tiny square that's plainly visible if you magnify the screen a lot.

Thanks!
Got it working now! However, is there any way to make it run even faster? I have it on turbo mode and I use warp but it would be great if I could make it more efficient! Currently, I replaced the majority of my operations with object creation to use the reuse of objects instead. Do you have any further suggestions?

Example source atm:

I like your vector arithmetic block! But why is it in Motion? I would put it in Operators with the scalar arithmetic blocks.

I believe that using both Warp and Turbo is redundant. Specifically, Warp implies Turbo, but not the other way around.

Other than that, I'm the worst person to ask about efficiency. Maybe @jens will chime in...

P.S. We've talked about extending the domain of the primitive arithmetic operators, and scalar operators in general, to vectors APL-style, e.g., multiplication would multiply corresponding elements termwise rather than doing vector dot product or cross product. But that's on the way-back burner. :~)

Perhaps I should do this in JavaScript instead for efficiency reasons, and just offer the raytracing and etc functions to Snap ! by calling them and getting return values from all the arithmetic.
Also the reason why vectors are in motion is because they represent a coordinate system. I could move the vector operations into Operators but imo it makes more sense to have all the vector based operations grouped together.

Consider micro benchmarking. For me, just marking the stage (480x360 pixels) with a pen, without any further processing, took approx. 5s.

I render at really really low resolutions by using a multiplier:

If going about this by using JS to call the trace functions, how do I execute them and get a return value? Is there some sort of doBlock function that takes in parameters?
I use raymarching in order to perform raycasts so sphere equations turn into stuff like this without needing to use a JS function to describe it instead:

Wanted to be able to call these directly in JS because complex Snap ! loops are very slow.

Is that what you're looking for?

Your loops are slow because you're using a custom FOR block. Try it this way:

It's still a custom block, but it's called only once. (I'm only guessing this'll be faster; I'm too lazy to do the experiment. :~P )

Na im looking for a solution to call using JS.
Essentially some way that I can pass in something like

to JS, and in JS do:

result = block.doBlock(pos /*in*/);


Also, this is my for loop, it is very sneaky:

Oh. Yeah, look at the implementation of the higher order functions, e.g. MAP, and see how they handle their function input.

I found

this.evaluate(reporter, new List(parms));


but what exactly is this within this context? How do I get a process?

Process.prototype.reportMap...


I don't think you have to worry about that; if your code is running, it's in a process! The reason for that procedure declaration is that Process.prototype is a place where primitive Snap! blocks are defined, but you're not defining a new primitive; I presume you're using a JS Function.

yes but i think that evaluate is what is being used to execute that reporter but I cannot seem to find out how to access this function.

I got this messy one but I am not sure if this is the way I am supposed to do it lmao:

Any better solutions for this? Hopefully in the future this function is more easily accessible or I might just not be knowing where else I can find it.

This also does not seem to be working for me all the time, this is honestly very confusing
oof
I moved the discussion off to this thread here so that it is more organized / on topic

Wait, I'm surprised that works for you any of the time! JS Block Execution Function isn't an actual JS function; it's a Snap! function that has a js function inside it. But you'd have to call it with evaluate().

Wait, what? It doesn't seem split off to me...

It returns a function which is a hacky way of going around that. And I used evaluate on the first process I could find but it doesn't seem to function properly.

Also this one was about drawing pixels which is already solved, I just wanted to separate the topic because it is about something different.

use the javascript block in operators